1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Update docstrings to correct documentation.

This commit is contained in:
coder2020official 2022-03-06 19:41:54 +05:00
parent 388477686b
commit 441a5793cc

View File

@ -389,6 +389,7 @@ class TeleBot:
long_polling_timeout: int=20) -> List[types.Update]:
"""
Use this method to receive incoming updates using long polling (wiki). An Array of Update objects is returned.
:param allowed_updates: Array of string. List the types of updates you want your bot to receive.
:param offset: Integer. Identifier of the first update to be returned.
:param limit: Integer. Limits the number of updates to be retrieved.
@ -402,6 +403,7 @@ class TeleBot:
def __skip_updates(self):
"""
Get and discard all pending updates before first poll of the bot
:return:
"""
self.get_updates(offset=-1)
@ -410,6 +412,7 @@ class TeleBot:
"""
Retrieves any updates from the Telegram API.
Registered listeners and applicable message handlers will be notified when a new message arrives.
:raises ApiException when a call has failed.
"""
if self.skip_pending:
@ -422,6 +425,11 @@ class TeleBot:
self.process_new_updates(updates)
def process_new_updates(self, updates):
"""
Processes new updates. Just pass list of subclasses of Update to this method.
:param updates: List of Update objects
"""
upd_count = len(updates)
logger.debug('Received {0} new updates'.format(upd_count))
if upd_count == 0: return
@ -645,6 +653,7 @@ class TeleBot:
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
@ -829,10 +838,17 @@ class TeleBot:
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.
:param file_id: File identifier
"""
return types.File.de_json(apihelper.get_file(self.token, file_id))
def get_file_url(self, file_id: str) -> str:
"""
Get a valid URL for downloading a file.
:param file_id: File identifier to get download URL for.
"""
return apihelper.get_file_url(self.token, file_id)
def download_file(self, file_path: str) -> bytes:
@ -864,7 +880,8 @@ class TeleBot:
"""
Retrieves the user profile photos of the person with 'user_id'
See https://core.telegram.org/bots/api#getuserprofilephotos
:param user_id:
:param user_id: Integer - Unique identifier of the target user
:param offset:
:param limit:
:return: API reply.
@ -876,6 +893,7 @@ class TeleBot:
"""
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.
:param chat_id:
:return:
"""
@ -885,6 +903,7 @@ class TeleBot:
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.
:param chat_id:
:return:
"""
@ -896,6 +915,7 @@ class TeleBot:
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.
:param chat_id: Unique identifier for the target chat or username
of the target supergroup or channel (in the format @channelusername)
:return:
@ -914,6 +934,7 @@ class TeleBot:
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.
:param chat_id:
:return:
"""
@ -926,6 +947,7 @@ class TeleBot:
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.
: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
@ -939,6 +961,7 @@ class TeleBot:
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.
:param chat_id: Unique identifier for the target chat or username of the target supergroup
(in the format @supergroupusername)
:return:
@ -949,6 +972,7 @@ class TeleBot:
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.
:param chat_id:
:param user_id:
:return:
@ -1002,6 +1026,7 @@ class TeleBot:
timeout: Optional[int]=None) -> types.Message:
"""
Use this method to forward messages of any kind.
:param disable_notification:
:param chat_id: which chat to forward
:param from_chat_id: which chat message from
@ -1028,6 +1053,7 @@ class TeleBot:
timeout: Optional[int]=None) -> int:
"""
Use this method to copy messages of any kind.
:param chat_id: which chat to forward
:param from_chat_id: which chat message from
:param message_id: message id
@ -1051,6 +1077,7 @@ class TeleBot:
timeout: Optional[int]=None) -> bool:
"""
Use this method to delete message. Returns True on success.
:param chat_id: in which chat to delete
:param message_id: which message to delete
:param timeout:
@ -1068,6 +1095,7 @@ class TeleBot:
protect_content: Optional[bool]=None) -> types.Message:
"""
Use this method to send dices.
:param chat_id:
:param emoji:
:param disable_notification:
@ -1096,6 +1124,7 @@ class TeleBot:
timeout: Optional[int]=None,) -> types.Message:
"""
Use this method to send photos. On success, the sent Message is returned.
:param chat_id:
:param photo:
:param caption:
@ -1134,6 +1163,7 @@ class TeleBot:
"""
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.
:param caption:
@ -1174,6 +1204,7 @@ class TeleBot:
"""
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.
:param voice:
:param caption:
@ -1214,6 +1245,7 @@ class TeleBot:
protect_content: Optional[bool]=None) -> types.Message:
"""
Use this method to send general files.
: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
@ -1258,6 +1290,7 @@ class TeleBot:
data: Union[Any, str]=None) -> types.Message:
"""
Use this method to send .webp stickers.
:param chat_id:
:param sticker:
:param data:
@ -1300,6 +1333,7 @@ class TeleBot:
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).
: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
@ -1346,6 +1380,7 @@ class TeleBot:
timeout: Optional[int]=None, ) -> types.Message:
"""
Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound).
: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
@ -1387,6 +1422,7 @@ class TeleBot:
"""
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.
: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
@ -1417,7 +1453,8 @@ class TeleBot:
timeout: Optional[int]=None,
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.
Send a group of photos or videos as an album. On success, an array of the sent Messages is returned.
:param chat_id:
:param media:
:param disable_notification:
@ -1448,6 +1485,7 @@ class TeleBot:
protect_content: Optional[bool]=None) -> types.Message:
"""
Use this method to send point on the map.
:param chat_id:
:param latitude:
:param longitude:
@ -1481,7 +1519,8 @@ class TeleBot:
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.
:param latitude:
:param longitude:
:param chat_id:
@ -1509,6 +1548,7 @@ class TeleBot:
"""
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
:param chat_id:
:param message_id:
:param inline_message_id:
@ -1537,6 +1577,7 @@ class TeleBot:
protect_content: Optional[bool]=None) -> types.Message:
"""
Use this method to send information about a venue.
: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
@ -1584,6 +1625,7 @@ class TeleBot:
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).
: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',
@ -1612,6 +1654,7 @@ class TeleBot:
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.
: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
@ -1657,7 +1700,7 @@ class TeleBot:
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.
:param chat_id: Int or String : Unique identifier for the target group or username of the target supergroup
: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
:param until_date: Date when restrictions will be lifted for the user, unix time.
@ -1755,7 +1798,6 @@ class TeleBot:
for this to work and must have the appropriate administrator rights.
Returns True on success.
: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
:return: True on success.
@ -1896,6 +1938,7 @@ class TeleBot:
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.
: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
@ -1910,6 +1953,7 @@ class TeleBot:
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.
:param chat_id: Int or Str: Unique identifier for the target chat or username of the target channel
(in the format @channelusername)
"""
@ -1920,6 +1964,7 @@ class TeleBot:
"""
Use this method to get the current list of the bot's commands.
Returns List of BotCommand on success.
:param scope: The scope of users for which the commands are relevant.
Defaults to BotCommandScopeDefault.
:param language_code: A two-letter ISO 639-1 language code. If empty,
@ -1934,6 +1979,7 @@ class TeleBot:
language_code: Optional[str]=None) -> bool:
"""
Use this method to change the list of the bot's commands.
:param commands: List of BotCommand. At most 100 commands can be specified.
:param scope: The scope of users for which the commands are relevant.
Defaults to BotCommandScopeDefault.
@ -1950,6 +1996,7 @@ class TeleBot:
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.
:param scope: The scope of users for which the commands are relevant.
Defaults to BotCommandScopeDefault.
:param language_code: A two-letter ISO 639-1 language code. If empty,
@ -1965,6 +2012,7 @@ class TeleBot:
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.
: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
@ -1991,6 +2039,7 @@ class TeleBot:
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.
: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
@ -2005,6 +2054,7 @@ class TeleBot:
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.
: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
@ -2017,6 +2067,7 @@ class TeleBot:
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.
:param chat_id: Int or Str: Unique identifier for the target chat or username of the target channel
(in the format @channelusername)
:return:
@ -2034,6 +2085,7 @@ class TeleBot:
reply_markup: Optional[REPLY_MARKUP_TYPES]=None) -> Union[types.Message, bool]:
"""
Use this method to edit text and game messages.
:param text:
:param chat_id:
:param message_id:
@ -2062,6 +2114,7 @@ class TeleBot:
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.
:param media:
:param chat_id:
:param message_id:
@ -2081,6 +2134,7 @@ class TeleBot:
reply_markup: Optional[REPLY_MARKUP_TYPES]=None) -> Union[types.Message, bool]:
"""
Use this method to edit only the reply markup of messages.
:param chat_id:
:param message_id:
:param inline_message_id:
@ -2102,6 +2156,7 @@ class TeleBot:
protect_content: Optional[bool]=None) -> types.Message:
"""
Used to send the game
:param chat_id:
:param game_short_name:
:param disable_notification:
@ -2126,7 +2181,8 @@ class TeleBot:
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.
:param user_id:
:param score:
:param force:
@ -2148,6 +2204,7 @@ class TeleBot:
inline_message_id: Optional[str]=None) -> List[types.GameHighScore]:
"""
Gets top points and game play
:param user_id:
:param chat_id:
:param message_id:
@ -2179,7 +2236,8 @@ class TeleBot:
suggested_tip_amounts: Optional[List[int]]=None,
protect_content: Optional[bool]=None) -> types.Message:
"""
Sends invoice
Sends invoice.
:param chat_id: Unique identifier for the target private chat
:param title: Product name
:param description: Product description
@ -2248,7 +2306,8 @@ class TeleBot:
explanation_entities: Optional[List[types.MessageEntity]]=None,
protect_content: Optional[bool]=None) -> types.Message:
"""
Send polls
Sends a poll.
:param chat_id:
:param question:
:param options: array of str with answers
@ -2286,7 +2345,8 @@ class TeleBot:
self, chat_id: Union[int, str], message_id: int,
reply_markup: Optional[REPLY_MARKUP_TYPES]=None) -> types.Poll:
"""
Stops poll
Stops a poll.
:param chat_id:
:param message_id:
:param reply_markup:
@ -2299,7 +2359,8 @@ class TeleBot:
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.
:param shipping_query_id:
:param ok:
:param shipping_options:
@ -2312,7 +2373,8 @@ class TeleBot:
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.
:param pre_checkout_query_id:
:param ok:
:param error_message:
@ -2328,7 +2390,8 @@ class TeleBot:
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.
:param caption:
:param chat_id:
:param message_id:
@ -2349,6 +2412,7 @@ class TeleBot:
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:
@ -2367,6 +2431,7 @@ class TeleBot:
"""
Use this method to send answers to an inline query. On success, True is returned.
No more than 50 results per query are allowed.
: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
@ -2390,6 +2455,7 @@ class TeleBot:
"""
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.
:param callback_query_id:
:param text:
:param show_alert:
@ -2404,12 +2470,17 @@ class TeleBot:
"""
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.
:param name: Sticker set name
:param user_id: User identifier
:param thumb:
"""
return apihelper.set_sticker_set_thumb(self.token, name, user_id, thumb)
def get_sticker_set(self, name: str) -> types.StickerSet:
"""
Use this method to get a sticker set. On success, a StickerSet object is returned.
:param name:
:return:
"""
@ -2420,6 +2491,7 @@ class TeleBot:
"""
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.
:param user_id:
:param png_sticker:
:return:
@ -2439,6 +2511,7 @@ class TeleBot:
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.
:param user_id:
:param name:
:param title:
@ -2464,6 +2537,7 @@ class TeleBot:
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.
:param user_id:
:param name:
:param emojis:
@ -2479,6 +2553,7 @@ class TeleBot:
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.
:param sticker:
:param position:
:return:
@ -2488,6 +2563,7 @@ class TeleBot:
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.
:param sticker:
:return:
"""
@ -2523,6 +2599,7 @@ class TeleBot:
def _notify_reply_handlers(self, new_messages) -> None:
"""
Notify handlers of the answers
:param new_messages:
:return:
"""
@ -2552,6 +2629,7 @@ class TeleBot:
def setup_middleware(self, middleware: BaseMiddleware):
"""
Register middleware
:param middleware: Subclass of `telebot.handler_backends.BaseMiddleware`
:return: None
"""
@ -2565,6 +2643,7 @@ class TeleBot:
def set_state(self, user_id: int, state: Union[int, str], chat_id: int=None) -> None:
"""
Sets a new state of a user.
:param user_id:
:param state: new state. can be string or integer.
:param chat_id:
@ -2576,6 +2655,7 @@ class TeleBot:
def reset_data(self, user_id: int, chat_id: int=None):
"""
Reset data for a user in chat.
:param user_id:
:param chat_id:
"""
@ -2586,6 +2666,7 @@ class TeleBot:
def delete_state(self, user_id: int, chat_id: int=None) -> None:
"""
Delete the current state of a user.
:param user_id:
:param chat_id:
:return:
@ -2602,6 +2683,7 @@ class TeleBot:
def get_state(self, user_id: int, chat_id: int=None) -> Optional[Union[int, str]]:
"""
Get current state of a user.
:param user_id:
:param chat_id:
:return: state of a user
@ -2613,6 +2695,7 @@ class TeleBot:
def add_data(self, user_id: int, chat_id:int=None, **kwargs):
"""
Add data to states.
:param user_id:
:param chat_id:
"""
@ -2672,6 +2755,7 @@ class TeleBot:
def _notify_next_handlers(self, new_messages):
"""
Description: TBD
:param new_messages:
:return:
"""
@ -2690,6 +2774,7 @@ class TeleBot:
def _build_handler_dict(handler, pass_bot=False, **filters):
"""
Builds a dictionary for a handler
:param handler:
:param filters:
:return:
@ -2850,6 +2935,8 @@ class TeleBot:
def add_message_handler(self, handler_dict):
"""
Adds a message handler
Note that you should use register_message_handler to add message_handler to the bot.
:param handler_dict:
:return:
"""
@ -2858,6 +2945,7 @@ class TeleBot:
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
@ -2894,6 +2982,7 @@ class TeleBot:
def edited_message_handler(self, commands=None, regexp=None, func=None, content_types=None, chat_types=None, **kwargs):
"""
Edit message handler decorator
:param commands:
:param regexp:
:param func:
@ -2935,6 +3024,7 @@ class TeleBot:
def add_edited_message_handler(self, handler_dict):
"""
Adds the edit message handler
Note that you should use register_edited_message_handler to add edited_message_handler to the bot.
:param handler_dict:
:return:
"""
@ -2943,6 +3033,7 @@ class TeleBot:
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 callback: function to be called
:param content_types: list of content_types
:param commands: list of commands
@ -2980,6 +3071,7 @@ class TeleBot:
def channel_post_handler(self, commands=None, regexp=None, func=None, content_types=None, **kwargs):
"""
Channel post handler decorator
:param commands:
:param regexp:
:param func:
@ -3019,6 +3111,8 @@ class TeleBot:
def add_channel_post_handler(self, handler_dict):
"""
Adds channel post handler
Note that you should use register_channel_post_handler to add channel_post_handler to the bot.
:param handler_dict:
:return:
"""
@ -3027,6 +3121,7 @@ class TeleBot:
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 callback: function to be called
:param content_types: list of content_types
:param commands: list of commands
@ -3061,6 +3156,7 @@ class TeleBot:
def edited_channel_post_handler(self, commands=None, regexp=None, func=None, content_types=None, **kwargs):
"""
Edit channel post handler decorator
:param commands:
:param regexp:
:param func:
@ -3100,6 +3196,8 @@ class TeleBot:
def add_edited_channel_post_handler(self, handler_dict):
"""
Adds the edit channel post handler
Note that you should use register_edited_channel_post_handler to add edited_channel_post_handler to the bot.
:param handler_dict:
:return:
"""
@ -3142,6 +3240,7 @@ class TeleBot:
def inline_handler(self, func, **kwargs):
"""
Inline call handler decorator
:param func:
:param kwargs:
:return:
@ -3156,6 +3255,8 @@ class TeleBot:
def add_inline_handler(self, handler_dict):
"""
Adds inline call handler
Note that you should use register_inline_handler to add inline_handler to the bot.
:param handler_dict:
:return:
"""
@ -3164,6 +3265,7 @@ class TeleBot:
def register_inline_handler(self, callback, func, pass_bot=False, **kwargs):
"""
Registers inline handler.
:param callback: function to be called
:param func:
:param pass_bot: Pass TeleBot to handler.
@ -3175,6 +3277,7 @@ class TeleBot:
def chosen_inline_handler(self, func, **kwargs):
"""
Description: TBD
:param func:
:param kwargs:
:return:
@ -3189,6 +3292,8 @@ class TeleBot:
def add_chosen_inline_handler(self, handler_dict):
"""
Description: TBD
Note that you should use register_chosen_inline_handler to add chosen_inline_handler to the bot.
:param handler_dict:
:return:
"""
@ -3208,6 +3313,7 @@ class TeleBot:
def callback_query_handler(self, func, **kwargs):
"""
Callback request handler decorator
:param func:
:param kwargs:
:return:
@ -3222,6 +3328,8 @@ class TeleBot:
def add_callback_query_handler(self, handler_dict):
"""
Adds a callback request handler
Note that you should use register_callback_query_handler to add callback_query_handler to the bot.
:param handler_dict:
:return:
"""
@ -3229,7 +3337,8 @@ class TeleBot:
def register_callback_query_handler(self, callback, func, pass_bot=False, **kwargs):
"""
Registers callback query handler..
Registers callback query handler.
:param callback: function to be called
:param func:
:param pass_bot: Pass TeleBot to handler.
@ -3241,6 +3350,7 @@ class TeleBot:
def shipping_query_handler(self, func, **kwargs):
"""
Shipping request handler
:param func:
:param kwargs:
:return:
@ -3254,7 +3364,9 @@ class TeleBot:
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 to the bot.
:param handler_dict:
:return:
"""
@ -3263,6 +3375,7 @@ class TeleBot:
def register_shipping_query_handler(self, callback, func, pass_bot=False, **kwargs):
"""
Registers shipping query handler.
:param callback: function to be called
:param func:
:param pass_bot: Pass TeleBot to handler.
@ -3274,6 +3387,7 @@ class TeleBot:
def pre_checkout_query_handler(self, func, **kwargs):
"""
Pre-checkout request handler
:param func:
:param kwargs:
:return:
@ -3288,6 +3402,8 @@ class TeleBot:
def add_pre_checkout_query_handler(self, handler_dict):
"""
Adds a pre-checkout request handler
Note that you should use register_pre_checkout_query_handler to add pre_checkout_query_handler to the bot.
:param handler_dict:
:return:
"""
@ -3296,6 +3412,7 @@ class TeleBot:
def register_pre_checkout_query_handler(self, callback, func, pass_bot=False, **kwargs):
"""
Registers pre-checkout request handler.
:param callback: function to be called
:param func:
:param pass_bot: Pass TeleBot to handler.
@ -3307,6 +3424,7 @@ class TeleBot:
def poll_handler(self, func, **kwargs):
"""
Poll request handler
:param func:
:param kwargs:
:return:
@ -3321,6 +3439,8 @@ class TeleBot:
def add_poll_handler(self, handler_dict):
"""
Adds a poll request handler
Note that you should use register_poll_handler to add poll_handler to the bot.
:param handler_dict:
:return:
"""
@ -3329,6 +3449,7 @@ class TeleBot:
def register_poll_handler(self, callback, func, pass_bot=False, **kwargs):
"""
Registers poll handler.
:param callback: function to be called
:param func:
:param pass_bot: Pass TeleBot to handler.
@ -3340,6 +3461,7 @@ class TeleBot:
def poll_answer_handler(self, func=None, **kwargs):
"""
Poll_answer request handler
:param func:
:param kwargs:
:return:
@ -3353,7 +3475,9 @@ class TeleBot:
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 to the bot.
:param handler_dict:
:return:
"""
@ -3362,6 +3486,7 @@ class TeleBot:
def register_poll_answer_handler(self, callback, func, pass_bot=False, **kwargs):
"""
Registers poll answer handler.
:param callback: function to be called
:param func:
:param pass_bot: Pass TeleBot to handler.
@ -3372,7 +3497,8 @@ class TeleBot:
def my_chat_member_handler(self, func=None, **kwargs):
"""
my_chat_member handler
my_chat_member handler.
:param func:
:param kwargs:
:return:
@ -3386,7 +3512,9 @@ class TeleBot:
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 to the bot.
:param handler_dict:
:return:
"""
@ -3395,6 +3523,7 @@ class TeleBot:
def register_my_chat_member_handler(self, callback, func=None, pass_bot=False, **kwargs):
"""
Registers my chat member handler.
:param callback: function to be called
:param func:
:param pass_bot: Pass TeleBot to handler.
@ -3405,7 +3534,8 @@ class TeleBot:
def chat_member_handler(self, func=None, **kwargs):
"""
chat_member handler
chat_member handler.
:param func:
:param kwargs:
:return:
@ -3419,7 +3549,9 @@ class TeleBot:
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 to the bot.
:param handler_dict:
:return:
"""
@ -3428,6 +3560,7 @@ class TeleBot:
def register_chat_member_handler(self, callback, func=None, pass_bot=False, **kwargs):
"""
Registers chat member handler.
:param callback: function to be called
:param func:
:param pass_bot: Pass TeleBot to handler.
@ -3439,6 +3572,7 @@ class TeleBot:
def chat_join_request_handler(self, func=None, **kwargs):
"""
chat_join_request handler
:param func:
:param kwargs:
:return:
@ -3452,7 +3586,9 @@ class TeleBot:
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 to the bot.
:param handler_dict:
:return:
"""
@ -3472,6 +3608,7 @@ class TeleBot:
def _test_message_handler(self, message_handler, message):
"""
Test message handler
:param message_handler:
:param message:
:return:
@ -3485,16 +3622,19 @@ class TeleBot:
return True
def add_custom_filter(self, custom_filter):
def add_custom_filter(self, custom_filter: Union[SimpleCustomFilter, AdvancedCustomFilter]):
"""
Create custom filter.
custom_filter: Class with check(message) method.
:param custom_filter: Custom filter class with key.
"""
self.custom_filters[custom_filter.key] = custom_filter
def _test_filter(self, message_filter, filter_value, message):
"""
Test filters
:param message_filter: Filter type passed in handler
:param filter_value: Filter value passed in handler
:param message: Message to test
@ -3531,6 +3671,7 @@ class TeleBot:
def _check_middleware(self, update_type):
"""
Check middleware
:param message:
:return:
"""
@ -3539,7 +3680,9 @@ class TeleBot:
return middlewares
def _run_middlewares_and_handler(self, message, handlers, middlewares, *args, **kwargs):
"""This class is made to run handler and middleware in queue.
"""
This class is made to run handler and middleware in queue.
:param handler: handler that should be executed.
:param middleware: middleware that should be executed.
:return:
@ -3557,9 +3700,6 @@ class TeleBot:
return
elif isinstance(result, SkipHandler) and skip_handler is False:
skip_handler = True
try:
if handlers and not skip_handler:
@ -3603,7 +3743,8 @@ class TeleBot:
def _notify_command_handlers(self, handlers, new_messages, update_type):
"""
Notifies command handlers
Notifies command handlers.
:param handlers:
:param new_messages:
:return: