💸 Donatello-py Documentation#
Basic Usage#
Get and activate your API key here.
Sync#
from donatello import Donatello
client = Donatello("YOUR_API_KEY")
# Get client info
print(client.get_me())
# Get donates
print(client.get_donates(page=0, per_page=00))
# Get clients
print(client.get_clients())
Async#
from donatello import AsyncDonatello
client = AsyncDonatello("YOUR_API_KEY")
async def main():
print(await client.get_me())
print(await client.get_donates(page=0, per_page=00))
print(await client.get_clients())
asyncio.run(main())
Long polling#
For use long polling you need to create widget here and get widget id from url.
https://donatello.to/widget/<WIDGET_ID>/token/<YOUR_API_KEY>
Code example#
Sync#
from donatello import Donatello
from donatello.models import Donate, User
client = Donatello("YOUR_API_KEY", "WIDGET_ID")
@client.on_ready
def start(user: User):
print(f"Started with user {user.nickname}")
print(f"Donates Amount: {user.donates.total_amount}")
print(f"Donates count: {user.donates.total_count}")
@client.on_donate
def donate(donate: Donate):
print(donate)
client.start()
Async#
from donatello import AsyncDonatello
from donatello.models import Donate, User
client = AsyncDonatello("YOUR_API_KEY", "WIDGET_ID")
@client.on_donate
async def donate(donate):
print(f"Donator: {donate.nickname}")
print(f"Amount: {donate.amount} {donate.currency} / {donate.goal_amount} {donate.goal_currency}")
print(f"Message: {donate.message}")
@client.on_ready
async def ready(user):
print(user)
client.start()
Examples#
You can find more examples here.
API Reference#
- donatello package
- Submodules
- donatello.async_client module
- donatello.base module
BaseClient
BaseClient.nickname
BaseClient.public_id
BaseClient.page
BaseClient.is_active
BaseClient.is_public
BaseClient.donates
BaseClient.created_at
BaseClient.on_ready()
BaseClient.on_donate()
BaseClient.on_error()
BaseClient.remove_client_listener()
BaseClient.remove_donate_listener()
BaseClient.remove_error_listener()
- donatello.client module
- donatello.events module
- Module contents
- donatello.models package
- Submodules
- donatello.models.client module
- donatello.models.client_list module
- donatello.models.donate module
- donatello.models.donate_list module
- donatello.models.longpool_donale module
LongpoolDonate
LongpoolDonate.client_name
LongpoolDonate.message
LongpoolDonate.amount
LongpoolDonate.currency
LongpoolDonate.source
LongpoolDonate.image
LongpoolDonate.sound
LongpoolDonate.video
LongpoolDonate.interaction_media
LongpoolDonate.interaction_media_start_time
LongpoolDonate.goal_widget_name
LongpoolDonate.manually_approved
LongpoolDonate.ban
LongpoolDonate.is_published
LongpoolDonate.created_at
LongpoolDonate.is_subscription
LongpoolDonate.uploaded_voice
LongpoolDonate.name
LongpoolDonate.validate_created_at()
LongpoolDonate.model_config
LongpoolDonate.model_fields
- donatello.models.user module
- donatello.models.user_donates module
- Module contents
Contributing#
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
License#
MIT