peyk.platforms.bale.methods

Bale client methods, one module per method.

async peyk.platforms.bale.methods.logout(self) bool[source]

Log the bot out of the cloud API server before running locally.

Wraps logout (no parameters). See docs.bale.ai: intended to be called before running the bot against a local/test environment.

Returns:

The operation result (bool).

async peyk.platforms.bale.methods.close_bot(self) bool[source]

Close the bot before moving it from one server to another.

Wraps the API’s close method – renamed here to avoid shadowing this class’s own close(), which closes the local transport session and is unrelated to this API call. See the module docstring for details.

Returns:

The operation result (bool).

async peyk.platforms.bale.methods.send_message(self, chat_id: int | str, text: str, *, reply_to_message_id: int | None = None, reply_markup: Mapping[str, object] | None = None) Message[source]

Sends message through the Bale API.

Parameters:
  • chat_id – Identifier of the target chat.

  • text – Text content supplied to the operation.

  • reply_to_message_id – Value used by this operation.

  • reply_markup – Keyboard or reply markup attached to the request.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.edit_message_text(self, chat_id: int | str, message_id: int, text: str, *, reply_markup: Mapping[str, object] | None = None) Message[source]

Edits message text through the Bale API.

Parameters:
  • chat_id – Identifier of the target chat.

  • message_id – Identifier of the target message.

  • text – Text content supplied to the operation.

  • reply_markup – Keyboard or reply markup attached to the request.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.edit_message_caption(self, chat_id: int | str, message_id: int, *, caption: str | None = None, reply_markup: Mapping[str, object] | None = None) Message[source]

Edits message caption through the Bale API.

Parameters:
  • chat_id – Identifier of the target chat.

  • message_id – Identifier of the target message.

  • caption – Value used by this operation.

  • reply_markup – Keyboard or reply markup attached to the request.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.edit_message_reply_markup(self, chat_id: int | str, message_id: int, *, reply_markup: Mapping[str, object] | None = None) Message[source]

Edits message reply markup through the Bale API.

Parameters:
  • chat_id – Identifier of the target chat.

  • message_id – Identifier of the target message.

  • reply_markup – Keyboard or reply markup attached to the request.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.forward_message(self, chat_id: int | str, from_chat_id: int | str, message_id: int) Message[source]

Performs the forward message operation for the Bale client.

Parameters:
  • chat_id – Identifier of the target chat.

  • from_chat_id – Value used by this operation.

  • message_id – Identifier of the target message.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.copy_message(self, chat_id: int | str, from_chat_id: int | str, message_id: int) Dict[str, object][source]

Performs the copy message operation for the Bale client.

Parameters:
  • chat_id – Identifier of the target chat.

  • from_chat_id – Value used by this operation.

  • message_id – Identifier of the target message.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.ban_chat_member(self, chat_id: int | str, user_id: int) bool[source]

Performs the ban chat member operation for the Bale client.

Parameters:
  • chat_id – Identifier of the target chat.

  • user_id – Identifier of the target user.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.promote_chat_member(self, chat_id: int | str, user_id: int, *, can_change_info: bool | None = None, can_post_messages: bool | None = None, can_edit_messages: bool | None = None, can_delete_messages: bool | None = None, can_manage_video_chats: bool | None = None, can_invite_users: bool | None = None, can_restrict_members: bool | None = None) bool[source]

Performs the promote chat member operation for the Bale client.

Parameters:
  • chat_id – Identifier of the target chat.

  • user_id – Identifier of the target user.

  • can_change_info – Value used by this operation.

  • can_post_messages – Value used by this operation.

  • can_edit_messages – Value used by this operation.

  • can_delete_messages – Value used by this operation.

  • can_manage_video_chats – Value used by this operation.

  • can_invite_users – Value used by this operation.

  • can_restrict_members – Value used by this operation.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.get_chat_administrators(self, chat_id: int | str) List[ChatMember][source]

Retrieves chat administrators from the Bale API.

Parameters:

chat_id – Identifier of the target chat.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.pin_chat_message(self, chat_id: int | str, message_id: int) bool[source]

Performs the pin chat message operation for the Bale client.

Parameters:
  • chat_id – Identifier of the target chat.

  • message_id – Identifier of the target message.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.unpin_chat_message(self, chat_id: int | str, message_id: int) bool[source]

Performs the unpin chat message operation for the Bale client.

Parameters:
  • chat_id – Identifier of the target chat.

  • message_id – Identifier of the target message.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.get_chat_members_count(self, chat_id: int | str) int[source]

Retrieves chat members count from the Bale API.

Parameters:

chat_id – Identifier of the target chat.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.set_chat_description(self, chat_id: int | str, description: str) bool[source]

Updates chat description through the Bale API.

Parameters:
  • chat_id – Identifier of the target chat.

  • description – Description to apply to the target resource.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.set_chat_photo(self, chat_id: int | str, photo: str | bytes | FilePayload) bool[source]

Updates chat photo through the Bale API.

Parameters:
  • chat_id – Identifier of the target chat.

  • photo – Photo input supplied to the operation.

Returns:

Result produced by the Bale operation.

Creates chat invite link through the Bale API.

Parameters:

chat_id – Identifier of the target chat.

Returns:

Result produced by the Bale operation.

Performs the revoke chat invite link operation for the Bale client.

Parameters:
  • chat_id – Identifier of the target chat.

  • invite_link – Value used by this operation.

Returns:

Result produced by the Bale operation.

Performs the export chat invite link operation for the Bale client.

Parameters:

chat_id – Identifier of the target chat.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.send_chat_action(self, chat_id: int | str, action: str) bool[source]

Sends chat action through the Bale API.

Parameters:
  • chat_id – Identifier of the target chat.

  • action – Value used by this operation.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.answer_callback_query(self, callback_query_id: str, *, text: str | None = None, show_alert: bool | None = None) bool[source]

Answers the callback query request through the Bale API.

Parameters:
  • callback_query_id – Identifier of the callback query.

  • text – Text content supplied to the operation.

  • show_alert – Value used by this operation.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.ask_review(self, user_id: int, delay_seconds: int) bool[source]

Performs the ask review operation for the Bale client.

Parameters:
  • user_id – Identifier of the target user.

  • delay_seconds – Value used by this operation.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.send_photo(self, chat_id: int | str, photo: str | bytes | FilePayload, *, caption: str | None = None, reply_to_message_id: int | None = None, reply_markup: Mapping[str, object] | None = None) Message[source]

Sends photo through the Bale API.

Parameters:
  • chat_id – Identifier of the target chat.

  • photo – Photo input supplied to the operation.

  • caption – Value used by this operation.

  • reply_to_message_id – Value used by this operation.

  • reply_markup – Keyboard or reply markup attached to the request.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.send_document(self, chat_id: int | str, document: str | bytes | FilePayload, *, caption: str | None = None, reply_to_message_id: int | None = None, reply_markup: Mapping[str, object] | None = None) Message[source]

Sends document through the Bale API.

Parameters:
  • chat_id – Identifier of the target chat.

  • document – Document input supplied to the operation.

  • caption – Value used by this operation.

  • reply_to_message_id – Value used by this operation.

  • reply_markup – Keyboard or reply markup attached to the request.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.send_audio(self, chat_id: int | str, audio: str | bytes | FilePayload, *, caption: str | None = None, reply_to_message_id: int | None = None, reply_markup: Mapping[str, object] | None = None) Message[source]

Sends audio through the Bale API.

Parameters:
  • chat_id – Identifier of the target chat.

  • audio – Audio input supplied to the operation.

  • caption – Value used by this operation.

  • reply_to_message_id – Value used by this operation.

  • reply_markup – Keyboard or reply markup attached to the request.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.send_video(self, chat_id: int | str, video: str | bytes | FilePayload, *, caption: str | None = None, reply_to_message_id: int | None = None, reply_markup: Mapping[str, object] | None = None) Message[source]

Sends video through the Bale API.

Parameters:
  • chat_id – Identifier of the target chat.

  • video – Video input supplied to the operation.

  • caption – Value used by this operation.

  • reply_to_message_id – Value used by this operation.

  • reply_markup – Keyboard or reply markup attached to the request.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.send_animation(self, chat_id: int | str, animation: str | bytes | FilePayload, *, caption: str | None = None, reply_to_message_id: int | None = None, reply_markup: Mapping[str, object] | None = None) Message[source]

Sends animation through the Bale API.

Parameters:
  • chat_id – Identifier of the target chat.

  • animation – Value used by this operation.

  • caption – Value used by this operation.

  • reply_to_message_id – Value used by this operation.

  • reply_markup – Keyboard or reply markup attached to the request.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.send_voice(self, chat_id: int | str, voice: str | bytes | FilePayload, *, caption: str | None = None, reply_to_message_id: int | None = None, reply_markup: Mapping[str, object] | None = None) Message[source]

Sends voice through the Bale API.

Parameters:
  • chat_id – Identifier of the target chat.

  • voice – Voice input supplied to the operation.

  • caption – Value used by this operation.

  • reply_to_message_id – Value used by this operation.

  • reply_markup – Keyboard or reply markup attached to the request.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.send_media_group(self, chat_id: int | str, media: Sequence[InputMediaPhoto | InputMediaVideo | InputMediaAnimation | InputMediaAudio | InputMediaDocument], *, reply_to_message_id: int | None = None) List[Message][source]

Sends media group through the Bale API.

Parameters:
  • chat_id – Identifier of the target chat.

  • media – Value used by this operation.

  • reply_to_message_id – Value used by this operation.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.send_location(self, chat_id: int | str, latitude: float, longitude: float, *, horizontal_accuracy: float | None = None, reply_to_message_id: int | None = None, reply_markup: Mapping[str, object] | None = None) Message[source]

Sends location through the Bale API.

Parameters:
  • chat_id – Identifier of the target chat.

  • latitude – Value used by this operation.

  • longitude – Value used by this operation.

  • horizontal_accuracy – Value used by this operation.

  • reply_to_message_id – Value used by this operation.

  • reply_markup – Keyboard or reply markup attached to the request.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.send_contact(self, chat_id: int | str, phone_number: str, first_name: str, *, last_name: str | None = None, reply_to_message_id: int | None = None, reply_markup: Mapping[str, object] | None = None) Message[source]

Sends contact through the Bale API.

Parameters:
  • chat_id – Identifier of the target chat.

  • phone_number – Value used by this operation.

  • first_name – Value used by this operation.

  • last_name – Value used by this operation.

  • reply_to_message_id – Value used by this operation.

  • reply_markup – Keyboard or reply markup attached to the request.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.upload_sticker_file(self, user_id: int, sticker: str | bytes | FilePayload) File[source]

Performs the upload sticker file operation for the Bale client.

Parameters:
  • user_id – Identifier of the target user.

  • sticker – Value used by this operation.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.create_new_sticker_set(self, user_id: int, name: str, title: str, stickers: Sequence[Mapping[str, object]]) bool[source]

Creates new sticker set through the Bale API.

Parameters:
  • user_id – Identifier of the target user.

  • name – Value used by this operation.

  • title – Title to apply to the target resource.

  • stickers – Value used by this operation.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.add_sticker_to_set(self, user_id: int, name: str, sticker: Mapping[str, object]) bool[source]

Performs the add sticker to set operation for the Bale client.

Parameters:
  • user_id – Identifier of the target user.

  • name – Value used by this operation.

  • sticker – Value used by this operation.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.send_invoice(self, chat_id: int | str, title: str, description: str, payload_: str, provider_token: str, prices: Sequence[Mapping[str, object]], *, photo_url: str | None = None, reply_to_message_id: int | None = None, reply_markup: Mapping[str, object] | None = None) Message[source]

Sends invoice through the Bale API.

Parameters:
  • chat_id – Identifier of the target chat.

  • title – Title to apply to the target resource.

  • description – Description to apply to the target resource.

  • payload – Value used by this operation.

  • provider_token – Value used by this operation.

  • prices – Value used by this operation.

  • photo_url – Value used by this operation.

  • reply_to_message_id – Value used by this operation.

  • reply_markup – Keyboard or reply markup attached to the request.

Returns:

Result produced by the Bale operation.

Creates invoice link through the Bale API.

Parameters:
  • title – Title to apply to the target resource.

  • description – Description to apply to the target resource.

  • payload – Value used by this operation.

  • provider_token – Value used by this operation.

  • prices – Value used by this operation.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.answer_pre_checkout_query(self, pre_checkout_query_id: str, ok: bool, *, error_message: str | None = None) bool[source]

Answers the pre checkout query request through the Bale API.

Parameters:
  • pre_checkout_query_id – Value used by this operation.

  • ok – Value used by this operation.

  • error_message – Value used by this operation.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.inquire_transaction(self, transaction_id: str) Transaction[source]

Performs the inquire transaction operation for the Bale client.

Parameters:

transaction_id – Value used by this operation.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.get_updates(self, *, offset: int | None = None, limit: int | None = None, timeout: int | None = None) List[Update][source]

Retrieves updates from the Bale API.

Parameters:
  • offset – Pagination offset returned by the preceding request.

  • limit – Maximum number of results requested.

  • timeout – Maximum time to wait for the operation.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.set_webhook(self, url: str) bool[source]

Updates webhook through the Bale API.

Parameters:

url – Target URL.

Returns:

Result produced by the Bale operation.

async peyk.platforms.bale.methods.delete_webhook(self) bool[source]

Delete the webhook and switch back to getUpdates.

Per docs.bale.ai, takes no parameters. Returns True on success.

Returns:

The operation result (bool).

Modules

add_sticker_to_set(self, user_id, name, sticker)

Performs the add sticker to set operation for the Bale client.

answer_callback_query(self, callback_query_id, *)

Answers the callback query request through the Bale API.

answer_pre_checkout_query(self, ...[, ...])

Answers the pre checkout query request through the Bale API.

ask_review(self, user_id, delay_seconds)

Performs the ask review operation for the Bale client.

ban_chat_member(self, chat_id, user_id)

Performs the ban chat member operation for the Bale client.

close_bot(self)

Close the bot before moving it from one server to another.

copy_message(self, chat_id, from_chat_id, ...)

Performs the copy message operation for the Bale client.

create_chat_invite_link(self, chat_id)

Creates chat invite link through the Bale API.

create_invoice_link(self, title, ...)

Creates invoice link through the Bale API.

create_new_sticker_set(self, user_id, name, ...)

Creates new sticker set through the Bale API.

delete_webhook(self)

Delete the webhook and switch back to getUpdates.

edit_message_caption(self, chat_id, ...[, ...])

Edits message caption through the Bale API.

edit_message_reply_markup(self, chat_id, ...)

Edits message reply markup through the Bale API.

edit_message_text(self, chat_id, message_id, ...)

Edits message text through the Bale API.

export_chat_invite_link(self, chat_id)

Performs the export chat invite link operation for the Bale client.

forward_message(self, chat_id, from_chat_id, ...)

Performs the forward message operation for the Bale client.

get_chat_administrators(self, chat_id)

Retrieves chat administrators from the Bale API.

get_chat_members_count(self, chat_id)

Retrieves chat members count from the Bale API.

get_updates(self, *[, offset, limit, timeout])

Retrieves updates from the Bale API.

inquire_transaction(self, transaction_id)

Performs the inquire transaction operation for the Bale client.

logout(self)

Log the bot out of the cloud API server before running locally.

pin_chat_message(self, chat_id, message_id)

Performs the pin chat message operation for the Bale client.

promote_chat_member(self, chat_id, user_id, *)

Performs the promote chat member operation for the Bale client.

revoke_chat_invite_link(self, chat_id, ...)

Performs the revoke chat invite link operation for the Bale client.

send_animation(self, chat_id, animation, *)

Sends animation through the Bale API.

send_audio(self, chat_id, audio, *[, ...])

Sends audio through the Bale API.

send_chat_action(self, chat_id, action)

Sends chat action through the Bale API.

send_contact(self, chat_id, phone_number, ...)

Sends contact through the Bale API.

send_document(self, chat_id, document, *[, ...])

Sends document through the Bale API.

send_invoice(self, chat_id, title, ...[, ...])

Sends invoice through the Bale API.

send_location(self, chat_id, latitude, ...)

Sends location through the Bale API.

send_media_group(self, chat_id, media, *[, ...])

Sends media group through the Bale API.

send_message(self, chat_id, text, *[, ...])

Sends message through the Bale API.

send_photo(self, chat_id, photo, *[, ...])

Sends photo through the Bale API.

send_video(self, chat_id, video, *[, ...])

Sends video through the Bale API.

send_voice(self, chat_id, voice, *[, ...])

Sends voice through the Bale API.

set_chat_description(self, chat_id, description)

Updates chat description through the Bale API.

set_chat_photo(self, chat_id, photo)

Updates chat photo through the Bale API.

set_webhook(self, url)

Updates webhook through the Bale API.

unpin_chat_message(self, chat_id, message_id)

Performs the unpin chat message operation for the Bale client.

upload_sticker_file(self, user_id, sticker)

Performs the upload sticker file operation for the Bale client.