Event Reference¶
The list of events that can be received by the bot.
An example of how to listen to events in different situations (for on_message
event):
from bale import Bot, Message
bot = Bot("YOUR_TOKEN")
@bot.event
async def on_message(message: Message):
if message.content == '/start':
return await message.reply("Hi, python-bale-bot!")
bot.run()
from bale import Bot, Message
class MyBot(Bot):
async def on_message(self, message: Message):
if message.content == '/start':
return await message.reply("Hi, python-bale-bot!")
MyBot('YOUR_TOKEN').run()
Connection¶
- async on_before_ready()¶
This event is called before the updater starts.
- async on_ready()¶
When the updater starts working and the Bot information is placed in
bale.Bot.user
.
Updates¶
- async on_update(update)¶
This event is called when an update is received from “Bale” servers.
- Parameters:
update (
bale.Update
) – update received.
Messages¶
- async on_message(message)¶
This event is called when sending a message in a chat to which the bot is connected.
- Parameters:
message (
bale.Message
) – message sent.
- async on_message_edit(message)¶
This event is called when the sent message is edited.
- Parameters:
message (
bale.Message
) – message edited.
CallbackQuery¶
- async on_callback(callback)¶
This event is called when a callback query is created.
- Parameters:
callback (
bale.CallbackQuery
) – callback received.
Groups¶
- async on_member_chat_join(message, chat, user)¶
This event is called when a user joins the chat.
- Parameters:
message (
bale.Message
) – message sent.chat (
bale.Chat
) – the chat.user (
bale.User
) – the user.
- async on_member_chat_leave(message, chat, user)¶
This event is called when a user leaves the chat.
- Parameters:
message (
bale.Message
) – message sent.chat (
bale.Chat
) – the chat.user (
bale.User
) – the user.
Payments¶
- async on_successful_payment(payment)¶
This event is called when a transaction is completed and its status is successful.
- Parameters:
successful_payment (
bale.SuccessfulPayment
) – the payment.