donatello package#
Submodules#
donatello.async_client module#
- class donatello.async_client.AsyncDonatello(token: str, widget_id: str | None = None, longpool_timeout: int = 1, logging_level: int = 20)[source]#
Bases:
BaseClient
Donatello API wrapper
- Parameters:
token (str) – Donatello API token
widget_id (str) – Donatello widget ID
longpool_timeout (int) – Long polling timeout
logging_level (int) – Logging level
- Returns:
Donatello API wrapper
- Return type:
- Raises:
Exception – If API returns error
Longpoll:
>>> from donatello.client import Donatello >>> from donatello.models import LongpoolDonate >>> client = Donatello("your_token", "widget_id") >>> @client.on_ready # On client event >>> async def on_ready(): >>> user = await client.get_me() >>> print(f"Client name: {user.nickname}") >>> print(f"Total donates: {user.donates.total_amount}") >>> @client.on_donate # On donate event >>> async def on_donate(donate: LongpoolDonate): >>> print("------- NEW DONATE -------") >>> print(f"Nickname: {donate.name}") >>> print(f"Amount: {donate.amount} {donate.currency}") >>> print(f"Message: {donate.message}") >>> print(f"Date: {donate.created_at}") >>> print(f"Client name: {donate.client_name}") >>> client.start() # Start long polling
Basic Usage:
>>> import asyncio >>> from donatello.client import Donatello >>> from donatello.models import LongpoolDonate >>> client = Donatello("your_token", "widget_id") >>> async def main(): >>> user = await client.get_me() >>> print(f"Client name: {user.nickname}") >>> print(f"Total donates: {user.donates.total_amount}") >>> donates = await client.get_donates() >>> print(f"Donates: {donates}") >>> clients = await client.get_clients() >>> print(f"Clients: {clients}") >>> asyncio.run(main())
- await get_clients() ClientList [source]#
Get clients list
- Returns:
Clients list
- Return type:
- await get_donates() DonateList [source]#
Get donates list
- Returns:
Donates list
- Return type:
donatello.base module#
- class donatello.base.BaseClient(token: str, widget_id: str | None = None, longpool_timeout: int = 1, logging_level: int = 20, is_async: bool = False)[source]#
Bases:
object
Donatello API BaseClient
- Parameters:
token (str) – Donatello API token
widget_id (str) – Donatello widget ID
longpool_timeout (int) – Long polling timeout
logging_level (int) – Logging level
- Returns:
BaseClient
- Return type:
- Raises:
Exception – If API returns error
- property nickname: str#
Client nickname
- property public_id: str#
Client public ID
- property page: str#
Client page
- property is_active: bool#
Client activity
- property is_public: bool#
Client public status
- property donates: list#
Client donates
- property created_at: str#
Client created at
donatello.client module#
- class donatello.client.Donatello(token: str, widget_id: str | None = None, longpool_timeout: int = 1, logging_level: int = 20)[source]#
Bases:
BaseClient
Donatello API wrapper
- Parameters:
token (str) – Donatello API token
widget_id (str) – Donatello widget ID
longpool_timeout (int) – Long polling timeout
logging_level (int) – Logging level
- Returns:
Donatello API wrapper
- Return type:
- Raises:
Exception – If API returns error
Basic Usage:
>>> from donatello.client import Donatello >>> from donatello.models import LongpoolDonate, User >>> client = Donatello("your_token", "widget_id") >>> print(client.get_me()) # Get user info >>> print(client.get_donates()) # Get donates >>> print(client.get_clients()) # Get clients >>> @client.on_ready # On client event >>> def on_ready(client: User): >>> print(f"Client name: {client.nickname}") >>> print(f"Total donates: {client.donates.total_amount}") >>> @client.on_donate # On donate event >>> def on_donate(donate: LongpoolDonate): >>> print("------- NEW DONATE -------") >>> print(f"Nickname: {donate.name}") >>> print(f"Amount: {donate.amount} {donate.currency}") >>> print(f"Message: {donate.message}") >>> print(f"Date: {donate.created_at}") >>> print(f"Client name: {donate.client_name}") >>> client.start() # Start long polling
- get_donates(page: int = 0, per_page: int = 20) DonateList [source]#
Get donates Returns :class: DonateList with donates
- get_clients() ClientList [source]#
Get clients Returns :class: ClientList with clients
donatello.events module#
- class donatello.events.EventHandler[source]#
Bases:
object
An event handler for functions
Initialise a list of listeners