diff --git a/telebot/__init__.py b/telebot/__init__.py index 6cdea41..b61b076 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -73,10 +73,12 @@ class ExceptionHandler: class TeleBot: """ - This is the main class to deal with bot. + This is the main synchronous class for Bot. + It allows you to add handlers for different kind of updates. Usage: + .. code-block:: python from telebot import TeleBot diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index 464f65b..18a000d 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -5,7 +5,6 @@ import logging import re import time import traceback -import inspect from typing import Any, List, Optional, Union # this imports are used to avoid circular import error @@ -15,6 +14,7 @@ import telebot.types # storages from telebot.asyncio_storage import StateMemoryStorage, StatePickleStorage +from telebot.asyncio_handler_backends import CancelUpdate, SkipHandler from inspect import signature @@ -58,106 +58,23 @@ class ExceptionHandler: return False -class SkipHandler: - """ - Class for skipping handlers. - Just return instance of this class - in middleware to skip handler. - Update will go to post_process, - but will skip execution of handler. - """ - - def __init__(self) -> None: - pass - -class CancelUpdate: - """ - Class for canceling updates. - Just return instance of this class - in middleware to skip update. - Update will skip handler and execution - of post_process in middlewares. - """ - - def __init__(self) -> None: - pass - class AsyncTeleBot: - """ This is AsyncTeleBot Class - Methods: - getMe - logOut - close - sendMessage - forwardMessage - copyMessage - deleteMessage - sendPhoto - sendAudio - sendDocument - sendSticker - sendVideo - sendVenue - sendAnimation - sendVideoNote - sendLocation - sendChatAction - sendDice - sendContact - sendInvoice - sendMediaGroup - getUserProfilePhotos - getUpdates - getFile - sendPoll - stopPoll - sendGame - setGameScore - getGameHighScores - editMessageText - editMessageCaption - editMessageMedia - editMessageReplyMarkup - editMessageLiveLocation - stopMessageLiveLocation - banChatMember - unbanChatMember - restrictChatMember - promoteChatMember - setChatAdministratorCustomTitle - setChatPermissions - createChatInviteLink - editChatInviteLink - revokeChatInviteLink - exportChatInviteLink - setChatStickerSet - deleteChatStickerSet - createNewStickerSet - addStickerToSet - deleteStickerFromSet - setStickerPositionInSet - uploadStickerFile - setStickerSetThumb - getStickerSet - setChatPhoto - deleteChatPhoto - setChatTitle - setChatDescription - pinChatMessage - unpinChatMessage - leaveChat - getChat - getChatAdministrators - getChatMemberCount - getChatMember - answerCallbackQuery - getMyCommands - setMyCommands - deleteMyCommands - answerInlineQuery - answerShippingQuery - answerPreCheckoutQuery - """ + """ + This is the main asynchronous class for Bot. + + It allows you to add handlers for different kind of updates. + + Usage: + + .. code-block:: python + + from telebot.async_telebot import AsyncTeleBot + bot = AsyncTeleBot('token') # get token from @BotFather + + See more examples in examples/ directory: + https://github.com/eternnoir/pyTelegramBotAPI/tree/master/examples + + """ def __init__(self, token: str, parse_mode: Optional[str]=None, offset=None, exception_handler=None, state_storage=StateMemoryStorage()) -> None: # TODO: ADD TYPEHINTS @@ -195,6 +112,10 @@ class AsyncTeleBot: self.middlewares = [] async def close_session(self): + """ + Closes existing session of aiohttp. + Use this function if you stop polling. + """ await asyncio_helper.session_manager.session.close() async def get_updates(self, offset: Optional[int]=None, limit: Optional[int]=None, timeout: Optional[int]=None, allowed_updates: Optional[List]=None, request_timeout: Optional[int]=None) -> List[types.Update]: @@ -210,6 +131,7 @@ class AsyncTeleBot: Warning: Do not call this function more than once! Always get updates. + :param interval: Delay between two update retrivals :param non_stop: Do not stop polling when an ApiException occurs. :param timeout: Request connection timeout @@ -275,6 +197,7 @@ class AsyncTeleBot: request_timeout: int=20, allowed_updates: Optional[List[str]]=None): """ Function to process polling. + :param non_stop: Do not stop polling when an ApiException occurs. :param interval: Delay between two update retrivals :param timeout: Request connection timeout @@ -338,6 +261,7 @@ class AsyncTeleBot: async def _process_updates(self, handlers, messages, update_type): """ Process updates. + :param handlers: :param messages: :return: @@ -397,6 +321,13 @@ class AsyncTeleBot: await middleware.post_process(message, data, handler_error) # update handling async def process_new_updates(self, updates): + """ + Process new updates. + Just pass list of updates - each update should be + instance of Update object. + + :param updates: list of updates + """ upd_count = len(updates) logger.info('Received {0} new updates'.format(upd_count)) if upd_count == 0: return @@ -546,7 +477,8 @@ class AsyncTeleBot: async def _test_message_handler(self, message_handler, message): """ - Test message handler + Test message handler. + :param message_handler: :param message: :return: @@ -561,18 +493,25 @@ class AsyncTeleBot: return True def set_update_listener(self, func): + """ + Update listener is a function that gets any update. + + :param func: function that should get update. + """ self.update_listener.append(func) def add_custom_filter(self, custom_filter): """ Create custom filter. + custom_filter: Class with check(message) method. """ self.custom_filters[custom_filter.key] = custom_filter async def _test_filter(self, message_filter, filter_value, message): """ - Test filters + Test filters. + :param message_filter: Filter type passed in handler :param filter_value: Filter value passed in handler :param message: Message to test @@ -594,8 +533,6 @@ class AsyncTeleBot: elif message_filter == 'chat_types': return message.chat.type in filter_value elif message_filter == 'func': - if inspect.iscoroutinefunction(filter_value): - return await filter_value(message) return filter_value(message) elif self.custom_filters and message_filter in self.custom_filters: return await self._check_filter(message_filter,filter_value,message) @@ -604,7 +541,8 @@ class AsyncTeleBot: async def _check_filter(self, message_filter, filter_value, message): """ - Check up the filter + Check up the filter. + :param message_filter: :param filter_value: :param message: @@ -623,8 +561,9 @@ class AsyncTeleBot: def setup_middleware(self, middleware): """ - Setup middleware - :param middleware: + Setup middleware. + + :param middleware: Middleware-class. :return: """ self.middlewares.append(middleware) @@ -695,7 +634,9 @@ class AsyncTeleBot: def add_message_handler(self, handler_dict): """ - Adds a message handler + Adds a message handler. + Note that you should use register_message_handler to add message_handler. + :param handler_dict: :return: """ @@ -704,6 +645,7 @@ class AsyncTeleBot: def register_message_handler(self, callback, content_types=None, commands=None, regexp=None, func=None, chat_types=None, pass_bot=False, **kwargs): """ Registers message handler. + :param callback: function to be called :param content_types: list of content_types :param commands: list of commands @@ -735,7 +677,8 @@ class AsyncTeleBot: def edited_message_handler(self, commands=None, regexp=None, func=None, content_types=None, chat_types=None, **kwargs): """ - Edit message handler decorator + Edit message handler decorator. + :param commands: :param regexp: :param func: @@ -771,7 +714,9 @@ class AsyncTeleBot: def add_edited_message_handler(self, handler_dict): """ - Adds the edit message handler + Adds the edit message handler. + Note that you should use register_edited_message_handler to add edited_message_handler. + :param handler_dict: :return: """ @@ -780,6 +725,7 @@ class AsyncTeleBot: def register_edited_message_handler(self, callback, content_types=None, commands=None, regexp=None, func=None, chat_types=None, pass_bot=False, **kwargs): """ Registers edited message handler. + :param pass_bot: :param callback: function to be called :param content_types: list of content_types @@ -810,7 +756,8 @@ class AsyncTeleBot: def channel_post_handler(self, commands=None, regexp=None, func=None, content_types=None, **kwargs): """ - Channel post handler decorator + Channel post handler decorator. + :param commands: :param regexp: :param func: @@ -843,7 +790,9 @@ class AsyncTeleBot: def add_channel_post_handler(self, handler_dict): """ - Adds channel post handler + Adds channel post handler. + Note that you should use register_channel_post_handler to add channel_post_handler. + :param handler_dict: :return: """ @@ -852,6 +801,7 @@ class AsyncTeleBot: def register_channel_post_handler(self, callback, content_types=None, commands=None, regexp=None, func=None, pass_bot=False, **kwargs): """ Registers channel post message handler. + :param pass_bot: :param callback: function to be called :param content_types: list of content_types @@ -879,7 +829,8 @@ class AsyncTeleBot: def edited_channel_post_handler(self, commands=None, regexp=None, func=None, content_types=None, **kwargs): """ - Edit channel post handler decorator + Edit channel post handler decorator. + :param commands: :param regexp: :param func: @@ -912,7 +863,9 @@ class AsyncTeleBot: def add_edited_channel_post_handler(self, handler_dict): """ - Adds the edit channel post handler + Adds the edit channel post handler. + Note that you should use register_edited_channel_post_handler to add edited_channel_post_handler. + :param handler_dict: :return: """ @@ -921,6 +874,7 @@ class AsyncTeleBot: def register_edited_channel_post_handler(self, callback, content_types=None, commands=None, regexp=None, func=None, pass_bot=False, **kwargs): """ Registers edited channel post message handler. + :param pass_bot: :param callback: function to be called :param content_types: list of content_types @@ -948,7 +902,8 @@ class AsyncTeleBot: def inline_handler(self, func, **kwargs): """ - Inline call handler decorator + Inline call handler decorator. + :param func: :param kwargs: :return: @@ -963,7 +918,9 @@ class AsyncTeleBot: def add_inline_handler(self, handler_dict): """ - Adds inline call handler + Adds inline call handler. + Note that you should use register_inline_handler to add inline_handler. + :param handler_dict: :return: """ @@ -972,6 +929,7 @@ class AsyncTeleBot: def register_inline_handler(self, callback, func, pass_bot=False, **kwargs): """ Registers inline handler. + :param pass_bot: :param callback: function to be called :param func: @@ -982,6 +940,7 @@ class AsyncTeleBot: def chosen_inline_handler(self, func, **kwargs): """ + Description: TBD :param func: :param kwargs: @@ -998,6 +957,8 @@ class AsyncTeleBot: def add_chosen_inline_handler(self, handler_dict): """ Description: TBD + Note that you should use register_chosen_inline_handler to add chosen_inline_handler. + :param handler_dict: :return: """ @@ -1006,6 +967,7 @@ class AsyncTeleBot: def register_chosen_inline_handler(self, callback, func, pass_bot=False, **kwargs): """ Registers chosen inline handler. + :param pass_bot: :param callback: function to be called :param func: @@ -1016,7 +978,8 @@ class AsyncTeleBot: def callback_query_handler(self, func, **kwargs): """ - Callback request handler decorator + Callback request handler decorator. + :param func: :param kwargs: :return: @@ -1031,7 +994,9 @@ class AsyncTeleBot: def add_callback_query_handler(self, handler_dict): """ - Adds a callback request handler + Adds a callback request handler. + Note that you should use register_callback_query_handler to add callback_query_handler. + :param handler_dict: :return: """ @@ -1039,7 +1004,8 @@ class AsyncTeleBot: def register_callback_query_handler(self, callback, func, pass_bot=False, **kwargs): """ - Registers callback query handler.. + Registers callback query handler. + :param pass_bot: :param callback: function to be called :param func: @@ -1050,7 +1016,8 @@ class AsyncTeleBot: def shipping_query_handler(self, func, **kwargs): """ - Shipping request handler + Shipping request handler. + :param func: :param kwargs: :return: @@ -1065,7 +1032,9 @@ class AsyncTeleBot: def add_shipping_query_handler(self, handler_dict): """ - Adds a shipping request handler + Adds a shipping request handler. + Note that you should use register_shipping_query_handler to add shipping_query_handler. + :param handler_dict: :return: """ @@ -1074,6 +1043,7 @@ class AsyncTeleBot: def register_shipping_query_handler(self, callback, func, pass_bot=False, **kwargs): """ Registers shipping query handler. + :param pass_bot: :param callback: function to be called :param func: @@ -1084,7 +1054,8 @@ class AsyncTeleBot: def pre_checkout_query_handler(self, func, **kwargs): """ - Pre-checkout request handler + Pre-checkout request handler. + :param func: :param kwargs: :return: @@ -1099,7 +1070,9 @@ class AsyncTeleBot: def add_pre_checkout_query_handler(self, handler_dict): """ - Adds a pre-checkout request handler + Adds a pre-checkout request handler. + Note that you should use register_pre_checkout_query_handler to add pre_checkout_query_handler. + :param handler_dict: :return: """ @@ -1108,6 +1081,7 @@ class AsyncTeleBot: def register_pre_checkout_query_handler(self, callback, func, pass_bot=False, **kwargs): """ Registers pre-checkout request handler. + :param pass_bot: :param callback: function to be called :param func: @@ -1118,7 +1092,8 @@ class AsyncTeleBot: def poll_handler(self, func, **kwargs): """ - Poll request handler + Poll request handler. + :param func: :param kwargs: :return: @@ -1133,7 +1108,9 @@ class AsyncTeleBot: def add_poll_handler(self, handler_dict): """ - Adds a poll request handler + Adds a poll request handler. + Note that you should use register_poll_handler to add poll_handler. + :param handler_dict: :return: """ @@ -1142,6 +1119,7 @@ class AsyncTeleBot: def register_poll_handler(self, callback, func, pass_bot=False, **kwargs): """ Registers poll handler. + :param pass_bot: :param callback: function to be called :param func: @@ -1152,7 +1130,8 @@ class AsyncTeleBot: def poll_answer_handler(self, func=None, **kwargs): """ - Poll_answer request handler + Poll_answer request handler. + :param func: :param kwargs: :return: @@ -1167,7 +1146,9 @@ class AsyncTeleBot: def add_poll_answer_handler(self, handler_dict): """ - Adds a poll_answer request handler + Adds a poll_answer request handler. + Note that you should use register_poll_answer_handler to add poll_answer_handler. + :param handler_dict: :return: """ @@ -1176,6 +1157,7 @@ class AsyncTeleBot: def register_poll_answer_handler(self, callback, func, pass_bot=False, **kwargs): """ Registers poll answer handler. + :param pass_bot: :param callback: function to be called :param func: @@ -1186,7 +1168,8 @@ class AsyncTeleBot: def my_chat_member_handler(self, func=None, **kwargs): """ - my_chat_member handler + my_chat_member handler. + :param func: :param kwargs: :return: @@ -1201,7 +1184,9 @@ class AsyncTeleBot: def add_my_chat_member_handler(self, handler_dict): """ - Adds a my_chat_member handler + Adds a my_chat_member handler. + Note that you should use register_my_chat_member_handler to add my_chat_member_handler. + :param handler_dict: :return: """ @@ -1210,6 +1195,7 @@ class AsyncTeleBot: def register_my_chat_member_handler(self, callback, func=None, pass_bot=False, **kwargs): """ Registers my chat member handler. + :param pass_bot: :param callback: function to be called :param func: @@ -1220,7 +1206,8 @@ class AsyncTeleBot: def chat_member_handler(self, func=None, **kwargs): """ - chat_member handler + chat_member handler. + :param func: :param kwargs: :return: @@ -1235,7 +1222,9 @@ class AsyncTeleBot: def add_chat_member_handler(self, handler_dict): """ - Adds a chat_member handler + Adds a chat_member handler. + Note that you should use register_chat_member_handler to add chat_member_handler. + :param handler_dict: :return: """ @@ -1244,6 +1233,7 @@ class AsyncTeleBot: def register_chat_member_handler(self, callback, func=None, pass_bot=False, **kwargs): """ Registers chat member handler. + :param pass_bot: :param callback: function to be called :param func: @@ -1254,7 +1244,8 @@ class AsyncTeleBot: def chat_join_request_handler(self, func=None, **kwargs): """ - chat_join_request handler + chat_join_request handler. + :param func: :param kwargs: :return: @@ -1269,7 +1260,9 @@ class AsyncTeleBot: def add_chat_join_request_handler(self, handler_dict): """ - Adds a chat_join_request handler + Adds a chat_join_request handler. + Note that you should use register_chat_join_request_handler to add chat_join_request_handler. + :param handler_dict: :return: """ @@ -1278,6 +1271,7 @@ class AsyncTeleBot: def register_chat_join_request_handler(self, callback, func=None, pass_bot=False, **kwargs): """ Registers chat join request handler. + :param pass_bot: :param callback: function to be called :param func: @@ -1289,7 +1283,8 @@ class AsyncTeleBot: @staticmethod def _build_handler_dict(handler, pass_bot=False, **filters): """ - Builds a dictionary for a handler + Builds a dictionary for a handler. + :param handler: :param filters: :return: @@ -1303,6 +1298,10 @@ class AsyncTeleBot: } async def skip_updates(self): + """ + Skip existing updates. + Only last update will remain on server. + """ await self.get_updates(-1) return True @@ -1311,6 +1310,8 @@ class AsyncTeleBot: async def get_me(self) -> types.User: """ Returns basic information about the bot in form of a User object. + + Telegram documentation: https://core.telegram.org/bots/api#getme """ result = await asyncio_helper.get_me(self.token) return types.User.de_json(result) @@ -1322,10 +1323,15 @@ class AsyncTeleBot: 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. + + Telegram documentation: https://core.telegram.org/bots/api#getfile + + :param file_id: """ return types.File.de_json(await asyncio_helper.get_file(self.token, file_id)) async def get_file_url(self, file_id: str) -> str: + return await asyncio_helper.get_file_url(self.token, file_id) async def download_file(self, file_path: str) -> bytes: @@ -1339,6 +1345,8 @@ class AsyncTeleBot: After a successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 minutes. Returns True on success. + + Telegram documentation: https://core.telegram.org/bots/api#logout """ return await asyncio_helper.log_out(self.token) @@ -1349,6 +1357,8 @@ class AsyncTeleBot: after server restart. The method will return error 429 in the first 10 minutes after the bot is launched. Returns True on success. + + Telegram documentation: https://core.telegram.org/bots/api#close """ return await asyncio_helper.close(self.token) @@ -1370,6 +1380,8 @@ class AsyncTeleBot: In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success. + Telegram documentation: https://core.telegram.org/bots/api#setwebhook + :param url: HTTPS url to send updates to. Use an empty string to remove webhook integration :param certificate: Upload your public key certificate so that the root certificate in use can be checked. See our self-signed guide for details. @@ -1396,6 +1408,8 @@ class AsyncTeleBot: """ Use this method to remove webhook integration if you decide to switch back to getUpdates. + Telegram documentation: https://core.telegram.org/bots/api#deletewebhook + :param drop_pending_updates: Pass True to drop all pending updates :param timeout: Integer. Request connection timeout :return: bool @@ -1413,6 +1427,8 @@ class AsyncTeleBot: Use this method to get current webhook status. Requires no parameters. If the bot is using getUpdates, will return an object with the url field empty. + Telegram documentation: https://core.telegram.org/bots/api#getwebhookinfo + :param timeout: Integer. Request connection timeout :return: On success, returns a WebhookInfo object. """ @@ -1423,7 +1439,9 @@ class AsyncTeleBot: limit: Optional[int]=None) -> types.UserProfilePhotos: """ Retrieves the user profile photos of the person with 'user_id' - See https://core.telegram.org/bots/api#getuserprofilephotos + + Telegram documentation: https://core.telegram.org/bots/api#getuserprofilephotos + :param user_id: :param offset: :param limit: @@ -1436,6 +1454,9 @@ class AsyncTeleBot: """ Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success. + + Telegram documentation: https://core.telegram.org/bots/api#getchat + :param chat_id: :return: """ @@ -1445,6 +1466,9 @@ class AsyncTeleBot: async def leave_chat(self, chat_id: Union[int, str]) -> bool: """ Use this method for your bot to leave a group, supergroup or channel. Returns True on success. + + Telegram documentation: https://core.telegram.org/bots/api#leavechat + :param chat_id: :return: """ @@ -1456,6 +1480,9 @@ class AsyncTeleBot: Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. + + Telegram documentation: https://core.telegram.org/bots/api#getchatadministrators + :param chat_id: Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) :return: @@ -1474,6 +1501,9 @@ class AsyncTeleBot: async def get_chat_member_count(self, chat_id: Union[int, str]) -> int: """ Use this method to get the number of members in a chat. Returns Int on success. + + Telegram documentation: https://core.telegram.org/bots/api#getchatmemberscount + :param chat_id: :return: """ @@ -1486,6 +1516,9 @@ class AsyncTeleBot: in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success. + + Telegram documentation: https://core.telegram.org/bots/api#setchatstickerset + :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) :param sticker_set_name: Name of the sticker set to be set as the group sticker set @@ -1499,9 +1532,12 @@ class AsyncTeleBot: Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success. + + Telegram documentation: https://core.telegram.org/bots/api#deletechatstickerset + :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) - :return: + :return: API reply. """ result = await asyncio_helper.delete_chat_sticker_set(self.token, chat_id) return result @@ -1509,9 +1545,12 @@ class AsyncTeleBot: async def get_chat_member(self, chat_id: Union[int, str], user_id: int) -> types.ChatMember: """ Use this method to get information about a member of a chat. Returns a ChatMember object on success. + + Telegram documentation: https://core.telegram.org/bots/api#getchatmember + :param chat_id: :param user_id: - :return: + :return: API reply. """ result = await asyncio_helper.get_chat_member(self.token, chat_id, user_id) return types.ChatMember.de_json(result) @@ -1536,6 +1575,8 @@ class AsyncTeleBot: If you must send more than 4000 characters, use the `split_string` or `smart_split` function in util.py. + Telegram documentation: https://core.telegram.org/bots/api#sendmessage + :param chat_id: :param text: :param disable_web_page_preview: @@ -1564,6 +1605,9 @@ class AsyncTeleBot: timeout: Optional[int]=None) -> types.Message: """ Use this method to forward messages of any kind. + + Telegram documentation: https://core.telegram.org/bots/api#forwardmessage + :param disable_notification: :param chat_id: which chat to forward :param from_chat_id: which chat message from @@ -1590,6 +1634,9 @@ class AsyncTeleBot: timeout: Optional[int]=None) -> int: """ Use this method to copy messages of any kind. + + Telegram documentation: https://core.telegram.org/bots/api#copymessage + :param chat_id: which chat to forward :param from_chat_id: which chat message from :param message_id: message id @@ -1613,6 +1660,9 @@ class AsyncTeleBot: timeout: Optional[int]=None) -> bool: """ Use this method to delete message. Returns True on success. + + Telegram documentation: https://core.telegram.org/bots/api#deletemessage + :param chat_id: in which chat to delete :param message_id: which message to delete :param timeout: @@ -1630,6 +1680,9 @@ class AsyncTeleBot: protect_content: Optional[bool]=None) -> types.Message: """ Use this method to send dices. + + Telegram documentation: https://core.telegram.org/bots/api#senddice + :param chat_id: :param emoji: :param disable_notification: @@ -1658,6 +1711,9 @@ class AsyncTeleBot: timeout: Optional[int]=None,) -> types.Message: """ Use this method to send photos. + + Telegram documentation: https://core.telegram.org/bots/api#sendphoto + :param chat_id: :param photo: :param caption: @@ -1695,13 +1751,16 @@ class AsyncTeleBot: """ Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format. - :param chat_id:Unique identifier for the message recipient - :param audio:Audio file to send. + + Telegram documentation: https://core.telegram.org/bots/api#sendaudio + + :param chat_id: Unique identifier for the message recipient + :param audio: Audio file to send. :param caption: - :param duration:Duration of the audio in seconds - :param performer:Performer + :param duration: Duration of the audio in seconds + :param performer: Performer :param title:Track name - :param reply_to_message_id:If the message is a reply, ID of the original message + :param reply_to_message_id: If the message is a reply, ID of the original message :param reply_markup: :param parse_mode :param disable_notification: @@ -1734,10 +1793,13 @@ class AsyncTeleBot: """ Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. - :param chat_id:Unique identifier for the message recipient. + + Telegram documentation: https://core.telegram.org/bots/api#sendvoice + + :param chat_id: Unique identifier for the message recipient. :param voice: :param caption: - :param duration:Duration of sent audio in seconds + :param duration: Duration of sent audio in seconds :param reply_to_message_id: :param reply_markup: :param parse_mode @@ -1773,6 +1835,9 @@ class AsyncTeleBot: protect_content: Optional[bool]=None) -> types.Message: """ Use this method to send general files. + + Telegram documentation: https://core.telegram.org/bots/api#senddocument + :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :param document: (document) File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data :param reply_to_message_id: If the message is a reply, ID of the original message @@ -1814,6 +1879,9 @@ class AsyncTeleBot: data: Union[Any, str]=None) -> types.Message: """ Use this method to send .webp stickers. + + Telegram documentation: https://core.telegram.org/bots/api#sendsticker + :param chat_id: :param sticker: :param reply_to_message_id: @@ -1854,6 +1922,9 @@ class AsyncTeleBot: data: Optional[Union[Any, str]]=None) -> types.Message: """ Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). + + Telegram documentation: https://core.telegram.org/bots/api#sendvideo + :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :param video: Video to send. You can either pass a file_id as String to resend a video that is already on the Telegram servers, or upload a new video file using multipart/form-data. :param duration: Duration of sent video in seconds @@ -1900,6 +1971,9 @@ class AsyncTeleBot: timeout: Optional[int]=None, ) -> types.Message: """ Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). + + Telegram documentation: https://core.telegram.org/bots/api#sendanimation + :param chat_id: Integer : Unique identifier for the message recipient — User or GroupChat id :param animation: InputFile or String : Animation to send. You can either pass a file_id as String to resend an animation that is already on the Telegram server @@ -1940,6 +2014,9 @@ class AsyncTeleBot: """ As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages. + + Telegram documentation: https://core.telegram.org/bots/api#sendvideonote + :param chat_id: Integer : Unique identifier for the message recipient — User or GroupChat id :param data: InputFile or String : Video note to send. You can either pass a file_id as String to resend a video that is already on the Telegram server @@ -1971,6 +2048,9 @@ class AsyncTeleBot: allow_sending_without_reply: Optional[bool]=None) -> List[types.Message]: """ send a group of photos or videos as an album. On success, an array of the sent Messages is returned. + + Telegram documentation: https://core.telegram.org/bots/api#sendmediagroup + :param chat_id: :param media: :param disable_notification: @@ -2002,6 +2082,9 @@ class AsyncTeleBot: """ Use this method to send point on the map. + + Telegram documentation: https://core.telegram.org/bots/api#sendlocation + :param chat_id: :param latitude: :param longitude: @@ -2035,7 +2118,10 @@ class AsyncTeleBot: heading: Optional[int]=None, proximity_alert_radius: Optional[int]=None) -> types.Message: """ - Use this method to edit live location + Use this method to edit live location. + + Telegram documentation: https://core.telegram.org/bots/api#editmessagelivelocation + :param latitude: :param longitude: :param chat_id: @@ -2062,7 +2148,10 @@ class AsyncTeleBot: timeout: Optional[int]=None) -> types.Message: """ Use this method to stop updating a live location message sent by the bot - or via the bot (for inline bots) before live_period expires + or via the bot (for inline bots) before live_period expires. + + Telegram documentation: https://core.telegram.org/bots/api#stopmessagelivelocation + :param chat_id: :param message_id: :param inline_message_id: @@ -2090,6 +2179,9 @@ class AsyncTeleBot: protect_content: Optional[bool]=None) -> types.Message: """ Use this method to send information about a venue. + + Telegram documentation: https://core.telegram.org/bots/api#sendvenue + :param chat_id: Integer or String : Unique identifier for the target chat or username of the target channel :param latitude: Float : Latitude of the venue :param longitude: Float : Longitude of the venue @@ -2127,6 +2219,9 @@ class AsyncTeleBot: protect_content: Optional[bool]=None) -> types.Message: """ Use this method to send phone contacts. + + Telegram documentation: https://core.telegram.org/bots/api#sendcontact + :param chat_id: Integer or String : Unique identifier for the target chat or username of the target channel :param phone_number: String : Contact's phone number :param first_name: String : Contact's first name @@ -2152,6 +2247,9 @@ class AsyncTeleBot: Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). + + Telegram documentation: https://core.telegram.org/bots/api#sendchataction + :param chat_id: :param action: One of the following strings: 'typing', 'upload_photo', 'record_video', 'upload_video', 'record_audio', 'upload_audio', 'upload_document', 'find_location', 'record_video_note', @@ -2180,6 +2278,9 @@ class AsyncTeleBot: In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. Returns True on success. + + Telegram documentation: https://core.telegram.org/bots/api#banchatmember + :param chat_id: Int or string : Unique identifier for the target group or username of the target supergroup :param user_id: Int : Unique identifier of the target user :param until_date: Date when the user will be unbanned, unix time. If user is banned for more than 366 days or @@ -2201,6 +2302,8 @@ class AsyncTeleBot: the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned. + Telegram documentation: https://core.telegram.org/bots/api#unbanchatmember + :param chat_id: Unique identifier for the target group or username of the target supergroup or channel (in the format @username) :param user_id: Unique identifier of the target user @@ -2225,6 +2328,8 @@ class AsyncTeleBot: The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user. + Telegram documentation: https://core.telegram.org/bots/api#restrictchatmember + :param chat_id: Int or String : Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername) :param user_id: Int : Unique identifier of the target user @@ -2271,6 +2376,8 @@ class AsyncTeleBot: in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user. + Telegram documentation: https://core.telegram.org/bots/api#promotechatmember + :param chat_id: Unique identifier for the target chat or username of the target channel ( in the format @channelusername) :param user_id: Int : Unique identifier of the target user @@ -2305,6 +2412,8 @@ class AsyncTeleBot: Use this method to set a custom title for an administrator in a supergroup promoted by the bot. + Telegram documentation: https://core.telegram.org/bots/api#setchatadministratorcustomtitle + :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) :param user_id: Unique identifier of the target user @@ -2324,7 +2433,8 @@ class AsyncTeleBot: for this to work and must have the appropriate administrator rights. Returns True on success. - :params: + Telegram documentation: https://core.telegram.org/bots/api#banchatsenderchat + :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :param sender_chat_id: Unique identifier of the target sender chat :return: True on success. @@ -2338,6 +2448,8 @@ class AsyncTeleBot: administrator rights. Returns True on success. + Telegram documentation: https://core.telegram.org/bots/api#unbanchatsenderchat + :params: :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :param sender_chat_id: Unique identifier of the target sender chat @@ -2352,6 +2464,8 @@ class AsyncTeleBot: The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members admin rights. + Telegram documentation: https://core.telegram.org/bots/api#setchatpermissions + :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) :param permissions: New async default chat permissions @@ -2369,6 +2483,8 @@ class AsyncTeleBot: Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. + Telegram documentation: https://core.telegram.org/bots/api#createchatinvitelink + :param chat_id: Id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :param name: Invite link name; 0-32 characters @@ -2392,6 +2508,8 @@ class AsyncTeleBot: Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. + Telegram documentation: https://core.telegram.org/bots/api#editchatinvitelink + :param chat_id: Id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :param name: Invite link name; 0-32 characters @@ -2412,6 +2530,8 @@ class AsyncTeleBot: Note: If the primary link is revoked, a new link is automatically generated The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. + Telegram documentation: https://core.telegram.org/bots/api#revokechatinvitelink + :param chat_id: Id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :param invite_link: The invite link to revoke @@ -2426,6 +2546,8 @@ class AsyncTeleBot: Use this method to export an invite link to a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. + Telegram documentation: https://core.telegram.org/bots/api#exportchatinvitelink + :param chat_id: Id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :return: exported invite link as String on success. @@ -2439,6 +2561,8 @@ class AsyncTeleBot: The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success. + Telegram documentation: https://core.telegram.org/bots/api#approvechatjoinrequest + :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) :param user_id: Unique identifier of the target user @@ -2452,6 +2576,8 @@ class AsyncTeleBot: The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success. + Telegram documentation: https://core.telegram.org/bots/api#declinechatjoinrequest + :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) :param user_id: Unique identifier of the target user @@ -2466,6 +2592,9 @@ class AsyncTeleBot: Returns True on success. Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group. + + Telegram documentation: https://core.telegram.org/bots/api#setchatphoto + :param chat_id: Int or Str: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :param photo: InputFile: New chat photo, uploaded using multipart/form-data @@ -2480,6 +2609,9 @@ class AsyncTeleBot: Returns True on success. Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group. + + Telegram documentation: https://core.telegram.org/bots/api#deletechatphoto + :param chat_id: Int or Str: Unique identifier for the target chat or username of the target channel (in the format @channelusername) """ @@ -2490,6 +2622,9 @@ class AsyncTeleBot: """ Use this method to get the current list of the bot's commands. Returns List of BotCommand on success. + + Telegram documentation: https://core.telegram.org/bots/api#getmycommands + :param scope: The scope of users for which the commands are relevant. async defaults to BotCommandScopeasync default. :param language_code: A two-letter ISO 639-1 language code. If empty, @@ -2504,6 +2639,9 @@ class AsyncTeleBot: language_code: Optional[str]=None) -> bool: """ Use this method to change the list of the bot's commands. + + Telegram documentation: https://core.telegram.org/bots/api#setmycommands + :param commands: List of BotCommand. At most 100 commands can be specified. :param scope: The scope of users for which the commands are relevant. async defaults to BotCommandScopeasync default. @@ -2520,6 +2658,9 @@ class AsyncTeleBot: Use this method to delete the list of the bot's commands for the given scope and user language. After deletion, higher level commands will be shown to affected users. Returns True on success. + + Telegram documentation: https://core.telegram.org/bots/api#deletemycommands + :param scope: The scope of users for which the commands are relevant. async defaults to BotCommandScopeasync default. :param language_code: A two-letter ISO 639-1 language code. If empty, @@ -2535,6 +2676,9 @@ class AsyncTeleBot: Returns True on success. Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group. + + Telegram documentation: https://core.telegram.org/bots/api#setchattitle + :param chat_id: Int or Str: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :param title: New chat title, 1-255 characters @@ -2547,6 +2691,8 @@ class AsyncTeleBot: Use this method to change the description of a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. + Telegram documentation: https://core.telegram.org/bots/api#setchatdescription + :param chat_id: Int or Str: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :param description: Str: New chat description, 0-255 characters @@ -2561,6 +2707,9 @@ class AsyncTeleBot: Use this method to pin a message in a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. + + Telegram documentation: https://core.telegram.org/bots/api#pinchatmessage + :param chat_id: Int or Str: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :param message_id: Int: Identifier of a message to pin @@ -2575,6 +2724,9 @@ class AsyncTeleBot: Use this method to unpin specific pinned message in a supergroup chat. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. + + Telegram documentation: https://core.telegram.org/bots/api#unpinchatmessage + :param chat_id: Int or Str: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :param message_id: Int: Identifier of a message to unpin @@ -2587,6 +2739,9 @@ class AsyncTeleBot: Use this method to unpin a all pinned messages in a supergroup chat. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. + + Telegram documentation: https://core.telegram.org/bots/api#unpinallchatmessages + :param chat_id: Int or Str: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :return: @@ -2604,6 +2759,9 @@ class AsyncTeleBot: reply_markup: Optional[REPLY_MARKUP_TYPES]=None) -> Union[types.Message, bool]: """ Use this method to edit text and game messages. + + Telegram documentation: https://core.telegram.org/bots/api#editmessagetext + :param text: :param chat_id: :param message_id: @@ -2632,6 +2790,9 @@ class AsyncTeleBot: If a message is a part of a message album, then it can be edited only to a photo or a video. Otherwise, message type can be changed arbitrarily. When inline message is edited, new file can't be uploaded. Use previously uploaded file via its file_id or specify a URL. + + Telegram documentation: https://core.telegram.org/bots/api#editmessagemedia + :param media: :param chat_id: :param message_id: @@ -2651,6 +2812,9 @@ class AsyncTeleBot: reply_markup: Optional[REPLY_MARKUP_TYPES]=None) -> Union[types.Message, bool]: """ Use this method to edit only the reply markup of messages. + + Telegram documentation: https://core.telegram.org/bots/api#editmessagereplymarkup + :param chat_id: :param message_id: :param inline_message_id: @@ -2671,7 +2835,10 @@ class AsyncTeleBot: allow_sending_without_reply: Optional[bool]=None, protect_content: Optional[bool]=None) -> types.Message: """ - Used to send the game + Used to send the game. + + Telegram documentation: https://core.telegram.org/bots/api#sendgame + :param chat_id: :param game_short_name: :param disable_notification: @@ -2696,7 +2863,10 @@ class AsyncTeleBot: inline_message_id: Optional[str]=None, disable_edit_message: Optional[bool]=None) -> Union[types.Message, bool]: """ - Sets the value of points in the game to a specific user + Sets the value of points in the game to a specific user. + + Telegram documentation: https://core.telegram.org/bots/api#setgamescore + :param user_id: :param score: :param force: @@ -2717,7 +2887,10 @@ class AsyncTeleBot: message_id: Optional[int]=None, inline_message_id: Optional[str]=None) -> List[types.GameHighScore]: """ - Gets top points and game play + Gets top points and game play. + + Telegram documentation: https://core.telegram.org/bots/api#getgamehighscores + :param user_id: :param chat_id: :param message_id: @@ -2748,7 +2921,10 @@ class AsyncTeleBot: suggested_tip_amounts: Optional[List[int]]=None, protect_content: Optional[bool]=None) -> types.Message: """ - Sends invoice + Sends invoice. + + Telegram documentation: https://core.telegram.org/bots/api#sendinvoice + :param chat_id: Unique identifier for the target private chat :param title: Product name :param description: Product description @@ -2816,7 +2992,10 @@ class AsyncTeleBot: explanation_entities: Optional[List[types.MessageEntity]]=None, protect_content: Optional[bool]=None) -> types.Message: """ - Send polls + Send polls. + + Telegram documentation: https://core.telegram.org/bots/api#sendpoll + :param chat_id: :param question: :param options: array of str with answers @@ -2855,7 +3034,10 @@ class AsyncTeleBot: self, chat_id: Union[int, str], message_id: int, reply_markup: Optional[REPLY_MARKUP_TYPES]=None) -> types.Poll: """ - Stops poll + Stops poll. + + Telegram documentation: https://core.telegram.org/bots/api#stoppoll + :param chat_id: :param message_id: :param reply_markup: @@ -2868,7 +3050,10 @@ class AsyncTeleBot: shipping_options: Optional[List[types.ShippingOption]]=None, error_message: Optional[str]=None) -> bool: """ - Asks for an answer to a shipping question + Asks for an answer to a shipping question. + + Telegram documentation: https://core.telegram.org/bots/api#answershippingquery + :param shipping_query_id: :param ok: :param shipping_options: @@ -2881,7 +3066,10 @@ class AsyncTeleBot: self, pre_checkout_query_id: int, ok: bool, error_message: Optional[str]=None) -> bool: """ - Response to a request for pre-inspection + Response to a request for pre-inspection. + + Telegram documentation: https://core.telegram.org/bots/api#answerprecheckoutquery + :param pre_checkout_query_id: :param ok: :param error_message: @@ -2897,7 +3085,10 @@ class AsyncTeleBot: caption_entities: Optional[List[types.MessageEntity]]=None, reply_markup: Optional[REPLY_MARKUP_TYPES]=None) -> Union[types.Message, bool]: """ - Use this method to edit captions of messages + Use this method to edit captions of messages. + + Telegram documentation: https://core.telegram.org/bots/api#editmessagecaption + :param caption: :param chat_id: :param message_id: @@ -2918,6 +3109,7 @@ class AsyncTeleBot: async def reply_to(self, message: types.Message, text: str, **kwargs) -> types.Message: """ Convenience function for `send_message(message.chat.id, text, reply_to_message_id=message.message_id, **kwargs)` + :param message: :param text: :param kwargs: @@ -2936,6 +3128,9 @@ class AsyncTeleBot: """ Use this method to send answers to an inline query. On success, True is returned. No more than 50 results per query are allowed. + + Telegram documentation: https://core.telegram.org/bots/api#answerinlinequery + :param inline_query_id: Unique identifier for the answered query :param results: Array of results for the inline query :param cache_time: The maximum amount of time in seconds that the result of the inline query @@ -2959,6 +3154,9 @@ class AsyncTeleBot: """ Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. + + Telegram documentation: https://core.telegram.org/bots/api#answercallbackquery + :param callback_query_id: :param text: :param show_alert: @@ -2973,12 +3171,24 @@ class AsyncTeleBot: """ Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only. Returns True on success. + + Telegram documentation: https://core.telegram.org/bots/api#setstickersetthumb + + :param name: Sticker set name + :param user_id: User identifier + :param thumb: A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height + exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; + see https://core.telegram.org/animated_stickers#technical-requirements + """ return await asyncio_helper.set_sticker_set_thumb(self.token, name, user_id, thumb) async def get_sticker_set(self, name: str) -> types.StickerSet: """ Use this method to get a sticker set. On success, a StickerSet object is returned. + + Telegram documentation: https://core.telegram.org/bots/api#getstickerset + :param name: :return: """ @@ -2989,6 +3199,10 @@ class AsyncTeleBot: """ Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success. + + + Telegram documentation: https://core.telegram.org/bots/api#uploadstickerfile + :param user_id: :param png_sticker: :return: @@ -3008,6 +3222,9 @@ class AsyncTeleBot: Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. Returns True on success. + + Telegram documentation: https://core.telegram.org/bots/api#createnewstickerset + :param user_id: :param name: :param title: @@ -3034,6 +3251,9 @@ class AsyncTeleBot: Use this method to add a new sticker to a set created by the bot. It's required to pass `png_sticker` or `tgs_sticker`. Returns True on success. + + Telegram documentation: https://core.telegram.org/bots/api#addstickertoset + :param user_id: :param name: :param emojis: @@ -3050,6 +3270,9 @@ class AsyncTeleBot: async def set_sticker_position_in_set(self, sticker: str, position: int) -> bool: """ Use this method to move a sticker in a set created by the bot to a specific position . Returns True on success. + + Telegram documentation: https://core.telegram.org/bots/api#setstickerpositioninset + :param sticker: :param position: :return: @@ -3059,6 +3282,9 @@ class AsyncTeleBot: async def delete_sticker_from_set(self, sticker: str) -> bool: """ Use this method to delete a sticker from a set created by the bot. Returns True on success. + + Telegram documentation: https://core.telegram.org/bots/api#deletestickerfromset + :param sticker: :return: """ @@ -3068,6 +3294,7 @@ class AsyncTeleBot: async def set_state(self, user_id: int, state: str, chat_id: int=None): """ Sets a new state of a user. + :param user_id: :param chat_id: :param state: new state. can be string or integer. @@ -3079,6 +3306,7 @@ class AsyncTeleBot: async def reset_data(self, user_id: int, chat_id: int=None): """ Reset data for a user in chat. + :param user_id: :param chat_id: """ @@ -3089,6 +3317,7 @@ class AsyncTeleBot: async def delete_state(self, user_id: int, chat_id:int=None): """ Delete the current state of a user. + :param user_id: :param chat_id: :return: @@ -3105,6 +3334,7 @@ class AsyncTeleBot: async def get_state(self, user_id, chat_id: int=None): """ Get current state of a user. + :param user_id: :param chat_id: :return: state of a user @@ -3116,6 +3346,7 @@ class AsyncTeleBot: async def add_data(self, user_id: int, chat_id: int=None, **kwargs): """ Add data to states. + :param user_id: :param chat_id: """ diff --git a/telebot/asyncio_handler_backends.py b/telebot/asyncio_handler_backends.py index c6db03b..17e28d0 100644 --- a/telebot/asyncio_handler_backends.py +++ b/telebot/asyncio_handler_backends.py @@ -28,4 +28,29 @@ class StatesGroup: for name, value in cls.__dict__.items(): if not name.startswith('__') and not callable(value) and isinstance(value, State): # change value of that variable - value.name = ':'.join((cls.__name__, name)) \ No newline at end of file + value.name = ':'.join((cls.__name__, name)) + + +class SkipHandler: + """ + Class for skipping handlers. + Just return instance of this class + in middleware to skip handler. + Update will go to post_process, + but will skip execution of handler. + """ + + def __init__(self) -> None: + pass + +class CancelUpdate: + """ + Class for canceling updates. + Just return instance of this class + in middleware to skip update. + Update will skip handler and execution + of post_process in middlewares. + """ + + def __init__(self) -> None: + pass \ No newline at end of file