@@ -540,7 +540,7 @@ def run_webhooks(self,
540540 from telebot .ext .sync import SyncWebhookListener
541541 except (NameError , ImportError ):
542542 raise ImportError ("Please install uvicorn and fastapi in order to use `run_webhooks` method." )
543- self .webhook_listener = SyncWebhookListener (self , secret_token , listen , port , ssl_context , '/' + url_path )
543+ self .webhook_listener = SyncWebhookListener (bot = self , secret_token = secret_token , host = listen , port = port , ssl_context = ssl_context , url_path = '/' + url_path )
544544 self .webhook_listener .run_app ()
545545
546546
@@ -1763,7 +1763,8 @@ def send_photo(
17631763 allow_sending_without_reply : Optional [bool ]= None ,
17641764 reply_markup : Optional [REPLY_MARKUP_TYPES ]= None ,
17651765 timeout : Optional [int ]= None ,
1766- message_thread_id : Optional [int ]= None ) -> types .Message :
1766+ message_thread_id : Optional [int ]= None ,
1767+ has_spoiler : Optional [bool ]= None ) -> types .Message :
17671768 """
17681769 Use this method to send photos. On success, the sent Message is returned.
17691770
@@ -1808,6 +1809,9 @@ def send_photo(
18081809
18091810 :param message_thread_id: Identifier of a message thread, in which the message will be sent
18101811 :type message_thread_id: :obj:`int`
1812+
1813+ :param has_spoiler: Pass True, if the photo should be sent as a spoiler
1814+ :type has_spoiler: :obj:`bool`
18111815
18121816 :return: On success, the sent Message is returned.
18131817 :rtype: :class:`telebot.types.Message`
@@ -1821,7 +1825,7 @@ def send_photo(
18211825 apihelper .send_photo (
18221826 self .token , chat_id , photo , caption , reply_to_message_id , reply_markup ,
18231827 parse_mode , disable_notification , timeout , caption_entities ,
1824- allow_sending_without_reply , protect_content , message_thread_id ))
1828+ allow_sending_without_reply , protect_content , message_thread_id , has_spoiler ))
18251829
18261830 # TODO: Rewrite this method like in API.
18271831 def send_audio (
@@ -2171,7 +2175,8 @@ def send_video(
21712175 reply_markup : Optional [REPLY_MARKUP_TYPES ]= None ,
21722176 timeout : Optional [int ]= None ,
21732177 data : Optional [Union [Any , str ]]= None ,
2174- message_thread_id : Optional [int ]= None ) -> types .Message :
2178+ message_thread_id : Optional [int ]= None ,
2179+ has_spoiler : Optional [bool ]= None ) -> types .Message :
21752180 """
21762181 Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
21772182
@@ -2233,6 +2238,9 @@ def send_video(
22332238 :param message_thread_id: Identifier of a message thread, in which the video will be sent
22342239 :type message_thread_id: :obj:`int`
22352240
2241+ :param has_spoiler: Pass True, if the video should be sent as a spoiler
2242+ :type has_spoiler: :obj:`bool`
2243+
22362244 :return: On success, the sent Message is returned.
22372245 :rtype: :class:`telebot.types.Message`
22382246 """
@@ -2249,7 +2257,7 @@ def send_video(
22492257 apihelper .send_video (
22502258 self .token , chat_id , video , duration , caption , reply_to_message_id , reply_markup ,
22512259 parse_mode , supports_streaming , disable_notification , timeout , thumb , width , height ,
2252- caption_entities , allow_sending_without_reply , protect_content , message_thread_id ))
2260+ caption_entities , allow_sending_without_reply , protect_content , message_thread_id , has_spoiler ))
22532261
22542262 def send_animation (
22552263 self , chat_id : Union [int , str ], animation : Union [Any , str ],
@@ -2266,7 +2274,8 @@ def send_animation(
22662274 allow_sending_without_reply : Optional [bool ]= None ,
22672275 reply_markup : Optional [REPLY_MARKUP_TYPES ]= None ,
22682276 timeout : Optional [int ]= None ,
2269- message_thread_id : Optional [int ]= None ) -> types .Message :
2277+ message_thread_id : Optional [int ]= None ,
2278+ has_spoiler : Optional [bool ]= None ) -> types .Message :
22702279 """
22712280 Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound).
22722281 On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.
@@ -2327,6 +2336,9 @@ def send_animation(
23272336 :param message_thread_id: Identifier of a message thread, in which the video will be sent
23282337 :type message_thread_id: :obj:`int`
23292338
2339+ :param has_spoiler: Pass True, if the animation should be sent as a spoiler
2340+ :type has_spoiler: :obj:`bool`
2341+
23302342 :return: On success, the sent Message is returned.
23312343 :rtype: :class:`telebot.types.Message`
23322344 """
@@ -2339,7 +2351,7 @@ def send_animation(
23392351 apihelper .send_animation (
23402352 self .token , chat_id , animation , duration , caption , reply_to_message_id ,
23412353 reply_markup , parse_mode , disable_notification , timeout , thumb ,
2342- caption_entities , allow_sending_without_reply , protect_content , width , height , message_thread_id ))
2354+ caption_entities , allow_sending_without_reply , protect_content , width , height , message_thread_id , has_spoiler ))
23432355
23442356 # TODO: Rewrite this method like in API.
23452357 def send_video_note (
@@ -2794,7 +2806,7 @@ def send_contact(
27942806 allow_sending_without_reply , protect_content , message_thread_id ))
27952807
27962808 def send_chat_action (
2797- self , chat_id : Union [int , str ], action : str , timeout : Optional [int ]= None ) -> bool :
2809+ self , chat_id : Union [int , str ], action : str , timeout : Optional [int ]= None , message_thread_id : Optional [ int ] = None ) -> bool :
27982810 """
27992811 Use this method when you need to tell the user that something is happening on the bot's side.
28002812 The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
@@ -2817,10 +2829,13 @@ def send_chat_action(
28172829 :param timeout: Timeout in seconds for the request.
28182830 :type timeout: :obj:`int`
28192831
2832+ :param message_thread_id: The thread identifier of a message from which the reply will be sent(supergroups only)
2833+ :type message_thread_id: :obj:`int`
2834+
28202835 :return: Returns True on success.
28212836 :rtype: :obj:`bool`
28222837 """
2823- return apihelper .send_chat_action (self .token , chat_id , action , timeout )
2838+ return apihelper .send_chat_action (self .token , chat_id , action , timeout , message_thread_id )
28242839
28252840 @util .deprecated (deprecation_text = "Use ban_chat_member instead" )
28262841 def kick_chat_member (
@@ -4636,8 +4651,8 @@ def create_forum_topic(self,
46364651
46374652 def edit_forum_topic (
46384653 self , chat_id : Union [int , str ],
4639- message_thread_id : int , name : str ,
4640- icon_custom_emoji_id : str ,
4654+ message_thread_id : int , name : Optional [ str ] = None ,
4655+ icon_custom_emoji_id : Optional [ str ] = None
46414656 ) -> bool :
46424657 """
46434658 Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an
@@ -4652,10 +4667,13 @@ def edit_forum_topic(
46524667 :param message_thread_id: Identifier of the topic to edit
46534668 :type message_thread_id: :obj:`int`
46544669
4655- :param name: New name of the topic, 1-128 characters
4670+ :param name: Optional, New name of the topic, 1-128 characters. If not specififed or empty,
4671+ the current name of the topic will be kept
46564672 :type name: :obj:`str`
46574673
4658- :param icon_custom_emoji_id: New custom emoji for the topic icon. Must be an emoji of type “tgs” and must be exactly 1 character long
4674+ :param icon_custom_emoji_id: Optional, New unique identifier of the custom emoji shown as the topic icon.
4675+ Use getForumTopicIconStickers to get all allowed custom emoji identifiers. Pass an empty string to remove the
4676+ icon. If not specified, the current icon will be kept
46594677 :type icon_custom_emoji_id: :obj:`str`
46604678
46614679 :return: On success, True is returned.
@@ -4739,6 +4757,75 @@ def unpin_all_forum_topic_messages(self, chat_id: Union[str, int], message_threa
47394757 """
47404758 return apihelper .unpin_all_forum_topic_messages (self .token , chat_id , message_thread_id )
47414759
4760+ def edit_general_forum_topic (self , chat_id : Union [int , str ], name : str ) -> bool :
4761+ """
4762+ Use this method to edit the name of the 'General' topic in a forum supergroup chat.
4763+ The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights.
4764+ Returns True on success.
4765+
4766+ Telegram documentation: https://core.telegram.org/bots/api#editgeneralforumtopic
4767+
4768+ :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
4769+ :type chat_id: :obj:`int` or :obj:`str`
4770+
4771+ :param name: New topic name, 1-128 characters
4772+ :type name: :obj:`str`
4773+ """
4774+
4775+ return apihelper .edit_general_forum_topic (self .token , chat_id , name )
4776+
4777+ def close_general_forum_topic (self , chat_id : Union [int , str ]) -> bool :
4778+ """
4779+ Use this method to close the 'General' topic in a forum supergroup chat.
4780+ The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights.
4781+ Returns True on success.
4782+
4783+ Telegram documentation: https://core.telegram.org/bots/api#closegeneralforumtopic
4784+
4785+ :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
4786+ :type chat_id: :obj:`int` or :obj:`str`
4787+ """
4788+ return apihelper .close_general_forum_topic (self .token , chat_id )
4789+
4790+ def reopen_general_forum_topic (self , chat_id : Union [int , str ]) -> bool :
4791+ """
4792+ Use this method to reopen the 'General' topic in a forum supergroup chat.
4793+ The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights.
4794+ Returns True on success.
4795+
4796+ Telegram documentation: https://core.telegram.org/bots/api#reopengeneralforumtopic
4797+
4798+ :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
4799+ :type chat_id: :obj:`int` or :obj:`str`
4800+ """
4801+ return apihelper .reopen_general_forum_topic (self .token , chat_id )
4802+
4803+ def hide_general_forum_topic (self , chat_id : Union [int , str ]) -> bool :
4804+ """
4805+ Use this method to hide the 'General' topic in a forum supergroup chat.
4806+ The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights.
4807+ Returns True on success.
4808+
4809+ Telegram documentation: https://core.telegram.org/bots/api#hidegeneralforumtopic
4810+
4811+ :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
4812+ :type chat_id: :obj:`int` or :obj:`str`
4813+ """
4814+ return apihelper .hide_general_forum_topic (self .token , chat_id )
4815+
4816+ def unhide_general_forum_topic (self , chat_id : Union [int , str ]) -> bool :
4817+ """
4818+ Use this method to unhide the 'General' topic in a forum supergroup chat.
4819+ The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights.
4820+ Returns True on success.
4821+
4822+ Telegram documentation: https://core.telegram.org/bots/api#unhidegeneralforumtopic
4823+
4824+ :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
4825+ :type chat_id: :obj:`int` or :obj:`str`
4826+ """
4827+ return apihelper .unhide_general_forum_topic (self .token , chat_id )
4828+
47424829 def get_forum_topic_icon_stickers (self ) -> List [types .Sticker ]:
47434830 """
47444831 Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user.
@@ -4981,14 +5068,14 @@ def add_data(self, user_id: int, chat_id: Optional[int]=None, **kwargs):
49815068 self .current_states .set_data (chat_id , user_id , key , value )
49825069
49835070 def register_next_step_handler_by_chat_id (
4984- self , chat_id : Union [ int , str ] , callback : Callable , * args , ** kwargs ) -> None :
5071+ self , chat_id : int , callback : Callable , * args , ** kwargs ) -> None :
49855072 """
4986- Registers a callback function to be notified when new message arrives after `message` .
5073+ Registers a callback function to be notified when new message arrives in the given chat .
49875074
49885075 Warning: In case `callback` as lambda function, saving next step handlers will not work.
49895076
4990- :param chat_id: The chat for which we want to handle new message.
4991- :type chat_id: :obj:`int` or :obj:`str`
5077+ :param chat_id: The chat (chat ID) for which we want to handle new message.
5078+ :type chat_id: :obj:`int`
49925079
49935080 :param callback: The callback function which next new message arrives.
49945081 :type callback: :obj:`Callable[[telebot.types.Message], None]`
0 commit comments