API Reference¶
Version Info¶
Bot¶
- defadd_event
- asyncclose
- asyncdelete_message
- asyncdelete_webhook
- asyncedit_message
- asyncget_bot
- asyncget_chat
- asyncget_chat_administrators
- asyncget_chat_member
- asyncget_chat_members_count
- asyncget_updates
- asyncget_user
- asyncinvite_to_chat
- defis_closed
- asyncleave_chat
- deflisten
- asyncon_error
- defremove_event
- defrun
- asyncsend_invoice
- asyncsend_message
- asyncsend_photo
- defwait_for
- class bale.Bot¶
This object represents a Bale Bot.
- Parameters:
token (str) – Bot Token
- listen(event_name)¶
Register a Event
- add_event(event, function)¶
Register an Event with event name
- remove_event(event, function=None)¶
Register an Event with event name
- wait_for(event_name, check=None, timeout=None)¶
Wait for an event
- property user¶
Represents the connected client.
None
if not logged in
- await close()¶
Close http Events and bot
- await on_error(event_name, error)¶
a Event for get errors when exceptions
- await get_bot()¶
- Returns:
Bot User information.
- Return type:
Bale.User
- Raises:
Bale.Error –
- await delete_webhook()¶
This service is used to remove the webhook set for the bot.
- Returns:
True
elseFalse
if not done- Return type:
- await send_message(chat, text=None, components=None, reply_to_message_id=None)¶
This service is used to send text messages.
- Parameters:
- Raises:
bale.Error –
- Returns:
The Message or
None
if message not sent- Return type:
Optional[
bale.Message
]
- await send_photo(chat, photo, caption=None, reply_to_message_id=None)¶
This service is used to send photo.
- Parameters:
- Raises:
bale.Error –
- Returns:
The Message or
None
if message not sent- Return type:
Optional[
bale.Message
]
- await send_invoice(chat, title, description, provider_token, prices, photo_url=None, need_name=False, need_phone_number=False, need_email=False, need_shipping_address=False, is_flexible=True)¶
You can use this service to send money request messages.
- Parameters:
chat (
bale.Chat
) – Chattitle (str) – Invoice Title
description (str) – Invoice Description
provider_token (str) – You can use 3 methods to receive money: 1.Card number 2. Port number and acceptor number 3. Wallet number “Bale”
prices (List[
bale.Price
]) – A list of prices.photo_url (str) – Photo URL of Invoice. Defaults to None.
need_name (bool) – Get a name from “User”?. Defaults to False.
need_phone_number (bool) – Get a Phone number from “User”?. Defaults to False.
need_email (bool) – Get a Email from “User”?. Defaults to False.
need_shipping_address (bool) – Get a Shipping Address from “User”?. Defaults to False.
is_flexible (bool) – Is the Invoice Photo Flexible to the Payment button?. Defaults to True.
- Return type:
Bale.Message
- await edit_message(chat, message_id, text, components=None)¶
You can use this service to edit text messages that you have already sent through the arm.
- Parameters:
chat (
bale.Chat
) – chatmessage_id (str) – message id
text (str) – New Content For Message.
components (Optional[
bale.Components
|bale.RemoveComponents
]) – message components
- Raises:
bale.Error –
- Return type:
- await delete_message(chat, message_id)¶
You can use this service to delete a message that you have already sent through the arm.
- In Channel or Group:
If it is a group or channel Manager, it can delete a message from (group or channel).
- In private message (PV):
If the message was sent by a bot, it can be deleted with this method
- await get_chat(chat_id)¶
This service can be used to receive personal information that has previously interacted with the arm.
- await get_user(user_id)¶
This Method almost like “bale.Bot.get_chat”, but this a filter that only get users.
- await get_chat_member(chat, user)¶
- Parameters:
- Raises:
bale.Error –
- Returns:
The chat member or
None
if not found.- Return type:
Optional[
bale.ChatMember
]
- await invite_to_chat(chat, user)¶
Invite user to the chat
- await leave_chat(chat)¶
Leave bot from a Chat
- await get_chat_members_count(chat)¶
- await get_chat_administrators(chat)¶
This service can be used to display admins of a group or channel.
- Parameters:
chat (
bale.Chat
) – Group id- Raises:
bale.Error –
- Returns:
list of chat member or
None
if chat not found.- Return type:
Optional[List[
bale.ChatMember
]]
- await get_updates(offset=None, limit=None)¶
Use this method to receive incoming updates using long polling.
- Parameters:
- Raises:
bale.Error –
- Returns:
The list of Updates or
None
if updates not found.- Return type:
List[
bale.Update
]
- run()¶
Run bot and https
Models¶
CallbackQuery¶
Chat¶
- asyncadd_user
- asyncget_chat_administrators
- asyncget_chat_member
- asyncget_chat_members_count
- asyncleave
- asyncsend
- asyncsend_photo
- class bale.Chat¶
This object indicates a chat.
- type¶
Chat Type.
- Type:
bale.ChatType
- pinned_message¶
Pinned messages in chat. Defaults to None.
- Type:
- all_members_are_administrators¶
Does everyone have admin access?. Defaults to True. (for Group)
- Type:
- property type¶
Get chat type
- await send(text, components=None)¶
For the documentation of the arguments, please see
bale.Bot.send_message()
.- Parameters:
text (str) – Message content
components (Optional[
bale.Components
|bale.RemoveComponents
]) – Message components
- Return type:
- await send_photo(photo, caption=None)¶
For the documentation of the arguments, please see
bale.Bot.send_photo()
.- Parameters:
photo (
bytes
|str
|bale.Photo
) – Photocaption (str) – Message caption.
- Raises:
bale.Error –
- Returns:
On success, the sent Message is returned.
- Return type:
Optional[
bale.Message
]
- await leave()¶
For the documentation of the arguments, please see
bale.Bot.leave_chat()
.- Returns:
- bool:
On success,
True
.
- await add_user(user)¶
For the documentation of the arguments, please see
bale.Bot.invite_to_chat()
.
- await get_chat_member(user)¶
For the documentation of the arguments, please see
bale.Bot.get_chat_member()
.- Parameters:
user (
bale.User
) – User- Returns:
On success, The chat member is retuened.
- Return type:
Optional[
bale.ChatMember
]
- await get_chat_members_count()¶
For the documentation of the arguments, please see
bale.Bot.get_chat_members_count()
.- Returns:
On success, The count of chat members is returned.
- Return type:
Optional[
int
]
- await get_chat_administrators()¶
For the documentation of the arguments, please see
bale.Bot.get_chat_administrators()
.- Raises:
bale.Error –
- Returns:
On success, The chat members is returned.
- Return type:
Optional[List[
bale.ChatMember
]]
User¶
- asyncsend
- asyncsend_photo
- class bale.User¶
This object shows a user.
- await send(text, components=None)¶
Send a Text Message to User
- Parameters:
text (str) – Message Content
components (
bale.Components
|bale.RemoveComponents
) – Message Components
- Returns:
On success, the sent Message is returned.
- Return type:
- await send_photo(photo, caption=None)¶
This service is used to send photo.
- Parameters:
photo (
bytes
|str
|bale.Photo
) – Photocaption (
str
) – Message caption
- Raises:
bale.Error –
- Returns:
On success, the sent Message is returned.
- Return type:
ChatMember¶
Message¶
- asyncdelete
- asyncedit
- asyncreply
- asyncreply_invoice
- asyncreply_photo
- class bale.Message¶
This object shows a message.
- date¶
When the message has been sent.
- Type:
- contact¶
Contact
- Type:
Optional[
bale.ContactMessage
]
- reply_to_message¶
The message Replyed to who message.
- Type:
Optional[
bale.Message
]
- invoice¶
Message invoice.
- Type:
Optional[
bale.Invoice
]
- await reply(text, components=None)¶
For the documentation of the arguments, please see
bale.Bot.send_message()
.- Parameters:
text (str) – Message Content.
components (Optional[
bot.Components
|bale.RemoveComponents
]) – Message Components.
- Raises:
bale.Error –
- Returns:
On success, the sent Message is returned.
- Return type:
- await reply_photo(photo, caption=None)¶
For the documentation of the arguments, please see
bale.Bot.send_photo()
.- Parameters:
- Raises:
bale.Error –
- Returns:
On success, the sent Message is returned.
- Return type:
- await reply_invoice(title, description, provider_token, prices, photo_url=None, need_name=False, need_phone_number=False, need_email=False, need_shipping_address=False, is_flexible=True)¶
For the documentation of the arguments, please see
bale.Bot.send_invoice()
- Parameters:
title (str) – Invoice Title
description (str) – Invoice Description
provider_token (str) –
Note
- You can use 3 methods to receive money:
Card number
Port number and acceptor number
Wallet number “Bale”
prices (List[
bale.Price
]) – A list of prices.photo_url (Optional[
str
]) – Photo URL of Invoice.need_name (Optional[
bool
]) – Get a name from “User”?need_phone_number (Optional[
bool
]) – Get a Phone number from “User”?.need_email (Optional[bool]) – Get a Email from “User”?.
need_shipping_address (Optional[bool]) – Get a Shipping Address from “User”?.
is_flexible (Optional[bool]) – Is the Invoice Photo Flexible to the Payment button?
- Returns:
On success, the message sent returned.
- Return type:
Bale.Message
- await edit(text=None, components=None)¶
For the documentation of the arguments, please see
bale.Bot.edit_message()
- Parameters:
text (str) – New Content for message.
components (
bale.Components
|bale.RemoveComponents
) – New Message Components for message.
- Raises:
bale.Error –
- Return type:
- await delete()¶
For the documentation of the arguments, please see
bale.Bot.delete_message()
.- Returns:
True
when user added to chat elseFalse
- Return type:
Update¶
- class bale.Update¶
This object shows an update.
- callback_query¶
Callback Query
- Type:
Optional[
bale.CallbackQuery
]
- message¶
Message
- Type:
Optional[
bale.Message
]
- edited_message¶
Edited Message
- Type:
Optional[
bale.Message
]
Components¶
- class bale.Components¶
- Parameters:
keyboards (List[
bale.Keyboard
]) – keyboardsinline_keyboards (List[
bale.InlineKeyboard
]) – inline keyboards
Inline Keyboard¶
- class bale.InlineKeyboard¶
This object shows an inline keyboard (within the message).
- callback_data¶
If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot’s username and the specified inline query in the input field. Can be empty, in which case just the bot’s username will be inserted. Defaults to None.
- Type:
- switch_inline_query¶
If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot’s username and the specified inline query in the input field. Can be empty, in which case just the bot’s username will be inserted. Defaults to None.
- Type:
Keyboard¶
Remove Components¶
- class bale.RemoveComponents¶
This object shows a remove keyboard.
Attachment Models¶
Audio¶
Contact Message¶
Document¶
- class bale.Document¶
This object shows a Document.
Photo¶
Location¶
Payment Models¶
Invoice¶
Price¶
Event Reference¶
Update¶
- bale.on_update(update)¶
Called when a Update Sent.
- Parameters:
update (
bale.Update
) – The update
Message¶
- bale.on_message(message)¶
Called when a Message Sent.
- Parameters:
message (
bale.Message
) – The message
Callback¶
- bale.on_callback(callback)¶
Called when a Callback Sent.
- Parameters:
callback (
bale.CallbackQuery
) – The callback