### Complete Echo Bot Example Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/README.md A full example of an echo bot, including initialization, command handlers, an echo handler, and starting the bot's polling mechanism. ```python import telebot bot = telebot.TeleBot("YOUR_BOT_TOKEN") @bot.message_handler(commands=['start', 'help']) def send_welcome(message): bot.reply_to(message, "Howdy, how are you doing?") @bot.message_handler(func=lambda message: True) def echo_all(message): bot.reply_to(message, message.text) bot.infinity_polling() ``` -------------------------------- ### Install pyTelegramBotAPI by cloning repository Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/install.md Installs the pyTelegramBotAPI library by cloning the source code from GitHub and then running the setup script. This method allows for direct modification of the library's source code. ```bash git clone https://github.com/eternnoir/pyTelegramBotAPI.git cd pyTelegramBotAPI python setup.py install ``` -------------------------------- ### Text Starts With Filter Example Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/async_version/index.md Example of using the TextStartsFilter to trigger a handler when a message begins with specific text. ```python3 # Will work if message.text starts with 'sir'. @bot.message_handler(text_startswith='sir') # your function ``` -------------------------------- ### Install pyTelegramBotAPI using PIP Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/install.md Installs the pyTelegramBotAPI library using the pip package installer. This is the recommended method for most users. ```bash pip install pyTelegramBotAPI ``` -------------------------------- ### Custom TextStartsFilter Example Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/async_version/index.md Example of creating a custom filter to check if a message text starts with a specific string. This filter can be used in message handlers. ```python class TextStartsFilter(AdvancedCustomFilter): # Filter to check whether message starts with some text. key = 'text_startswith' def check(self, message, text): return message.text.startswith(text) ``` -------------------------------- ### Install pyTelegramBotAPI directly from GitHub Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/install.md Installs the pyTelegramBotAPI library directly from its GitHub repository using pip. This ensures you get the latest version available on the main branch. ```bash pip install git+https://github.com/eternnoir/pyTelegramBotAPI.git ``` -------------------------------- ### Async Message Handler Example Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/README.md Define an asynchronous message handler for the '/start' command using AsyncTeleBot. ```python import telebot tb = telebot.AsyncTeleBot("TOKEN") @tb.message_handler(commands=['start']) async def start_message(message): await bot.send_message(message.chat.id, 'Hello!') ``` -------------------------------- ### Get File Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/README.md Retrieves information about a file, used for downloading. ```APIDOC ## get_file ### Description Retrieves information about a file, which can then be used to download the file from Telegram's servers. ### Method GET ### Endpoint /getFile ### Parameters #### Query Parameters * **file_id** (string) - Required - File identifier to get information about. ``` -------------------------------- ### Create a Custom ReplyKeyboardMarkup Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/types.md Demonstrates how to create a custom keyboard with reply options. Use `resize_keyboard=True` to adjust the keyboard's height. The `add` method can take `KeyboardButton` objects or simple strings. ```python from telebot.types import ReplyKeyboardMarkup, KeyboardButton markup = ReplyKeyboardMarkup(resize_keyboard=True) markup.add(KeyboardButton('Text')) # or: markup.add('Text') ``` -------------------------------- ### Handle /start and /help Commands Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/README.md Register a message handler for specific commands. The decorated function receives the message object. ```python @bot.message_handler(commands=['start', 'help']) def send_welcome(message): bot.reply_to(message, "Howdy, how are you doing?") ``` -------------------------------- ### Create InlineKeyboardMarkup with quick_markup Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/types.md Use telebot.util.quick_markup to easily create an InlineKeyboardMarkup. This is the recommended approach for generating inline keyboards with URLs or callback data. ```python from telebot.util import quick_markup markup = quick_markup({ 'Twitter': {'url': 'https://twitter.com'}, 'Facebook': {'url': 'https://facebook.com'}, 'Back': {'callback_data': 'whatever'} }, row_width=2) # returns an InlineKeyboardMarkup with two buttons in a row, one leading to Twitter, the other to facebook # and a back button below ``` -------------------------------- ### AsyncTeleBot.answer_pre_checkout_query() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Use this method to respond to pre-checkout queries. On success, True is returned. ```APIDOC ## AsyncTeleBot.answer_pre_checkout_query() ### Description Use this method to respond to pre-checkout queries. On success, True is returned. ### Method POST (assumed, as it interacts with the Telegram API) ### Endpoint Not applicable (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response True #### Response Example None ``` -------------------------------- ### TeleBot.get_chat_members_count() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Gets the total number of members in a chat. This is an alternative method to get the member count. ```APIDOC ## TeleBot.get_chat_members_count() ### Description Gets the total number of members in a chat. This is an alternative method to get the member count. ### Method (Not specified in source, likely a method call) ### Endpoint (Not applicable for SDK method) ### Parameters (Parameters not detailed in source) ### Request Example (Not specified in source) ### Response (Response details not specified in source) ``` -------------------------------- ### Send Document with pathlib.Path Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/types.md Demonstrates how to send a document using a pathlib.Path object. Ensure the path is correctly formatted. ```python bot.send_document( chat_id, InputFile(pathlib.Path('/path/to/file/file.txt')) ) ``` -------------------------------- ### Get Bot Information Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/README.md Retrieves information about the bot user. This is a simple API call to get the bot's own details. ```python user = tb.get_me() ``` -------------------------------- ### telebot.util.quick_markup Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/util.md Generates an InlineKeyboardMarkup from a dictionary, simplifying the creation of inline keyboards with custom button layouts. ```APIDOC ## telebot.util.quick_markup(values: Dict[str, Dict[str, Any]], row_width: int = 2) -> types.InlineKeyboardMarkup ### Description Returns a reply markup from a dict in this format: {‘text’: kwargs} This is useful to avoid always typing ‘btn1 = InlineKeyboardButton(…)’ ‘btn2 = InlineKeyboardButton(…)’ ### Parameters * **values** (`dict`) – a dict containing all buttons to create in this format: {text: kwargs} {str:} * **row_width** (`int`) – number of [`telebot.types.InlineKeyboardButton`](types.md#telebot.types.InlineKeyboardButton) objects on each row ### Returns InlineKeyboardMarkup ### Return type `types.InlineKeyboardMarkup` ``` -------------------------------- ### Install pyTelegramBotAPI using pipenv Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/install.md Installs the pyTelegramBotAPI library within a pipenv environment. This is useful for managing project dependencies in isolation. ```bash pipenv install pyTelegramBotAPI ``` -------------------------------- ### IsDigitFilter Usage Example Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/async_version/index.md Example of using IsDigitFilter to process messages containing only digits. This filter is useful for validating numeric input from users. ```python @bot.message_handler(is_digit=True) # your function ``` -------------------------------- ### AsyncTeleBot.create_chat_invite_link() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Use this method to create a new invite link for a chat; any user can use this link to join the chat. The bot must be an administrator of the chat. Returns the new invite link on success. ```APIDOC ## AsyncTeleBot.create_chat_invite_link() ### Description Use this method to create a new invite link for a chat; any user can use this link to join the chat. The bot must be an administrator of the chat. Returns the new invite link on success. ### Method POST (assumed, as it interacts with the Telegram API) ### Endpoint Not applicable (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response Invite link object #### Response Example None ``` -------------------------------- ### Custom Asyncio Middleware Implementation Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/async_version/index.md Demonstrates how to create a custom middleware class for asyncio handlers, including pre- and post-processing logic for different update types. ```python class MyMiddleware(BaseMiddleware): def __init__(self): self.update_sensitive = True self.update_types = ['message', 'edited_message'] async def pre_process_message(self, message, data): # only message update here pass async def post_process_message(self, message, data, exception): pass # only message update here for post_process async def pre_process_edited_message(self, message, data): # only edited_message update here pass async def post_process_edited_message(self, message, data, exception): pass # only edited_message update here for post_process ``` -------------------------------- ### Get User Information Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/README.md Retrieves information about the bot user. ```APIDOC ## get_me ### Description Retrieves information about the bot user. ### Method GET ### Endpoint /getMe ### Response #### Success Response (200) - **user** (User object) - Information about the bot. ``` -------------------------------- ### get_file Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/async_version/index.md Obtains basic information about a file and prepares it for download. Returns a File object on success. The link is valid for at least 1 hour. ```APIDOC ## async get_file ### Description Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling get_file again. ### Method GET ### Endpoint /getFile ### Parameters #### Query Parameters - **file_id** (string) - Required - File identifier ### Response #### Success Response (200) - **file** (File) - A File object containing information about the file. ### Response Example ```json { "file": { "file_id": "file_id_123", "file_unique_id": "unique_file_id_123", "file_size": 1024, "file_path": "photos/file.jpg" } } ``` ``` -------------------------------- ### AsyncTeleBot.infinity_polling Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Starts an infinite polling loop to receive updates. ```APIDOC ## AsyncTeleBot.infinity_polling ### Description Starts an infinite polling loop to receive updates. ### Method GET ### Endpoint /infinityPolling ### Parameters #### Query Parameters - **none_stop** (boolean) - Optional - If True, the polling will continue even if an error occurs. - **timeout** (integer) - Optional - The timeout in seconds for the polling request. ``` -------------------------------- ### Continue Handling with Asyncio Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/async_version/index.md Illustrates how to use `ContinueHandling` in an asyncio handler to allow subsequent handlers to process the update. ```python3 @bot.message_handler(commands=['start']) async def start(message): await bot.send_message(message.chat.id, 'Hello World!') return ContinueHandling() ``` -------------------------------- ### TeleBot.get_my_name() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Gets the bot's name. This method retrieves the name displayed for the bot. ```APIDOC ## TeleBot.get_my_name() ### Description Gets the bot's name. This method retrieves the name displayed for the bot. ### Method (Not specified in source, likely a method call) ### Endpoint (Not applicable for SDK method) ### Parameters (Parameters not detailed in source) ### Request Example (Not specified in source) ### Response (Response details not specified in source) ``` -------------------------------- ### Initialize AsyncTeleBot Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/README.md Create an instance of AsyncTeleBot to enable asynchronous behavior for API calls. ```python import telebot tb = telebot.AsyncTeleBot("TOKEN") ``` -------------------------------- ### TeleBot.get_me() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Gets information about the bot. This method retrieves details about the bot itself, such as its username and ID. ```APIDOC ## TeleBot.get_me() ### Description Gets information about the bot. This method retrieves details about the bot itself, such as its username and ID. ### Method (Not specified in source, likely a method call) ### Endpoint (Not applicable for SDK method) ### Parameters (Parameters not detailed in source) ### Request Example (Not specified in source) ### Response (Response details not specified in source) ``` -------------------------------- ### TeleBot.get_game_high_scores() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Gets the high scores for a game. This method retrieves the leaderboard for a specific game. ```APIDOC ## TeleBot.get_game_high_scores() ### Description Gets the high scores for a game. This method retrieves the leaderboard for a specific game. ### Method (Not specified in source, likely a method call) ### Endpoint (Not applicable for SDK method) ### Parameters (Parameters not detailed in source) ### Request Example (Not specified in source) ### Response (Response details not specified in source) ``` -------------------------------- ### Send a document using InputFile from a file path Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/types.md Demonstrates sending a document by providing the file path to the InputFile constructor. The file will be opened and closed automatically by the class. ```python from telebot.types import InputFile bot.send_document( chat_id, InputFile('/path/to/file/file.txt') ) ``` -------------------------------- ### Get Updates Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/README.md Retrieves pending updates from Telegram. Can be configured with offset, limit, and timeout. ```APIDOC ## get_updates ### Description Retrieves pending updates from Telegram. This method can be used with polling or as a fallback if webhook is not configured. ### Method GET ### Endpoint /getUpdates ### Parameters #### Query Parameters * **offset** (integer) - Optional - Identifier of the first update to be returned. Defaults to the last unprocessed update ID + 1. * **limit** (integer) - Optional - Limits the number of updates to be retrieved. Defaults to 100. * **timeout** (integer) - Optional - Timeout in seconds for the long polling request. Defaults to 0 (no long polling). ``` -------------------------------- ### telebot.util.is_command Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/util.md Determines if a given string is a Telegram chat command, which starts with a '/' character. ```APIDOC ## telebot.util.is_command(text: str) ### Description Checks if text is a command. Telegram chat commands start with the ‘/’ character. ### Parameters * **text** (`str`) – Text to check. ### Returns True if text is a command, else False. ### Return type `bool` ``` -------------------------------- ### Sending a file using pathlib.Path Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/types.md Demonstrates how to send a file using a `pathlib.Path` object with the `send_document` method. ```APIDOC ## send_document with pathlib.Path ### Description This example shows how to send a document file by providing a `pathlib.Path` object to the `InputFile` constructor. ### Method `bot.send_document` ### Parameters * **chat_id**: The ID of the chat to send the document to. * **InputFile(pathlib.Path('/path/to/file/file.txt'))**: An `InputFile` object wrapping a `pathlib.Path` object representing the file to be sent. ### Request Example ```python bot.send_document(chat_id, InputFile(pathlib.Path('/path/to/file/file.txt'))) ``` ### Response * **file** (IOBase | str): File object or file path. * **file_name** (str): The name of the file. ``` -------------------------------- ### TeleBot.get_my_commands() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Gets the list of bot commands. This method retrieves the commands that are currently set for the bot. ```APIDOC ## TeleBot.get_my_commands() ### Description Gets the list of bot commands. This method retrieves the commands that are currently set for the bot. ### Method (Not specified in source, likely a method call) ### Endpoint (Not applicable for SDK method) ### Parameters (Parameters not detailed in source) ### Request Example (Not specified in source) ### Response (Response details not specified in source) ``` -------------------------------- ### Sending a Message with a ReplyKeyboardMarkup Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/types.md Example of sending a message to a chat with a custom reply keyboard attached. Ensure the 'markup' object is a properly initialized ReplyKeyboardMarkup instance. ```python bot.send_message(chat_id, 'Text', reply_markup=markup) ``` -------------------------------- ### AsyncTeleBot.answer_shipping_query() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Use this method to respond to shipping queries. On success, True is returned. ```APIDOC ## AsyncTeleBot.answer_shipping_query() ### Description Use this method to respond to shipping queries. On success, True is returned. ### Method POST (assumed, as it interacts with the Telegram API) ### Endpoint Not applicable (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response True #### Response Example None ``` -------------------------------- ### TeleBot.get_managed_bot_token() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Gets the token for a managed bot. This method retrieves the authentication token for a managed bot. ```APIDOC ## TeleBot.get_managed_bot_token() ### Description Gets the token for a managed bot. This method retrieves the authentication token for a managed bot. ### Method (Not specified in source, likely a method call) ### Endpoint (Not applicable for SDK method) ### Parameters (Parameters not detailed in source) ### Request Example (Not specified in source) ### Response (Response details not specified in source) ``` -------------------------------- ### Create and Use ReplyKeyboardMarkup Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/README.md Defines a custom keyboard with buttons for user interaction. Supports resizing, one-time use, and custom row widths. ```python from telebot import types # Using the ReplyKeyboardMarkup class # It's constructor can take the following optional arguments: # - resize_keyboard: True/False (default False) # - one_time_keyboard: True/False (default False) # - selective: True/False (default False) # - row_width: integer (default 3) # row_width is used in combination with the add() function. # It defines how many buttons are fit on each row before continuing on the next row. markup = types.ReplyKeyboardMarkup(row_width=2) itembtn1 = types.KeyboardButton('a') itembtn2 = types.KeyboardButton('v') itembtn3 = types.KeyboardButton('d') markup.add(itembtn1, itembtn2, itembtn3) tb.send_message(chat_id, "Choose one letter:", reply_markup=markup) # or add KeyboardButton one row at a time: markup = types.ReplyKeyboardMarkup() itembtna = types.KeyboardButton('a') itembtnv = types.KeyboardButton('v') itembtnc = types.KeyboardButton('c') itembtnd = types.KeyboardButton('d') itembtne = types.KeyboardButton('e') markup.row(itembtna, itembtnv) markup.row(itembtnc, itembtnd, itembtne) tb.send_message(chat_id, "Choose one letter:", reply_markup=markup) ``` -------------------------------- ### TeleBot.get_file() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Gets information about a file. This method retrieves metadata for a file, such as its path on Telegram servers. ```APIDOC ## TeleBot.get_file() ### Description Gets information about a file. This method retrieves metadata for a file, such as its path on Telegram servers. ### Method (Not specified in source, likely a method call) ### Endpoint (Not applicable for SDK method) ### Parameters (Parameters not detailed in source) ### Request Example (Not specified in source) ### Response (Response details not specified in source) ``` -------------------------------- ### TeleBot.get_chat_member_count() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Gets the number of members in a chat. This method returns the total count of users in a chat. ```APIDOC ## TeleBot.get_chat_member_count() ### Description Gets the number of members in a chat. This method returns the total count of users in a chat. ### Method (Not specified in source, likely a method call) ### Endpoint (Not applicable for SDK method) ### Parameters (Parameters not detailed in source) ### Request Example (Not specified in source) ### Response (Response details not specified in source) ``` -------------------------------- ### AsyncTeleBot.create_chat_subscription_invite_link() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Use this method to create a subscription invite link for a chat. Returns the invite link on success. ```APIDOC ## AsyncTeleBot.create_chat_subscription_invite_link() ### Description Use this method to create a subscription invite link for a chat. Returns the invite link on success. ### Method POST (assumed, as it interacts with the Telegram API) ### Endpoint Not applicable (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response Invite link object #### Response Example None ``` -------------------------------- ### add Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/types.md Adds strings or KeyboardButton objects to the keyboard, arranging them into rows based on the specified row_width. ```APIDOC ## add(*args, row_width=None) ### Description This function adds strings to the keyboard, while not exceeding row_width. It allows for flexible button arrangement within rows. ### Parameters - **args** (`str` or [`telebot.types.KeyboardButton`]) - Required - KeyboardButton to append to the keyboard. - **row_width** (`int`) - Optional - The maximum number of buttons per row. ### Returns - `self`, to allow function chaining. - Return type: [`telebot.types.ReplyKeyboardMarkup`] ``` -------------------------------- ### TeleBot.get_business_connection() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Gets information about a business connection. This method retrieves details about a specific business connection. ```APIDOC ## TeleBot.get_business_connection() ### Description Gets information about a business connection. This method retrieves details about a specific business connection. ### Method (Not specified in source, likely a method call) ### Endpoint (Not applicable for SDK method) ### Parameters (Parameters not detailed in source) ### Request Example (Not specified in source) ### Response (Response details not specified in source) ``` -------------------------------- ### TeleBot.get_my_description() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Gets the bot's description. This method retrieves the description that appears in the bot's profile. ```APIDOC ## TeleBot.get_my_description() ### Description Gets the bot's description. This method retrieves the description that appears in the bot's profile. ### Method (Not specified in source, likely a method call) ### Endpoint (Not applicable for SDK method) ### Parameters (Parameters not detailed in source) ### Request Example (Not specified in source) ### Response (Response details not specified in source) ``` -------------------------------- ### AsyncTeleBot.answer_web_app_query() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Use this method to answer any Web App queries. On success, True is returned. ```APIDOC ## AsyncTeleBot.answer_web_app_query() ### Description Use this method to answer any Web App queries. On success, True is returned. ### Method POST (assumed, as it interacts with the Telegram API) ### Endpoint Not applicable (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response True #### Response Example None ``` -------------------------------- ### TeleBot.get_my_default_administrator_rights() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Gets the default administrator rights for the bot. This method retrieves the default permissions granted to administrators. ```APIDOC ## TeleBot.get_my_default_administrator_rights() ### Description Gets the default administrator rights for the bot. This method retrieves the default permissions granted to administrators. ### Method (Not specified in source, likely a method call) ### Endpoint (Not applicable for SDK method) ### Parameters (Parameters not detailed in source) ### Request Example (Not specified in source) ### Response (Response details not specified in source) ``` -------------------------------- ### TeleBot.get_file_url() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Gets the download URL for a file. This method constructs the direct URL to download a file from Telegram. ```APIDOC ## TeleBot.get_file_url() ### Description Gets the download URL for a file. This method constructs the direct URL to download a file from Telegram. ### Method (Not specified in source, likely a method call) ### Endpoint (Not applicable for SDK method) ### Parameters (Parameters not detailed in source) ### Request Example (Not specified in source) ### Response (Response details not specified in source) ``` -------------------------------- ### AsyncTeleBot Initialization Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/async_version/index.md Initializes the AsyncTeleBot class with a token and optional parameters for message parsing, error handling, state storage, and logging. ```APIDOC ## AsyncTeleBot Constructor ### Description Initializes the main asynchronous class for the Bot, allowing for the addition of handlers for different kinds of updates. ### Parameters * **token** (`str`) – Token of a bot, obtained from @BotFather * **parse_mode** (`str`, optional) – Default parse mode, defaults to None * **offset** (`int`, optional) – Offset used in get_updates, defaults to None * **exception_handler** (*Optional* *[*[*ExceptionHandler*](#telebot.async_telebot.ExceptionHandler) *]* *,* *optional*) – Exception handler, which will handle the exception occured, defaults to None * **state_storage** (`telebot.asyncio_storage.StateMemoryStorage`, optional) – Storage for states, defaults to StateMemoryStorage() * **disable_web_page_preview** (`bool`, optional) – Default value for disable_web_page_preview, defaults to None * **disable_notification** (`bool`, optional) – Default value for disable_notification, defaults to None * **protect_content** (`bool`, optional) – Default value for protect_content, defaults to None * **allow_sending_without_reply** (`bool`, optional) – Deprecated - Use reply_parameters instead. Default value for allow_sending_without_reply, defaults to None * **colorful_logs** (`bool`, optional) – Outputs colorful logs * **validate_token** (`bool`, optional) – Validate token, defaults to True; ### Raises * **ImportError** – If coloredlogs module is not installed and colorful_logs is True * **ValueError** – If token is invalid ### Usage Example ```python from telebot.async_telebot import AsyncTeleBot bot = AsyncTeleBot('YOUR_BOT_TOKEN') ``` ``` -------------------------------- ### TeleBot.get_custom_emoji_stickers() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Gets a list of custom emoji stickers. This method retrieves available custom emoji stickers. ```APIDOC ## TeleBot.get_custom_emoji_stickers() ### Description Gets a list of custom emoji stickers. This method retrieves available custom emoji stickers. ### Method (Not specified in source, likely a method call) ### Endpoint (Not applicable for SDK method) ### Parameters (Parameters not detailed in source) ### Request Example (Not specified in source) ### Response (Response details not specified in source) ``` -------------------------------- ### AsyncTeleBot.set_business_account_gift_settings() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Set up a business account gift message. This method is part of the asynchronous API. ```APIDOC ## AsyncTeleBot.set_business_account_gift_settings() ### Description Set up a business account gift message. This method is part of the asynchronous API. ### Method POST ### Endpoint /setBusinessAccountGiftSettings ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **business_connection_id** (str) - Required - Unique identifier of the business connection. - **gift_message** (BusinessMessagesDeleted | BusinessMessage) - Optional - A JSON-serialized object for the business account's opening or welcome message. If empty, the opening message will be deleted. ### Request Example ```json { "business_connection_id": "connection_id_123", "gift_message": { "message_id": 1, "chat": { "id": 123456789, "type": "private", "first_name": "John Doe" }, "date": 1678886400, "text": "Welcome!" } } ``` ### Response #### Success Response (200) - **ok** (bool) - True if the request was successful. #### Response Example ```json { "ok": true } ``` ``` -------------------------------- ### TeleBot.get_chat_menu_button() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Gets the menu button for a chat. This method retrieves information about the menu button configured for a chat. ```APIDOC ## TeleBot.get_chat_menu_button() ### Description Gets the menu button for a chat. This method retrieves information about the menu button configured for a chat. ### Method (Not specified in source, likely a method call) ### Endpoint (Not applicable for SDK method) ### Parameters (Parameters not detailed in source) ### Request Example (Not specified in source) ### Response (Response details not specified in source) ``` -------------------------------- ### TeleBot.get_chat_administrators() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Gets a list of administrators in a chat. This method returns information about users who have administrative privileges in a chat. ```APIDOC ## TeleBot.get_chat_administrators() ### Description Gets a list of administrators in a chat. This method returns information about users who have administrative privileges in a chat. ### Method (Not specified in source, likely a method call) ### Endpoint (Not applicable for SDK method) ### Parameters (Parameters not detailed in source) ### Request Example (Not specified in source) ### Response (Response details not specified in source) ``` -------------------------------- ### AsyncTeleBot.create_invoice_link() Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/index.md Use this method to create a link for an invoice. Returns the link on success. ```APIDOC ## AsyncTeleBot.create_invoice_link() ### Description Use this method to create a link for an invoice. Returns the link on success. ### Method POST (assumed, as it interacts with the Telegram API) ### Endpoint Not applicable (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response Invoice link string #### Response Example None ``` -------------------------------- ### Custom ForwardFilter Implementation Source: https://github.com/eternnoir/pytelegrambotapi/blob/master/docs/source/async_version/index.md Example of implementing a custom SimpleCustomFilter to check if a message was forwarded. This demonstrates the basic structure for simple custom filters. ```python class ForwardFilter(SimpleCustomFilter): # Check whether message was forwarded from channel or group. key = 'is_forwarded' def check(self, message): return message.forward_date is not None ```