diff --git a/README.md b/README.md
index 7a67b7d78..29764fb3c 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@
A simple, but extensible Python implementation for the Telegram Bot API.
Both synchronous and asynchronous.
-## Supported Bot API version:
+##
Supported Bot API version:
diff --git a/telebot/__init__.py b/telebot/__init__.py
index 59a8d7db8..dcdeb8eb3 100644
--- a/telebot/__init__.py
+++ b/telebot/__init__.py
@@ -1691,7 +1691,9 @@ def send_message(
link_preview_options : Optional[types.LinkPreviewOptions]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send text messages.
@@ -1754,6 +1756,15 @@ def send_message(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -1802,7 +1813,10 @@ def send_message(
reply_markup=reply_markup, parse_mode=parse_mode, disable_notification=disable_notification,
timeout=timeout, entities=entities, protect_content=protect_content, message_thread_id=message_thread_id,
reply_parameters=reply_parameters, link_preview_options=link_preview_options, business_connection_id=business_connection_id,
- message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast))
+ message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast, direct_messages_topic_id=direct_messages_topic_id,
+ suggested_post_parameters=suggested_post_parameters
+ )
+ )
def forward_message(
@@ -1811,7 +1825,9 @@ def forward_message(
protect_content: Optional[bool]=None,
timeout: Optional[int]=None,
message_thread_id: Optional[int]=None,
- video_start_timestamp: Optional[int]=None) -> types.Message:
+ video_start_timestamp: Optional[int]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to forward messages of any kind.
@@ -1841,6 +1857,15 @@ def forward_message(
:param message_thread_id: Identifier of a message thread, in which the message will be sent
:type message_thread_id: :obj:`int`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -1851,7 +1876,10 @@ def forward_message(
apihelper.forward_message(
self.token, chat_id, from_chat_id, message_id, disable_notification=disable_notification,
timeout=timeout, protect_content=protect_content, message_thread_id=message_thread_id,
- video_start_timestamp=video_start_timestamp))
+ video_start_timestamp=video_start_timestamp, direct_messages_topic_id=direct_messages_topic_id,
+ suggested_post_parameters=suggested_post_parameters
+ )
+ )
def copy_message(
@@ -1871,7 +1899,9 @@ def copy_message(
reply_parameters: Optional[types.ReplyParameters]=None,
show_caption_above_media: Optional[bool]=None,
allow_paid_broadcast: Optional[bool]=None,
- video_start_timestamp: Optional[int]=None) -> types.MessageID:
+ video_start_timestamp: Optional[int]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.MessageID:
"""
Use this method to copy messages of any kind.
Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied.
@@ -1933,6 +1963,15 @@ def copy_message(
:param allow_paid_broadcast: Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
:return: On success, the MessageId of the sent message is returned.
:rtype: :class:`telebot.types.MessageID`
@@ -1966,8 +2005,54 @@ def copy_message(
reply_markup=reply_markup, timeout=timeout, protect_content=protect_content,
message_thread_id=message_thread_id, reply_parameters=reply_parameters,
show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast,
- video_start_timestamp=video_start_timestamp))
+ video_start_timestamp=video_start_timestamp, direct_messages_topic_id=direct_messages_topic_id,
+ suggested_post_parameters=suggested_post_parameters
+ ))
+
+
+ def approve_suggested_post(self, chat_id: int, message_id: int, send_date: Optional[int]=None) -> bool:
+ """
+ Use this method to approve a suggested post in a direct messages chat. The bot must have the 'can_post_messages' administrator right in the corresponding channel chat. Returns True on success.
+
+ Telegram documentation: https://core.telegram.org/bots/api#approvesuggestedpost
+
+ :param chat_id: Unique identifier for the target direct messages chat
+ :type chat_id: :obj:`int`
+
+ :param message_id: Identifier of a suggested post message to approve
+ :type message_id: :obj:`int`
+
+ :param send_date: Point in time (Unix timestamp) when the post is expected to be published; omit if the date has already been specified when the suggested post was created.
+ If specified, then the date must be not more than 2678400 seconds (30 days) in the future
+ :type send_date: :obj:`int`
+ :return: Returns True on success.
+ :rtype: :obj:`bool`
+ """
+ return apihelper.approve_suggested_post(self.token, chat_id, message_id,
+ send_date=send_date)
+
+ def decline_suggested_post(self, chat_id: int, message_id: int, comment: Optional[str]=None) -> bool:
+ """
+ Use this method to decline a suggested post in a direct messages chat. The bot must have
+ the 'can_manage_direct_messages' administrator right in the corresponding channel chat. Returns True on success.
+
+ Telegram documentation: https://core.telegram.org/bots/api#declinesuggestedpost
+
+ :param chat_id: Unique identifier for the target direct messages chat
+ :type chat_id: :obj:`int`
+
+ :param message_id: Identifier of a suggested post message to decline
+ :type message_id: :obj:`int`
+
+ :param comment: Comment for the creator of the suggested post; 0-128 characters
+ :type comment: :obj:`str`
+
+ :return: Returns True on success.
+ :rtype: :obj:`bool`
+ """
+ return apihelper.decline_suggested_post(self.token, chat_id, message_id,
+ comment=comment)
def delete_message(self, chat_id: Union[int, str], message_id: int,
timeout: Optional[int]=None) -> bool:
@@ -2019,7 +2104,7 @@ def delete_messages(self, chat_id: Union[int, str], message_ids: List[int]):
def forward_messages(self, chat_id: Union[str, int], from_chat_id: Union[str, int], message_ids: List[int],
disable_notification: Optional[bool]=None, message_thread_id: Optional[int]=None,
- protect_content: Optional[bool]=None) -> List[types.MessageID]:
+ protect_content: Optional[bool]=None, direct_messages_topic_id: Optional[int]=None) -> List[types.MessageID]:
"""
Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped.
Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages.
@@ -2045,6 +2130,10 @@ def forward_messages(self, chat_id: Union[str, int], from_chat_id: Union[str, in
:param protect_content: Protects the contents of the forwarded message from forwarding and saving
:type protect_content: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.MessageID`
"""
@@ -2055,13 +2144,14 @@ def forward_messages(self, chat_id: Union[str, int], from_chat_id: Union[str, in
result = apihelper.forward_messages(
self.token, chat_id, from_chat_id, message_ids,
disable_notification=disable_notification, message_thread_id=message_thread_id,
- protect_content=protect_content)
+ protect_content=protect_content, direct_messages_topic_id=direct_messages_topic_id)
return [types.MessageID.de_json(message_id) for message_id in result]
def copy_messages(self, chat_id: Union[str, int], from_chat_id: Union[str, int], message_ids: List[int],
disable_notification: Optional[bool] = None, message_thread_id: Optional[int] = None,
- protect_content: Optional[bool] = None, remove_caption: Optional[bool] = None) -> List[types.MessageID]:
+ protect_content: Optional[bool] = None, remove_caption: Optional[bool] = None,
+ direct_messages_topic_id: Optional[int] = None) -> List[types.MessageID]:
"""
Use this method to copy messages of any kind.
If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages,
@@ -2093,6 +2183,10 @@ def copy_messages(self, chat_id: Union[str, int], from_chat_id: Union[str, int],
:param remove_caption: Pass True to copy the messages without their captions
:type remove_caption: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
:return: On success, an array of MessageId of the sent messages is returned.
:rtype: :obj:`list` of :class:`telebot.types.MessageID`
"""
@@ -2101,7 +2195,8 @@ def copy_messages(self, chat_id: Union[str, int], from_chat_id: Union[str, int],
result = apihelper.copy_messages(
self.token, chat_id, from_chat_id, message_ids, disable_notification=disable_notification,
- message_thread_id=message_thread_id, protect_content=protect_content, remove_caption=remove_caption)
+ message_thread_id=message_thread_id, protect_content=protect_content, remove_caption=remove_caption,
+ direct_messages_topic_id=direct_messages_topic_id)
return [types.MessageID.de_json(message_id) for message_id in result]
def send_checklist(
@@ -2201,7 +2296,9 @@ def send_dice(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.
@@ -2250,6 +2347,15 @@ def send_dice(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -2279,7 +2385,10 @@ def send_dice(
self.token, chat_id, emoji=emoji, disable_notification=disable_notification,
reply_markup=reply_markup, timeout=timeout, protect_content=protect_content,
message_thread_id=message_thread_id, reply_parameters=reply_parameters, business_connection_id=business_connection_id,
- message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast))
+ message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast, direct_messages_topic_id=direct_messages_topic_id,
+ suggested_post_parameters=suggested_post_parameters
+ )
+ )
@@ -2299,7 +2408,9 @@ def send_photo(
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
show_caption_above_media: Optional[bool]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send photos. On success, the sent Message is returned.
@@ -2363,6 +2474,15 @@ def send_photo(
:param allow_paid_broadcast: Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
@@ -2396,8 +2516,10 @@ def send_photo(
caption_entities=caption_entities, protect_content=protect_content,
message_thread_id=message_thread_id, has_spoiler=has_spoiler, reply_parameters=reply_parameters,
business_connection_id=business_connection_id, message_effect_id=message_effect_id,
- show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast))
-
+ show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters
+ )
+ )
def send_audio(
self, chat_id: Union[int, str], audio: Union[Any, str],
@@ -2417,7 +2539,9 @@ def send_audio(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
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 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size,
@@ -2497,6 +2621,15 @@ def send_audio(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -2532,8 +2665,10 @@ def send_audio(
reply_markup=reply_markup, parse_mode=parse_mode, disable_notification=disable_notification,
timeout=timeout, thumbnail=thumbnail, caption_entities=caption_entities, protect_content=protect_content,
message_thread_id=message_thread_id, reply_parameters=reply_parameters, business_connection_id=business_connection_id,
- message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast))
-
+ message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters
+ )
+ )
def send_voice(
self, chat_id: Union[int, str], voice: Union[Any, str],
@@ -2550,7 +2685,9 @@ def send_voice(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS, or in .MP3 format, or in .M4A format (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
@@ -2611,6 +2748,15 @@ def send_voice(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
"""
parse_mode = self.parse_mode if (parse_mode is None) else parse_mode
@@ -2641,7 +2787,9 @@ def send_voice(
parse_mode=parse_mode, disable_notification=disable_notification, timeout=timeout,
caption_entities=caption_entities, protect_content=protect_content,
message_thread_id=message_thread_id, reply_parameters=reply_parameters, business_connection_id=business_connection_id,
- message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)
+ message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast, direct_messages_topic_id=direct_messages_topic_id,
+ suggested_post_parameters=suggested_post_parameters
+ )
)
@@ -2664,7 +2812,9 @@ def send_document(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send general files.
@@ -2737,6 +2887,15 @@ def send_document(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -2781,7 +2940,8 @@ def send_document(
timeout=timeout, caption=caption, thumbnail=thumbnail, caption_entities=caption_entities,
disable_content_type_detection=disable_content_type_detection, visible_file_name=visible_file_name,
protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters,
- business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)
+ business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters)
)
@@ -2800,7 +2960,9 @@ def send_sticker(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers.
On success, the sent Message is returned.
@@ -2856,6 +3018,15 @@ def send_sticker(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -2890,7 +3061,8 @@ def send_sticker(
reply_markup=reply_markup, disable_notification=disable_notification, timeout=timeout,
protect_content=protect_content, message_thread_id=message_thread_id, emoji=emoji,
reply_parameters=reply_parameters, business_connection_id=business_connection_id,
- message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)
+ message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters)
)
@@ -2920,7 +3092,9 @@ def send_video(
show_caption_above_media: Optional[bool]=None,
allow_paid_broadcast: Optional[bool]=None,
cover: Optional[Union[Any, str]]=None,
- start_timestamp: Optional[int]=None) -> types.Message:
+ start_timestamp: Optional[int]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
@@ -3014,6 +3188,15 @@ def send_video(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -3056,7 +3239,8 @@ def send_video(
protect_content=protect_content, message_thread_id=message_thread_id, has_spoiler=has_spoiler,
reply_parameters=reply_parameters, business_connection_id=business_connection_id, message_effect_id=message_effect_id,
show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast,
- cover=cover, start_timestamp=start_timestamp)
+ cover=cover, start_timestamp=start_timestamp, direct_messages_topic_id=direct_messages_topic_id,
+ suggested_post_parameters=suggested_post_parameters)
)
@@ -3082,7 +3266,9 @@ def send_animation(
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
show_caption_above_media: Optional[bool]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound).
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.
@@ -3165,6 +3351,15 @@ def send_animation(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -3201,7 +3396,8 @@ def send_animation(
thumbnail=thumbnail, caption_entities=caption_entities, protect_content=protect_content,
width=width, height=height, message_thread_id=message_thread_id, reply_parameters=reply_parameters,
has_spoiler=has_spoiler, business_connection_id=business_connection_id, message_effect_id=message_effect_id,
- show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast)
+ show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters)
)
@@ -3221,7 +3417,9 @@ def send_video_note(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long.
Use this method to send video messages. On success, the sent Message is returned.
@@ -3286,6 +3484,15 @@ def send_video_note(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -3319,7 +3526,8 @@ def send_video_note(
self.token, chat_id, data, duration=duration, length=length, reply_markup=reply_markup,
disable_notification=disable_notification, timeout=timeout, thumbnail=thumbnail,
protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters,
- business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)
+ business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters)
)
def send_paid_media(
@@ -3328,7 +3536,9 @@ def send_paid_media(
show_caption_above_media: Optional[bool]=None, disable_notification: Optional[bool]=None,
protect_content: Optional[bool]=None, reply_parameters: Optional[types.ReplyParameters]=None,
reply_markup: Optional[REPLY_MARKUP_TYPES]=None, business_connection_id: Optional[str]=None,
- payload: Optional[str]=None, allow_paid_broadcast: Optional[bool]=None
+ payload: Optional[str]=None, allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None
) -> types.Message:
"""
Use this method to send paid media to channel chats. On success, the sent Message is returned.
@@ -3378,6 +3588,15 @@ def send_paid_media(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -3387,7 +3606,8 @@ def send_paid_media(
caption_entities=caption_entities, show_caption_above_media=show_caption_above_media,
disable_notification=disable_notification, protect_content=protect_content,
reply_parameters=reply_parameters, reply_markup=reply_markup, business_connection_id=business_connection_id,
- payload=payload, allow_paid_broadcast=allow_paid_broadcast)
+ payload=payload, allow_paid_broadcast=allow_paid_broadcast, direct_messages_topic_id=direct_messages_topic_id,
+ suggested_post_parameters=suggested_post_parameters)
)
@@ -3405,7 +3625,8 @@ def send_media_group(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> List[types.Message]:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None) -> List[types.Message]:
"""
Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files
can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned.
@@ -3449,6 +3670,10 @@ def send_media_group(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
:return: On success, an array of Messages that were sent is returned.
:rtype: List[types.Message]
"""
@@ -3482,7 +3707,8 @@ def send_media_group(
result = apihelper.send_media_group(
self.token, chat_id, media, disable_notification=disable_notification, timeout=timeout,
protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters,
- business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)
+ business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast,
+ direct_messages_topic_id=direct_messages_topic_id)
return [types.Message.de_json(msg) for msg in result]
@@ -3503,7 +3729,9 @@ def send_location(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send point on the map. On success, the sent Message is returned.
@@ -3566,6 +3794,15 @@ def send_location(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -3596,7 +3833,8 @@ def send_location(
disable_notification=disable_notification, timeout=timeout, horizontal_accuracy=horizontal_accuracy,
heading=heading, proximity_alert_radius=proximity_alert_radius, protect_content=protect_content,
message_thread_id=message_thread_id, reply_parameters=reply_parameters, business_connection_id=business_connection_id,
- message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)
+ message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast, direct_messages_topic_id=direct_messages_topic_id,
+ suggested_post_parameters=suggested_post_parameters)
)
@@ -3728,7 +3966,9 @@ def send_venue(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send information about a venue. On success, the sent Message is returned.
@@ -3798,6 +4038,15 @@ def send_venue(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -3828,7 +4077,8 @@ def send_venue(
foursquare_type=foursquare_type, disable_notification=disable_notification, reply_markup=reply_markup,
timeout=timeout, google_place_id=google_place_id, google_place_type=google_place_type,
protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters, business_connection_id=business_connection_id,
- message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)
+ message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast, direct_messages_topic_id=direct_messages_topic_id,
+ suggested_post_parameters=suggested_post_parameters)
)
@@ -3845,7 +4095,9 @@ def send_contact(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send phone contacts. On success, the sent Message is returned.
@@ -3902,6 +4154,15 @@ def send_contact(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -3931,7 +4192,8 @@ def send_contact(
self.token, chat_id, phone_number, first_name, last_name=last_name, vcard=vcard,
disable_notification=disable_notification, reply_markup=reply_markup, timeout=timeout,
protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters,
- business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)
+ business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters)
)
@@ -4154,7 +4416,8 @@ def promote_chat_member(
can_manage_topics: Optional[bool]=None,
can_post_stories: Optional[bool]=None,
can_edit_stories: Optional[bool]=None,
- can_delete_stories: Optional[bool]=None) -> bool:
+ can_delete_stories: Optional[bool]=None,
+ can_manage_direct_messages: Optional[bool]=None) -> bool:
"""
Use this method to promote or demote a user in 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.
@@ -4224,6 +4487,10 @@ def promote_chat_member(
:param can_delete_stories: Pass True if the administrator can delete the channel's stories
:type can_delete_stories: :obj:`bool`
+ :param can_manage_direct_messages: Pass True if the administrator can manage direct messages
+ within the channel and decline suggested posts; for channels only
+ :type can_manage_direct_messages: :obj:`bool`
+
:return: True on success.
:rtype: :obj:`bool`
"""
@@ -4240,7 +4507,8 @@ def promote_chat_member(
is_anonymous=is_anonymous, can_manage_chat=can_manage_chat,
can_manage_video_chats=can_manage_video_chats, can_manage_topics=can_manage_topics,
can_post_stories=can_post_stories, can_edit_stories=can_edit_stories,
- can_delete_stories=can_delete_stories)
+ can_delete_stories=can_delete_stories, can_manage_direct_messages=can_manage_direct_messages,
+ )
def set_chat_administrator_custom_title(
@@ -5374,7 +5642,9 @@ def send_invoice(
message_thread_id: Optional[int]=None,
reply_parameters: Optional[types.ReplyParameters]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Sends invoice.
@@ -5487,6 +5757,15 @@ def send_invoice(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :obj:`types.Message`
"""
@@ -5526,7 +5805,8 @@ def send_invoice(
provider_data=provider_data, timeout=timeout, protect_content=protect_content,
message_thread_id=message_thread_id, reply_parameters=reply_parameters,
max_tip_amount=max_tip_amount, suggested_tip_amounts=suggested_tip_amounts,
- message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)
+ message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters)
)
def create_invoice_link(self,
diff --git a/telebot/apihelper.py b/telebot/apihelper.py
index cba38bbdd..68f2418da 100644
--- a/telebot/apihelper.py
+++ b/telebot/apihelper.py
@@ -247,7 +247,8 @@ def send_message(
parse_mode=None, disable_notification=None, timeout=None,
entities=None, protect_content=None,
message_thread_id=None, reply_parameters=None, link_preview_options=None,
- business_connection_id=None, message_effect_id=None, allow_paid_broadcast=None):
+ business_connection_id=None, message_effect_id=None, allow_paid_broadcast=None,
+ direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendMessage'
payload = {'chat_id': str(chat_id), 'text': text}
if link_preview_options is not None:
@@ -274,6 +275,10 @@ def send_message(
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return _make_request(token, method_url, params=payload, method='post')
@@ -427,7 +432,7 @@ def get_chat_member(token, chat_id, user_id):
def forward_message(
token, chat_id, from_chat_id, message_id,
disable_notification=None, timeout=None, protect_content=None, message_thread_id=None,
- video_start_timestamp=None):
+ video_start_timestamp=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'forwardMessage'
payload = {'chat_id': chat_id, 'from_chat_id': from_chat_id, 'message_id': message_id}
if disable_notification is not None:
@@ -440,13 +445,17 @@ def forward_message(
payload['message_thread_id'] = message_thread_id
if video_start_timestamp:
payload['video_start_timestamp'] = video_start_timestamp
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return _make_request(token, method_url, params=payload)
def copy_message(token, chat_id, from_chat_id, message_id, caption=None, parse_mode=None, caption_entities=None,
disable_notification=None, reply_markup=None, timeout=None, protect_content=None, message_thread_id=None,
reply_parameters=None, show_caption_above_media=None, allow_paid_broadcast=None,
- video_start_timestamp=None):
+ video_start_timestamp=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'copyMessage'
payload = {'chat_id': chat_id, 'from_chat_id': from_chat_id, 'message_id': message_id}
if caption is not None:
@@ -473,6 +482,10 @@ def copy_message(token, chat_id, from_chat_id, message_id, caption=None, parse_m
payload['allow_paid_broadcast'] = allow_paid_broadcast
if video_start_timestamp:
payload['video_start_timestamp'] = video_start_timestamp
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return _make_request(token, method_url, params=payload)
def send_checklist(
@@ -510,7 +523,8 @@ def send_dice(
token, chat_id,
emoji=None, disable_notification=None,
reply_markup=None, timeout=None, protect_content=None, message_thread_id=None, reply_parameters=None,
- business_connection_id=None, message_effect_id=None, allow_paid_broadcast=None):
+ business_connection_id=None, message_effect_id=None, allow_paid_broadcast=None, direct_messages_topic_id=None,
+ suggested_post_parameters=None):
method_url = r'sendDice'
payload = {'chat_id': chat_id}
if emoji:
@@ -533,6 +547,10 @@ def send_dice(
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return _make_request(token, method_url, params=payload)
@@ -542,7 +560,8 @@ def send_photo(
parse_mode=None, disable_notification=None, timeout=None,
caption_entities=None, protect_content=None,
message_thread_id=None, has_spoiler=None, reply_parameters=None, business_connection_id=None,
- message_effect_id=None, show_caption_above_media=None, allow_paid_broadcast=None):
+ message_effect_id=None, show_caption_above_media=None, allow_paid_broadcast=None,
+ direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendPhoto'
payload = {'chat_id': chat_id}
files = None
@@ -580,13 +599,18 @@ def send_photo(
payload['show_caption_above_media'] = show_caption_above_media
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return _make_request(token, method_url, params=payload, files=files, method='post')
def send_paid_media(
token, chat_id, star_count, media,
caption=None, parse_mode=None, caption_entities=None, show_caption_above_media=None,
disable_notification=None, protect_content=None, reply_parameters=None, reply_markup=None,
- business_connection_id=None, payload=None, allow_paid_broadcast=None):
+ business_connection_id=None, payload=None, allow_paid_broadcast=None, direct_messages_topic_id=None,
+ suggested_post_parameters=None):
method_url = r'sendPaidMedia'
media_json, files = convert_input_media_array(media)
_payload = {'chat_id': chat_id, 'star_count': star_count, 'media': media_json}
@@ -612,6 +636,10 @@ def send_paid_media(
_payload['payload'] = payload
if allow_paid_broadcast is not None:
_payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ _payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ _payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return _make_request(
token, method_url, params=_payload,
method='post' if files else 'get',
@@ -622,7 +650,7 @@ def send_media_group(
token, chat_id, media,
disable_notification=None,
timeout=None, protect_content=None, message_thread_id=None, reply_parameters=None, business_connection_id=None,
- message_effect_id=None, allow_paid_broadcast=None):
+ message_effect_id=None, allow_paid_broadcast=None, direct_messages_topic_id=None):
method_url = r'sendMediaGroup'
media_json, files = convert_input_media_array(media)
payload = {'chat_id': chat_id, 'media': media_json}
@@ -642,6 +670,8 @@ def send_media_group(
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
return _make_request(
token, method_url, params=payload,
method='post' if files else 'get',
@@ -655,7 +685,8 @@ def send_location(
timeout=None, horizontal_accuracy=None, heading=None,
proximity_alert_radius=None, protect_content=None,
message_thread_id=None, reply_parameters=None, business_connection_id=None,
- message_effect_id=None, allow_paid_broadcast=None):
+ message_effect_id=None, allow_paid_broadcast=None, direct_messages_topic_id=None,
+ suggested_post_parameters=None):
method_url = r'sendLocation'
payload = {'chat_id': chat_id, 'latitude': latitude, 'longitude': longitude}
if live_period:
@@ -684,6 +715,10 @@ def send_location(
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return _make_request(token, method_url, params=payload)
@@ -740,7 +775,7 @@ def send_venue(
foursquare_id=None, foursquare_type=None, disable_notification=None,
reply_markup=None, timeout=None, google_place_id=None,
google_place_type=None, protect_content=None, message_thread_id=None, reply_parameters=None, business_connection_id=None,
- message_effect_id=None, allow_paid_broadcast=None):
+ message_effect_id=None, allow_paid_broadcast=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendVenue'
payload = {'chat_id': chat_id, 'latitude': latitude, 'longitude': longitude, 'title': title, 'address': address}
if foursquare_id:
@@ -769,6 +804,10 @@ def send_venue(
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return _make_request(token, method_url, params=payload)
@@ -776,7 +815,7 @@ def send_contact(
token, chat_id, phone_number, first_name, last_name=None, vcard=None,
disable_notification=None, reply_markup=None, timeout=None,
protect_content=None, message_thread_id=None, reply_parameters=None, business_connection_id=None,
- message_effect_id=None, allow_paid_broadcast=None):
+ message_effect_id=None, allow_paid_broadcast=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendContact'
payload = {'chat_id': chat_id, 'phone_number': phone_number, 'first_name': first_name}
if last_name:
@@ -801,6 +840,10 @@ def send_contact(
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return _make_request(token, method_url, params=payload)
@@ -822,7 +865,7 @@ def send_video(token, chat_id, data, duration=None, caption=None, reply_markup=N
thumbnail=None, width=None, height=None, caption_entities=None, protect_content=None,
message_thread_id=None, has_spoiler=None, reply_parameters=None, business_connection_id=None,
message_effect_id=None, show_caption_above_media=None, allow_paid_broadcast=None,
- cover=None, start_timestamp=None):
+ cover=None, start_timestamp=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendVideo'
payload = {'chat_id': chat_id}
files = None
@@ -884,6 +927,10 @@ def send_video(token, chat_id, data, duration=None, caption=None, reply_markup=N
payload['cover'] = cover
if start_timestamp:
payload['start_timestamp'] = start_timestamp
+ if direct_messages_topic_id:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return _make_request(token, method_url, params=payload, files=files, method='post')
@@ -893,7 +940,7 @@ def send_animation(
parse_mode=None, disable_notification=None, timeout=None, thumbnail=None, caption_entities=None,
protect_content=None, width=None, height=None, message_thread_id=None, reply_parameters=None,
has_spoiler=None, business_connection_id=None, message_effect_id=None, show_caption_above_media=None,
- allow_paid_broadcast=None):
+ allow_paid_broadcast=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendAnimation'
payload = {'chat_id': chat_id}
files = None
@@ -943,13 +990,17 @@ def send_animation(
payload['show_caption_above_media'] = show_caption_above_media
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return _make_request(token, method_url, params=payload, files=files, method='post')
def send_voice(token, chat_id, voice, caption=None, duration=None, reply_markup=None,
parse_mode=None, disable_notification=None, timeout=None, caption_entities=None,
protect_content=None, message_thread_id=None, reply_parameters=None, business_connection_id=None,
- message_effect_id=None, allow_paid_broadcast=None):
+ message_effect_id=None, allow_paid_broadcast=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendVoice'
payload = {'chat_id': chat_id}
files = None
@@ -983,13 +1034,17 @@ def send_voice(token, chat_id, voice, caption=None, duration=None, reply_markup=
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return _make_request(token, method_url, params=payload, files=files, method='post')
def send_video_note(token, chat_id, data, duration=None, length=None, reply_markup=None,
disable_notification=None, timeout=None, thumbnail=None, protect_content=None,
message_thread_id=None, reply_parameters=None,business_connection_id=None, message_effect_id=None,
- allow_paid_broadcast=None):
+ allow_paid_broadcast=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendVideoNote'
payload = {'chat_id': chat_id}
files = None
@@ -1029,13 +1084,17 @@ def send_video_note(token, chat_id, data, duration=None, length=None, reply_mark
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return _make_request(token, method_url, params=payload, files=files, method='post')
def send_audio(token, chat_id, audio, caption=None, duration=None, performer=None, title=None,
reply_markup=None, parse_mode=None, disable_notification=None, timeout=None, thumbnail=None,
caption_entities=None, protect_content=None, message_thread_id=None, reply_parameters=None, business_connection_id=None,
- message_effect_id=None, allow_paid_broadcast=None):
+ message_effect_id=None, allow_paid_broadcast=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendAudio'
payload = {'chat_id': chat_id}
files = None
@@ -1081,6 +1140,10 @@ def send_audio(token, chat_id, audio, caption=None, duration=None, performer=Non
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return _make_request(token, method_url, params=payload, files=files, method='post')
@@ -1088,7 +1151,7 @@ def send_data(token, chat_id, data, data_type, reply_markup=None, parse_mode=Non
disable_notification=None, timeout=None, caption=None, thumbnail=None, caption_entities=None,
disable_content_type_detection=None, visible_file_name=None,
protect_content = None, message_thread_id=None, emoji=None, reply_parameters=None, business_connection_id=None,
- message_effect_id=None, allow_paid_broadcast=None):
+ message_effect_id=None, allow_paid_broadcast=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = get_method_by_type(data_type)
payload = {'chat_id': chat_id}
files = None
@@ -1135,6 +1198,10 @@ def send_data(token, chat_id, data, data_type, reply_markup=None, parse_mode=Non
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return _make_request(token, method_url, params=payload, files=files, method='post')
@@ -1190,7 +1257,7 @@ def promote_chat_member(
can_restrict_members=None, can_pin_messages=None, can_promote_members=None,
is_anonymous=None, can_manage_chat=None, can_manage_video_chats=None,
can_manage_topics=None, can_post_stories=None, can_edit_stories=None,
- can_delete_stories=None):
+ can_delete_stories=None, can_manage_direct_messages=None):
method_url = 'promoteChatMember'
payload = {'chat_id': chat_id, 'user_id': user_id}
if can_change_info is not None:
@@ -1223,6 +1290,8 @@ def promote_chat_member(
payload['can_edit_stories'] = can_edit_stories
if can_delete_stories is not None:
payload['can_delete_stories'] = can_delete_stories
+ if can_manage_direct_messages is not None:
+ payload['can_manage_direct_messages'] = can_manage_direct_messages
return _make_request(token, method_url, params=payload, method='post')
@@ -1624,6 +1693,20 @@ def edit_message_reply_markup(
payload['timeout'] = timeout
return _make_request(token, method_url, params=payload, method='post')
+def approve_suggested_post(token, chat_id, message_id, send_date=None):
+ method_url = r'approveSuggestedPost'
+ payload = {'chat_id': chat_id, 'message_id': message_id}
+ if send_date is not None:
+ payload['send_date'] = send_date
+ return _make_request(token, method_url, params=payload, method='post')
+
+def decline_suggested_post(token, chat_id, message_id, comment=None):
+ method_url = r'declineSuggestedPost'
+ payload = {'chat_id': chat_id, 'message_id': message_id}
+ if comment is not None:
+ payload['comment'] = comment
+ return _make_request(token, method_url, params=payload, method='post')
+
def delete_message(token, chat_id, message_id, timeout=None):
method_url = r'deleteMessage'
@@ -1726,7 +1809,7 @@ def send_invoice(
disable_notification=None, reply_markup=None, provider_data=None,
timeout=None, max_tip_amount=None, suggested_tip_amounts=None,
protect_content=None, message_thread_id=None, reply_parameters=None, message_effect_id=None,
- allow_paid_broadcast=None):
+ allow_paid_broadcast=None, direct_messages_topic_id=None, suggested_post_parameters=None):
"""
Use this method to send invoices. On success, the sent Message is returned.
:param token: Bot's token (you don't need to fill this)
@@ -1814,6 +1897,10 @@ def send_invoice(
payload['provider_token'] = provider_token
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return _make_request(token, method_url, params=payload)
@@ -2464,7 +2551,7 @@ def delete_messages(token, chat_id, message_ids):
return _make_request(token, method_url, params=payload)
def forward_messages(token, chat_id, from_chat_id, message_ids, disable_notification=None,
- message_thread_id=None, protect_content=None):
+ message_thread_id=None, protect_content=None, direct_messages_topic_id=None):
method_url = 'forwardMessages'
payload = {
'chat_id': chat_id,
@@ -2477,10 +2564,13 @@ def forward_messages(token, chat_id, from_chat_id, message_ids, disable_notifica
payload['message_thread_id'] = message_thread_id
if protect_content is not None:
payload['protect_content'] = protect_content
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
return _make_request(token, method_url, params=payload)
def copy_messages(token, chat_id, from_chat_id, message_ids, disable_notification=None,
- message_thread_id=None, protect_content=None, remove_caption=None, show_caption_above_media=None):
+ message_thread_id=None, protect_content=None, remove_caption=None, show_caption_above_media=None,
+ direct_messages_topic_id=None):
method_url = 'copyMessages'
payload = {
'chat_id': chat_id,
@@ -2497,6 +2587,8 @@ def copy_messages(token, chat_id, from_chat_id, message_ids, disable_notificatio
payload['remove_caption'] = remove_caption
if show_caption_above_media is not None:
payload['show_caption_above_media'] = show_caption_above_media
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
return _make_request(token, method_url, params=payload)
diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py
index fe8013135..33783893f 100644
--- a/telebot/async_telebot.py
+++ b/telebot/async_telebot.py
@@ -3213,7 +3213,9 @@ async def send_message(
link_preview_options: Optional[types.LinkPreviewOptions]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send text messages.
@@ -3276,6 +3278,15 @@ async def send_message(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -3331,7 +3342,10 @@ async def send_message(
self.token, chat_id, text,
reply_markup, parse_mode, disable_notification, timeout,
entities, protect_content, message_thread_id, reply_parameters, link_preview_options, business_connection_id,
- message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast))
+ message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters
+ )
+ )
async def forward_message(
self, chat_id: Union[int, str], from_chat_id: Union[int, str],
@@ -3339,7 +3353,9 @@ async def forward_message(
protect_content: Optional[bool]=None,
timeout: Optional[int]=None,
message_thread_id: Optional[int]=None,
- video_start_timestamp: Optional[int]=None) -> types.Message:
+ video_start_timestamp: Optional[int]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to forward messages of any kind.
@@ -3369,6 +3385,15 @@ async def forward_message(
:param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
:type message_thread_id: :obj:`int`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -3378,7 +3403,9 @@ async def forward_message(
return types.Message.de_json(
await asyncio_helper.forward_message(self.token, chat_id=chat_id, from_chat_id=from_chat_id, message_id=message_id,
disable_notification=disable_notification, protect_content=protect_content,
- timeout=timeout, message_thread_id=message_thread_id, video_start_timestamp=video_start_timestamp))
+ timeout=timeout, message_thread_id=message_thread_id, video_start_timestamp=video_start_timestamp,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters)
+ )
async def copy_message(
self, chat_id: Union[int, str],
@@ -3397,7 +3424,9 @@ async def copy_message(
reply_parameters: Optional[types.ReplyParameters]=None,
show_caption_above_media: Optional[bool]=None,
allow_paid_broadcast: Optional[bool]=None,
- video_start_timestamp: Optional[bool]=None) -> types.MessageID:
+ video_start_timestamp: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.MessageID:
"""
Use this method to copy messages of any kind.
If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages,
@@ -3460,6 +3489,15 @@ async def copy_message(
:param allow_paid_broadcast: Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
:return: On success, the MessageId of the sent message is returned.
:rtype: :class:`telebot.types.MessageID`
@@ -3494,7 +3532,54 @@ async def copy_message(
disable_notification=disable_notification, protect_content=protect_content,
reply_parameters=reply_parameters, reply_markup=reply_markup, timeout=timeout,
message_thread_id=message_thread_id, show_caption_above_media=show_caption_above_media,
- allow_paid_broadcast=allow_paid_broadcast, video_start_timestamp=video_start_timestamp))
+ allow_paid_broadcast=allow_paid_broadcast, video_start_timestamp=video_start_timestamp,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters
+ )
+ )
+
+ async def approve_suggested_post(self, chat_id: int, message_id: int, send_date: Optional[int]=None) -> bool:
+ """
+ Use this method to approve a suggested post in a direct messages chat. The bot must have the 'can_post_messages' administrator right in the corresponding channel chat. Returns True on success.
+
+ Telegram documentation: https://core.telegram.org/bots/api#approvesuggestedpost
+
+ :param chat_id: Unique identifier for the target direct messages chat
+ :type chat_id: :obj:`int`
+
+ :param message_id: Identifier of a suggested post message to approve
+ :type message_id: :obj:`int`
+
+ :param send_date: Point in time (Unix timestamp) when the post is expected to be published; omit if the date has already been specified when the suggested post was created.
+ If specified, then the date must be not more than 2678400 seconds (30 days) in the future
+ :type send_date: :obj:`int`
+
+ :return: Returns True on success.
+ :rtype: :obj:`bool`
+ """
+ return await asyncio_helper.approve_suggested_post(self.token, chat_id, message_id,
+ send_date=send_date)
+
+ async def decline_suggested_post(self, chat_id: int, message_id: int, comment: Optional[str]=None) -> bool:
+ """
+ Use this method to decline a suggested post in a direct messages chat. The bot must have
+ the 'can_manage_direct_messages' administrator right in the corresponding channel chat. Returns True on success.
+
+ Telegram documentation: https://core.telegram.org/bots/api#declinesuggestedpost
+
+ :param chat_id: Unique identifier for the target direct messages chat
+ :type chat_id: :obj:`int`
+
+ :param message_id: Identifier of a suggested post message to decline
+ :type message_id: :obj:`int`
+
+ :param comment: Comment for the creator of the suggested post; 0-128 characters
+ :type comment: :obj:`str`
+
+ :return: Returns True on success.
+ :rtype: :obj:`bool`
+ """
+ return await asyncio_helper.decline_suggested_post(self.token, chat_id, message_id,
+ comment=comment)
async def delete_message(self, chat_id: Union[int, str], message_id: int,
timeout: Optional[int]=None) -> bool:
@@ -3544,7 +3629,8 @@ async def delete_messages(self, chat_id: Union[int, str], message_ids: List[int]
return await asyncio_helper.delete_messages(self.token, chat_id, message_ids)
async def forward_messages(self, chat_id: Union[str, int], from_chat_id: Union[str, int], message_ids: List[int], disable_notification: Optional[bool]=None,
- message_thread_id: Optional[int]=None, protect_content: Optional[bool]=None) -> List[types.MessageID]:
+ message_thread_id: Optional[int]=None, protect_content: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None) -> List[types.MessageID]:
"""
Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded,
they are skipped. Service messages and messages with protected content can't be forwarded.
@@ -3570,18 +3656,24 @@ async def forward_messages(self, chat_id: Union[str, int], from_chat_id: Union[s
:param protect_content: Protects the contents of the forwarded message from forwarding and saving
:type protect_content: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.MessageID`
"""
disable_notification = self.disable_notification if (disable_notification is None) else disable_notification
protect_content = self.protect_content if (protect_content is None) else protect_content
- result = await asyncio_helper.forward_messages(self.token, chat_id, from_chat_id, message_ids, disable_notification, message_thread_id, protect_content)
+ result = await asyncio_helper.forward_messages(self.token, chat_id, from_chat_id, message_ids, disable_notification, message_thread_id, protect_content,
+ direct_messages_topic_id=direct_messages_topic_id)
return [types.MessageID.de_json(message_id) for message_id in result]
async def copy_messages(self, chat_id: Union[str, int], from_chat_id: Union[str, int], message_ids: List[int],
disable_notification: Optional[bool] = None, message_thread_id: Optional[int] = None,
- protect_content: Optional[bool] = None, remove_caption: Optional[bool] = None) -> List[types.MessageID]:
+ protect_content: Optional[bool] = None, remove_caption: Optional[bool] = None,
+ direct_messages_topic_id: Optional[int] = None) -> List[types.MessageID]:
"""
Use this method to copy messages of any kind.
Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied.
@@ -3611,13 +3703,17 @@ async def copy_messages(self, chat_id: Union[str, int], from_chat_id: Union[str,
:param remove_caption: Pass True to copy the messages without their captions
:type remove_caption: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
:return: On success, an array of MessageId of the sent messages is returned.
:rtype: :obj:`list` of :class:`telebot.types.MessageID`
"""
disable_notification = self.disable_notification if disable_notification is None else disable_notification
protect_content = self.protect_content if protect_content is None else protect_content
result = await asyncio_helper.copy_messages(self.token, chat_id, from_chat_id, message_ids, disable_notification, message_thread_id,
- protect_content, remove_caption)
+ protect_content, remove_caption, direct_messages_topic_id)
return [types.MessageID.de_json(message_id) for message_id in result]
async def send_checklist(
@@ -3717,7 +3813,9 @@ async def send_dice(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.
@@ -3766,6 +3864,15 @@ async def send_dice(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -3797,8 +3904,9 @@ async def send_dice(
await asyncio_helper.send_dice(
self.token, chat_id, emoji, disable_notification,
reply_markup, timeout, protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id,
- allow_paid_broadcast=allow_paid_broadcast))
-
+ allow_paid_broadcast=allow_paid_broadcast, direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters
+ )
+ )
async def send_photo(
self, chat_id: Union[int, str], photo: Union[Any, str],
@@ -3816,7 +3924,9 @@ async def send_photo(
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
show_caption_above_media: Optional[bool]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send photos. On success, the sent Message is returned.
@@ -3880,7 +3990,16 @@ async def send_photo(
:param allow_paid_broadcast: Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -3914,7 +4033,10 @@ async def send_photo(
self.token, chat_id, photo, caption, reply_markup,
parse_mode, disable_notification, timeout, caption_entities,
protect_content, message_thread_id, has_spoiler, reply_parameters, business_connection_id, message_effect_id=message_effect_id,
- show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast))
+ show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters
+ )
+ )
async def send_audio(
self, chat_id: Union[int, str], audio: Union[Any, str],
@@ -3934,7 +4056,9 @@ async def send_audio(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
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 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size,
@@ -4014,6 +4138,15 @@ async def send_audio(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -4050,7 +4183,10 @@ async def send_audio(
await asyncio_helper.send_audio(
self.token, chat_id, audio, caption, duration, performer, title,
reply_markup, parse_mode, disable_notification, timeout, thumbnail,
- caption_entities, protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast))
+ caption_entities, protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters
+ )
+ )
async def send_voice(
self, chat_id: Union[int, str], voice: Union[Any, str],
@@ -4067,7 +4203,9 @@ async def send_voice(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS, or in .MP3 format, or in .M4A format (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
@@ -4128,6 +4266,15 @@ async def send_voice(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
"""
parse_mode = self.parse_mode if (parse_mode is None) else parse_mode
@@ -4160,7 +4307,9 @@ async def send_voice(
self.token, chat_id, voice, caption, duration, reply_markup,
parse_mode, disable_notification, timeout, caption_entities,
protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id,
- allow_paid_broadcast=allow_paid_broadcast))
+ allow_paid_broadcast=allow_paid_broadcast, direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters
+ )
+ )
async def send_document(
self, chat_id: Union[int, str], document: Union[Any, str],
@@ -4182,7 +4331,9 @@ async def send_document(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send general files.
@@ -4255,6 +4406,15 @@ async def send_document(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -4303,7 +4463,10 @@ async def send_document(
disable_notification = disable_notification, timeout = timeout, caption = caption, thumbnail= thumbnail,
caption_entities = caption_entities,
disable_content_type_detection = disable_content_type_detection, visible_file_name = visible_file_name, protect_content = protect_content,
- message_thread_id = message_thread_id, reply_parameters=reply_parameters, business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast))
+ message_thread_id = message_thread_id, reply_parameters=reply_parameters, business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters
+ )
+ )
async def send_sticker(
self, chat_id: Union[int, str], sticker: Union[Any, str],
@@ -4319,7 +4482,9 @@ async def send_sticker(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers.
On success, the sent Message is returned.
@@ -4375,6 +4540,15 @@ async def send_sticker(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -4413,7 +4587,10 @@ async def send_sticker(
reply_markup=reply_markup,
disable_notification=disable_notification, timeout=timeout,
protect_content=protect_content,
- message_thread_id=message_thread_id, emoji=emoji, reply_parameters=reply_parameters, business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast))
+ message_thread_id=message_thread_id, emoji=emoji, reply_parameters=reply_parameters, business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast,
+ suggested_post_parameters=suggested_post_parameters, direct_messages_topic_id=direct_messages_topic_id
+ )
+ )
async def send_video(
self, chat_id: Union[int, str], video: Union[Any, str],
@@ -4441,7 +4618,9 @@ async def send_video(
show_caption_above_media: Optional[bool]=None,
allow_paid_broadcast: Optional[bool]=None,
cover: Optional[Union[Any, str]]=None,
- start_timestamp: Optional[int]=None) -> types.Message:
+ start_timestamp: Optional[int]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
@@ -4533,6 +4712,14 @@ async def send_video(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of a topic in a forum supergroup or channel, in which the message will be sent
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -4575,7 +4762,8 @@ async def send_video(
self.token, chat_id, video, duration, caption, reply_markup,
parse_mode, supports_streaming, disable_notification, timeout, thumbnail, width, height,
caption_entities, protect_content, message_thread_id, has_spoiler, reply_parameters, business_connection_id, message_effect_id=message_effect_id,
- show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast, cover=cover, start_timestamp=start_timestamp))
+ show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast, cover=cover, start_timestamp=start_timestamp,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters))
async def send_animation(
self, chat_id: Union[int, str], animation: Union[Any, str],
@@ -4599,7 +4787,9 @@ async def send_animation(
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
show_caption_above_media: Optional[bool]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound).
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.
@@ -4682,6 +4872,15 @@ async def send_animation(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -4719,7 +4918,8 @@ async def send_animation(
self.token, chat_id, animation, duration, caption,
reply_markup, parse_mode, disable_notification, timeout, thumbnail,
caption_entities, width, height, protect_content, message_thread_id, has_spoiler, reply_parameters, business_connection_id,
- message_effect_id=message_effect_id, show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast))
+ message_effect_id=message_effect_id, show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters))
async def send_video_note(
self, chat_id: Union[int, str], data: Union[Any, str],
@@ -4737,7 +4937,9 @@ async def send_video_note(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long.
Use this method to send video messages. On success, the sent Message is returned.
@@ -4802,6 +5004,15 @@ async def send_video_note(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -4837,7 +5048,10 @@ async def send_video_note(
await asyncio_helper.send_video_note(
self.token, chat_id, data, duration, length, reply_markup,
disable_notification, timeout, thumbnail, protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id,
- allow_paid_broadcast=allow_paid_broadcast))
+ allow_paid_broadcast=allow_paid_broadcast, direct_messages_topic_id=direct_messages_topic_id,
+ suggested_post_parameters=suggested_post_parameters
+ )
+ )
async def send_paid_media(
self, chat_id: Union[int, str], star_count: int, media: List[types.InputPaidMedia],
@@ -4845,7 +5059,9 @@ async def send_paid_media(
show_caption_above_media: Optional[bool]=None, disable_notification: Optional[bool]=None,
protect_content: Optional[bool]=None, reply_parameters: Optional[types.ReplyParameters]=None,
reply_markup: Optional[REPLY_MARKUP_TYPES]=None, business_connection_id: Optional[str]=None,
- payload: Optional[str]=None, allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ payload: Optional[str]=None, allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send paid media to channel chats. On success, the sent Message is returned.
@@ -4894,6 +5110,15 @@ async def send_paid_media(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -4903,7 +5128,10 @@ async def send_paid_media(
caption_entities=caption_entities, show_caption_above_media=show_caption_above_media,
disable_notification=disable_notification, protect_content=protect_content,
reply_parameters=reply_parameters, reply_markup=reply_markup, business_connection_id=business_connection_id,
- payload=payload, allow_paid_broadcast=allow_paid_broadcast))
+ payload=payload, allow_paid_broadcast=allow_paid_broadcast, direct_messages_topic_id=direct_messages_topic_id,
+ suggested_post_parameters=suggested_post_parameters
+ )
+ )
async def send_media_group(
self, chat_id: Union[int, str],
@@ -4919,7 +5147,9 @@ async def send_media_group(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> List[types.Message]:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> List[types.Message]:
"""
Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files
can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned.
@@ -4963,6 +5193,15 @@ async def send_media_group(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, an array of Messages that were sent is returned.
:rtype: List[types.Message]
"""
@@ -4997,7 +5236,8 @@ async def send_media_group(
result = await asyncio_helper.send_media_group(
self.token, chat_id, media, disable_notification, timeout, protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id,
- allow_paid_broadcast=allow_paid_broadcast)
+ allow_paid_broadcast=allow_paid_broadcast, direct_messages_topic_id=direct_messages_topic_id,
+ suggested_post_parameters=suggested_post_parameters)
return [types.Message.de_json(msg) for msg in result]
async def send_location(
@@ -5017,7 +5257,9 @@ async def send_location(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send point on the map. On success, the sent Message is returned.
@@ -5080,6 +5322,15 @@ async def send_location(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -5112,7 +5363,10 @@ async def send_location(
self.token, chat_id, latitude, longitude, live_period,
reply_markup, disable_notification, timeout,
horizontal_accuracy, heading, proximity_alert_radius,
- protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast))
+ protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters
+ )
+ )
async def edit_message_live_location(
self, latitude: float, longitude: float,
@@ -5238,7 +5492,9 @@ async def send_venue(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send information about a venue. On success, the sent Message is returned.
@@ -5308,6 +5564,15 @@ async def send_venue(
:param allow_paid_broadcast: Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
@@ -5341,7 +5606,8 @@ async def send_venue(
self.token, chat_id, latitude, longitude, title, address, foursquare_id, foursquare_type,
disable_notification, reply_markup, timeout,
google_place_id, google_place_type, protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id,
- allow_paid_broadcast=allow_paid_broadcast))
+ allow_paid_broadcast=allow_paid_broadcast, direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters)
+ )
async def send_contact(
@@ -5358,7 +5624,9 @@ async def send_contact(
reply_parameters: Optional[types.ReplyParameters]=None,
business_connection_id: Optional[str]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Use this method to send phone contacts. On success, the sent Message is returned.
@@ -5416,6 +5684,15 @@ async def send_contact(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message`
"""
@@ -5447,7 +5724,9 @@ async def send_contact(
await asyncio_helper.send_contact(
self.token, chat_id, phone_number, first_name, last_name, vcard,
disable_notification, reply_markup, timeout,
- protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast))
+ protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters)
+ )
async def send_chat_action(
@@ -5660,7 +5939,8 @@ async def promote_chat_member(
can_manage_topics: Optional[bool]=None,
can_post_stories: Optional[bool]=None,
can_edit_stories: Optional[bool]=None,
- can_delete_stories: Optional[bool]=None) -> bool:
+ can_delete_stories: Optional[bool]=None,
+ can_manage_direct_messages: Optional[bool]=None) -> bool:
"""
Use this method to promote or demote a user in 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.
@@ -5730,6 +6010,10 @@ async def promote_chat_member(
:param can_delete_stories: Pass True if the administrator can delete the channel's stories
:type can_delete_stories: :obj:`bool`
+ :param can_manage_direct_messages: Pass True if the administrator can manage direct messages
+ within the channel and decline suggested posts; for channels only
+ :type can_manage_direct_messages: :obj:`bool`
+
:return: True on success.
:rtype: :obj:`bool`
"""
@@ -5744,7 +6028,8 @@ async def promote_chat_member(
can_edit_messages, can_delete_messages, can_invite_users,
can_restrict_members, can_pin_messages, can_promote_members,
is_anonymous, can_manage_chat, can_manage_video_chats, can_manage_topics,
- can_post_stories, can_edit_stories, can_delete_stories)
+ can_post_stories, can_edit_stories, can_delete_stories, can_manage_direct_messages=can_manage_direct_messages
+ )
async def set_chat_administrator_custom_title(
self, chat_id: Union[int, str], user_id: int, custom_title: str) -> bool:
@@ -6827,7 +7112,9 @@ async def send_invoice(
message_thread_id: Optional[int]=None,
reply_parameters: Optional[types.ReplyParameters]=None,
message_effect_id: Optional[str]=None,
- allow_paid_broadcast: Optional[bool]=None) -> types.Message:
+ allow_paid_broadcast: Optional[bool]=None,
+ direct_messages_topic_id: Optional[int]=None,
+ suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message:
"""
Sends invoice.
@@ -6940,6 +7227,15 @@ async def send_invoice(
of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
:type allow_paid_broadcast: :obj:`bool`
+ :param direct_messages_topic_id: Identifier of the direct messages topic to which the message will be sent;
+ required if the message is sent to a direct messages chat
+ :type direct_messages_topic_id: :obj:`int`
+
+ :param suggested_post_parameters: A JSON-serialized object containing the parameters of the suggested post to send;
+ for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post
+ is automatically declined.
+ :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters`
+
:return: On success, the sent Message is returned.
:rtype: :obj:`types.Message`
"""
@@ -6974,7 +7270,9 @@ async def send_invoice(
send_phone_number_to_provider, send_email_to_provider, is_flexible, disable_notification,
reply_markup, provider_data, timeout,
max_tip_amount, suggested_tip_amounts, protect_content, message_thread_id, reply_parameters,
- message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)
+ message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast,
+ direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters
+ )
return types.Message.de_json(result)
diff --git a/telebot/asyncio_helper.py b/telebot/asyncio_helper.py
index bc50068f6..f127f316f 100644
--- a/telebot/asyncio_helper.py
+++ b/telebot/asyncio_helper.py
@@ -284,7 +284,7 @@ async def send_message(
parse_mode=None, disable_notification=None, timeout=None,
entities=None, protect_content=None,
message_thread_id=None, reply_parameters=None, link_preview_options=None, business_connection_id=None, message_effect_id=None,
- allow_paid_broadcast=None):
+ allow_paid_broadcast=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_name = 'sendMessage'
params = {'chat_id': str(chat_id), 'text': text}
if link_preview_options is not None:
@@ -311,6 +311,10 @@ async def send_message(
params['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
params['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ params['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ params['suggested_post_parameters'] = suggested_post_parameters.to_json()
return await _process_request(token, method_name, params=params, method='post')
@@ -429,7 +433,8 @@ async def get_chat_member(token, chat_id, user_id):
async def forward_message(
token, chat_id, from_chat_id, message_id,
disable_notification=None, timeout=None, protect_content=None,
- message_thread_id=None, video_start_timestamp=None):
+ message_thread_id=None, video_start_timestamp=None, direct_messages_topic_id=None,
+ suggested_post_parameters=None):
method_url = r'forwardMessage'
payload = {'chat_id': chat_id, 'from_chat_id': from_chat_id, 'message_id': message_id}
if disable_notification is not None:
@@ -442,13 +447,17 @@ async def forward_message(
payload['message_thread_id'] = message_thread_id
if video_start_timestamp:
payload['video_start_timestamp'] = video_start_timestamp
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return await _process_request(token, method_url, params=payload)
async def copy_message(token, chat_id, from_chat_id, message_id, caption=None, parse_mode=None, caption_entities=None,
disable_notification=None,
reply_markup=None, timeout=None, protect_content=None, message_thread_id=None, reply_parameters=None, show_caption_above_media=None,
- allow_paid_broadcast=None, video_start_timestamp=None):
+ allow_paid_broadcast=None, video_start_timestamp=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'copyMessage'
payload = {'chat_id': chat_id, 'from_chat_id': from_chat_id, 'message_id': message_id}
if caption is not None:
@@ -475,6 +484,10 @@ async def copy_message(token, chat_id, from_chat_id, message_id, caption=None, p
payload['allow_paid_broadcast'] = allow_paid_broadcast
if video_start_timestamp:
payload['video_start_timestamp'] = video_start_timestamp
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return await _process_request(token, method_url, params=payload)
async def send_checklist(
@@ -511,7 +524,8 @@ async def send_dice(
token, chat_id,
emoji=None, disable_notification=None,
reply_markup=None, timeout=None, protect_content=None,
- message_thread_id=None,reply_parameters=None, business_connection_id=None, message_effect_id=None, allow_paid_broadcast=None):
+ message_thread_id=None,reply_parameters=None, business_connection_id=None, message_effect_id=None, allow_paid_broadcast=None,
+ direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendDice'
payload = {'chat_id': chat_id}
if emoji:
@@ -534,6 +548,10 @@ async def send_dice(
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return await _process_request(token, method_url, params=payload)
@@ -543,7 +561,8 @@ async def send_photo(
parse_mode=None, disable_notification=None, timeout=None,
caption_entities=None, protect_content=None,
message_thread_id=None, has_spoiler=None,reply_parameters=None,
- business_connection_id=None, message_effect_id=None, show_caption_above_media=None, allow_paid_broadcast=None):
+ business_connection_id=None, message_effect_id=None, show_caption_above_media=None, allow_paid_broadcast=None,
+ direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendPhoto'
payload = {'chat_id': chat_id}
files = None
@@ -581,13 +600,18 @@ async def send_photo(
payload['show_caption_above_media'] = show_caption_above_media
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return await _process_request(token, method_url, params=payload, files=files, method='post')
async def send_paid_media(
token, chat_id, star_count, media,
caption=None, parse_mode=None, caption_entities=None, show_caption_above_media=None,
disable_notification=None, protect_content=None, reply_parameters=None, reply_markup=None,
- business_connection_id=None, payload=None, allow_paid_broadcast=None):
+ business_connection_id=None, payload=None, allow_paid_broadcast=None, direct_messages_topic_id=None,
+ suggested_post_parameters=None):
method_url = r'sendPaidMedia'
media_json, files = convert_input_media_array(media)
_payload = {'chat_id': chat_id, 'star_count': star_count, 'media': media_json}
@@ -614,6 +638,10 @@ async def send_paid_media(
_payload['payload'] = payload
if allow_paid_broadcast is not None:
_payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ _payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ _payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return await _process_request(
token, method_url, params=_payload,
@@ -624,7 +652,7 @@ async def send_media_group(
token, chat_id, media,
disable_notification=None,
timeout=None, protect_content=None, message_thread_id=None,reply_parameters=None, business_connection_id=None, message_effect_id=None,
- allow_paid_broadcast=None):
+ allow_paid_broadcast=None, direct_messages_topic_id=None):
method_url = r'sendMediaGroup'
media_json, files = await convert_input_media_array(media)
payload = {'chat_id': chat_id, 'media': media_json}
@@ -644,6 +672,8 @@ async def send_media_group(
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
return await _process_request(
token, method_url, params=payload,
method='post' if files else 'get',
@@ -656,7 +686,7 @@ async def send_location(
reply_markup=None, disable_notification=None,
timeout=None, horizontal_accuracy=None, heading=None,
proximity_alert_radius=None, protect_content=None, message_thread_id=None,reply_parameters=None, business_connection_id=None,
- message_effect_id=None, allow_paid_broadcast=None):
+ message_effect_id=None, allow_paid_broadcast=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendLocation'
payload = {'chat_id': chat_id, 'latitude': latitude, 'longitude': longitude}
if live_period:
@@ -685,6 +715,10 @@ async def send_location(
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return await _process_request(token, method_url, params=payload)
@@ -742,7 +776,7 @@ async def send_venue(
reply_markup=None, timeout=None,
google_place_id=None,
google_place_type=None, protect_content=None, message_thread_id=None,reply_parameters=None, business_connection_id=None,
- message_effect_id=None, allow_paid_broadcast=None):
+ message_effect_id=None, allow_paid_broadcast=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendVenue'
payload = {'chat_id': chat_id, 'latitude': latitude, 'longitude': longitude, 'title': title, 'address': address}
if foursquare_id:
@@ -771,6 +805,10 @@ async def send_venue(
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return await _process_request(token, method_url, params=payload)
@@ -778,7 +816,7 @@ async def send_contact(
token, chat_id, phone_number, first_name, last_name=None, vcard=None,
disable_notification=None, reply_markup=None, timeout=None,
protect_content=None, message_thread_id=None,reply_parameters=None, business_connection_id=None, message_effect_id=None,
- allow_paid_broadcast=None):
+ allow_paid_broadcast=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendContact'
payload = {'chat_id': chat_id, 'phone_number': phone_number, 'first_name': first_name}
if last_name:
@@ -803,6 +841,10 @@ async def send_contact(
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return await _process_request(token, method_url, params=payload)
@@ -822,7 +864,8 @@ async def send_video(token, chat_id, data, duration=None, caption=None, reply_m
parse_mode=None, supports_streaming=None, disable_notification=None, timeout=None,
thumbnail=None, width=None, height=None, caption_entities=None,
protect_content=None, message_thread_id=None, has_spoiler=None,reply_parameters=None, business_connection_id=None,
- message_effect_id=None, show_caption_above_media=None, allow_paid_broadcast=None, cover=None, start_timestamp=None):
+ message_effect_id=None, show_caption_above_media=None, allow_paid_broadcast=None, cover=None, start_timestamp=None,
+ direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendVideo'
payload = {'chat_id': chat_id}
files = None
@@ -884,6 +927,10 @@ async def send_video(token, chat_id, data, duration=None, caption=None, reply_m
payload['cover'] = cover
if start_timestamp:
payload['start_timestamp'] = start_timestamp
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return await _process_request(token, method_url, params=payload, files=files, method='post')
@@ -892,7 +939,7 @@ async def send_animation(
parse_mode=None, disable_notification=None, timeout=None, thumbnail=None, caption_entities=None,
width=None, height=None, protect_content=None, message_thread_id=None,
has_spoiler=None,reply_parameters=None, business_connection_id=None, message_effect_id=None, show_caption_above_media=None,
- allow_paid_broadcast=None):
+ allow_paid_broadcast=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendAnimation'
payload = {'chat_id': chat_id}
files = None
@@ -942,13 +989,17 @@ async def send_animation(
payload['show_caption_above_media'] = show_caption_above_media
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return await _process_request(token, method_url, params=payload, files=files, method='post')
async def send_voice(token, chat_id, voice, caption=None, duration=None, reply_markup=None,
parse_mode=None, disable_notification=None, timeout=None, caption_entities=None,
protect_content=None, message_thread_id=None,reply_parameters=None,business_connection_id=None, message_effect_id=None,
- allow_paid_broadcast=None):
+ allow_paid_broadcast=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendVoice'
payload = {'chat_id': chat_id}
files = None
@@ -982,12 +1033,17 @@ async def send_voice(token, chat_id, voice, caption=None, duration=None, reply_
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return await _process_request(token, method_url, params=payload, files=files, method='post')
async def send_video_note(token, chat_id, data, duration=None, length=None, reply_markup=None,
disable_notification=None, timeout=None, thumbnail=None, protect_content=None,
- message_thread_id=None,reply_parameters=None, business_connection_id=None, message_effect_id=None, allow_paid_broadcast=None):
+ message_thread_id=None,reply_parameters=None, business_connection_id=None, message_effect_id=None, allow_paid_broadcast=None,
+ direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendVideoNote'
payload = {'chat_id': chat_id}
files = None
@@ -1027,13 +1083,17 @@ async def send_video_note(token, chat_id, data, duration=None, length=None, rep
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return await _process_request(token, method_url, params=payload, files=files, method='post')
async def send_audio(token, chat_id, audio, caption=None, duration=None, performer=None, title=None,
reply_markup=None, parse_mode=None, disable_notification=None, timeout=None, thumbnail=None,
caption_entities=None, protect_content=None, message_thread_id=None,reply_parameters=None, business_connection_id=None,
- message_effect_id=None, allow_paid_broadcast=None):
+ message_effect_id=None, allow_paid_broadcast=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = r'sendAudio'
payload = {'chat_id': chat_id}
files = None
@@ -1079,6 +1139,10 @@ async def send_audio(token, chat_id, audio, caption=None, duration=None, perform
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return await _process_request(token, method_url, params=payload, files=files, method='post')
@@ -1086,7 +1150,7 @@ async def send_data(token, chat_id, data, data_type, reply_markup=None, parse_m
disable_notification=None, timeout=None, caption=None, thumbnail=None, caption_entities=None,
disable_content_type_detection=None, visible_file_name=None, protect_content=None,
message_thread_id=None, emoji=None,reply_parameters=None, business_connection_id=None, message_effect_id=None,
- allow_paid_broadcast=None):
+ allow_paid_broadcast=None, direct_messages_topic_id=None, suggested_post_parameters=None):
method_url = await get_method_by_type(data_type)
payload = {'chat_id': chat_id}
files = None
@@ -1133,6 +1197,10 @@ async def send_data(token, chat_id, data, data_type, reply_markup=None, parse_m
payload['message_effect_id'] = message_effect_id
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return await _process_request(token, method_url, params=payload, files=files, method='post')
@@ -1184,7 +1252,8 @@ async def promote_chat_member(
can_edit_messages=None, can_delete_messages=None, can_invite_users=None,
can_restrict_members=None, can_pin_messages=None, can_promote_members=None,
is_anonymous=None, can_manage_chat=None, can_manage_video_chats=None, can_manage_topics=None,
- can_post_stories=None, can_edit_stories=None, can_delete_stories=None):
+ can_post_stories=None, can_edit_stories=None, can_delete_stories=None,
+ can_manage_direct_messages=None):
method_url = 'promoteChatMember'
payload = {'chat_id': chat_id, 'user_id': user_id}
if can_change_info is not None:
@@ -1217,6 +1286,8 @@ async def promote_chat_member(
payload['can_edit_stories'] = can_edit_stories
if can_delete_stories is not None:
payload['can_delete_stories'] = can_delete_stories
+ if can_manage_direct_messages is not None:
+ payload['can_manage_direct_messages'] = can_manage_direct_messages
return await _process_request(token, method_url, params=payload, method='post')
@@ -1618,6 +1689,21 @@ async def edit_message_reply_markup(
payload['timeout'] = timeout
return await _process_request(token, method_url, params=payload, method='post')
+
+async def approve_suggested_post(token, chat_id, message_id, send_date=None):
+ method_url = r'approveSuggestedPost'
+ payload = {'chat_id': chat_id, 'message_id': message_id}
+ if send_date is not None:
+ payload['send_date'] = send_date
+ return await _process_request(token, method_url, params=payload, method='post')
+
+
+async def decline_suggested_post(token, chat_id, message_id, comment=None):
+ method_url = r'declineSuggestedPost'
+ payload = {'chat_id': chat_id, 'message_id': message_id}
+ if comment is not None:
+ payload['comment'] = comment
+ return await _process_request(token, method_url, params=payload, method='post')
async def delete_message(token, chat_id, message_id, timeout=None):
method_url = r'deleteMessage'
@@ -1719,7 +1805,8 @@ async def send_invoice(
send_phone_number_to_provider = None, send_email_to_provider = None, is_flexible=None,
disable_notification=None, reply_markup=None, provider_data=None,
timeout=None, max_tip_amount=None, suggested_tip_amounts=None,
- protect_content=None, message_thread_id=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None):
+ protect_content=None, message_thread_id=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None,
+ direct_messages_topic_id=None, suggested_post_parameters=None):
"""
Use this method to send invoices. On success, the sent Message is returned.
:param token: Bot's token (you don't need to fill this)
@@ -1808,6 +1895,10 @@ async def send_invoice(
payload['provider_token'] = provider_token
if allow_paid_broadcast is not None:
payload['allow_paid_broadcast'] = allow_paid_broadcast
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
+ if suggested_post_parameters is not None:
+ payload['suggested_post_parameters'] = suggested_post_parameters.to_json()
return await _process_request(token, method_url, params=payload)
@@ -2428,7 +2519,7 @@ async def delete_messages(token, chat_id, message_ids):
return await _process_request(token, method_url, params=payload)
async def forward_messages(token, chat_id, from_chat_id, message_ids, disable_notification=None,
- message_thread_id=None, protect_content=None):
+ message_thread_id=None, protect_content=None, direct_messages_topic_id=None):
method_url = 'forwardMessages'
payload = {
'chat_id': chat_id,
@@ -2441,12 +2532,14 @@ async def forward_messages(token, chat_id, from_chat_id, message_ids, disable_no
payload['message_thread_id'] = message_thread_id
if protect_content is not None:
payload['protect_content'] = protect_content
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
result = await _process_request(token, method_url, params=payload)
return result
async def copy_messages(token, chat_id, from_chat_id, message_ids, disable_notification=None,
- message_thread_id=None, protect_content=None, remove_caption=None):
+ message_thread_id=None, protect_content=None, remove_caption=None, direct_messages_topic_id=None):
method_url = 'copyMessages'
payload = {
'chat_id': chat_id,
@@ -2461,6 +2554,8 @@ async def copy_messages(token, chat_id, from_chat_id, message_ids, disable_notif
payload['protect_content'] = protect_content
if remove_caption is not None:
payload['remove_caption'] = remove_caption
+ if direct_messages_topic_id is not None:
+ payload['direct_messages_topic_id'] = direct_messages_topic_id
result = await _process_request(token, method_url, params=payload)
return result
diff --git a/telebot/types.py b/telebot/types.py
index a707b72ba..3f01fec54 100644
--- a/telebot/types.py
+++ b/telebot/types.py
@@ -615,6 +615,9 @@ class ChatFullInfo(JsonDeserializable):
:param is_forum: Optional. True, if the supergroup chat is a forum (has topics enabled)
:type is_forum: :obj:`bool`
+ :param is_direct_messages: Optional. True, if the chat is the direct messages chat of a channel
+ :type is_direct_messages: :obj:`bool`
+
:param max_reaction_count: Optional. The maximum number of reactions that can be set on a message in the chat
:type max_reaction_count: :obj:`int`
@@ -639,6 +642,9 @@ class ChatFullInfo(JsonDeserializable):
:param personal_chat: Optional. For private chats, the personal channel of the user. Returned only in getChat.
:type personal_chat: :class:`telebot.types.Chat`
+ :param parent_chat: Optional. Information about the corresponding channel chat; for direct messages chats only
+ :type parent_chat: :class:`telebot.types.Chat`
+
:param available_reactions: Optional. List of available chat reactions; for private chats, supergroups and channels. Returned only in getChat.
:type available_reactions: :obj:`list` of :class:`telebot.types.ReactionType`
@@ -767,6 +773,8 @@ def de_json(cls, json_string):
obj['birthdate'] = Birthdate.de_json(obj['birthdate'])
if 'accepted_gift_types' in obj:
obj['accepted_gift_types'] = AcceptedGiftTypes.de_json(obj['accepted_gift_types'])
+ if 'parent_chat' in obj:
+ obj['parent_chat'] = Chat.de_json(obj['parent_chat'])
return cls(**obj)
def __init__(self, id, type, title=None, username=None, first_name=None,
@@ -783,7 +791,7 @@ def __init__(self, id, type, title=None, username=None, first_name=None,
unrestrict_boost_count=None, custom_emoji_sticker_set_name=None, business_intro=None, business_location=None,
business_opening_hours=None, personal_chat=None, birthdate=None,
can_send_paid_media=None,
- accepted_gift_types=None, **kwargs):
+ accepted_gift_types=None, is_direct_messages=None, parent_chat=None, **kwargs):
self.id: int = id
self.type: str = type
self.title: Optional[str] = title
@@ -829,6 +837,8 @@ def __init__(self, id, type, title=None, username=None, first_name=None,
self.birthdate: Optional[Birthdate] = birthdate
self.can_send_paid_media: Optional[bool] = can_send_paid_media
self.accepted_gift_types: AcceptedGiftTypes = accepted_gift_types
+ self.is_direct_messages: Optional[bool] = is_direct_messages
+ self.parent_chat: Optional[Chat] = parent_chat
@property
def can_send_gift(self) -> bool:
"""
@@ -919,6 +929,9 @@ class Message(JsonDeserializable):
:param message_thread_id: Optional. Unique identifier of a message thread to which the message belongs; for supergroups only
:type message_thread_id: :obj:`int`
+ :param direct_messages_topic: Optional. Information about the direct messages chat topic that contains the message
+ :type direct_messages_topic: :class:`telebot.types.DirectMessagesTopic`
+
:param from_user: Optional. Sender of the message; empty for messages sent to channels. For backward compatibility, the
field contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.
:type from_user: :class:`telebot.types.User`
@@ -968,6 +981,9 @@ class Message(JsonDeserializable):
:param reply_to_story: Optional. For replies to a story, the original story
:type reply_to_story: :class:`telebot.types.Story`
+ :param reply_to_checklist_task_id: Optional. Identifier of the specific checklist task that is being replied to
+ :type reply_to_checklist_task_id: :obj:`str`
+
:param via_bot: Optional. Bot through which the message was sent
:type via_bot: :class:`telebot.types.User`
@@ -981,6 +997,10 @@ class Message(JsonDeserializable):
as an away or a greeting business message, or as a scheduled message
:type is_from_offline: :obj:`bool`
+ :param is_paid_post: Optional. True, if the message is a paid post. Note that such posts must not be
+ deleted for 24 hours to receive the payment and can't be edited.
+ :type is_paid_post: :obj:`bool`
+
:param media_group_id: Optional. The unique identifier of a media message group this message belongs to
:type media_group_id: :obj:`str`
@@ -1002,6 +1022,10 @@ class Message(JsonDeserializable):
if it is a text message and link preview options were changed
:type link_preview_options: :class:`telebot.types.LinkPreviewOptions`
+ :param suggested_post_info: Optional. Information about suggested post parameters if the message is a suggested post
+ in a channel direct messages chat. If the message is an approved or declined suggested post, then it can't be edited.
+ :type suggested_post_info: :class:`telebot.types.SuggestedPostInfo`
+
:param effect_id: Optional. Unique identifier of the message effect added to the message
:type effect_id: :obj:`str`
@@ -1206,6 +1230,21 @@ class Message(JsonDeserializable):
:param paid_message_price_changed: Optional. Service message: the price for paid messages has changed in the chat
:type paid_message_price_changed: :class:`telebot.types.PaidMessagePriceChanged`
+ :param suggested_post_approved: Optional. Service message: a suggested post was approved
+ :type suggested_post_approved: :class:`telebot.types.SuggestedPostApproved
+
+ :param suggested_post_approval_failed: Optional. Service message: approval of a suggested post has failed
+ :type suggested_post_approval_failed: :class:`telebot.types.SuggestedPost
+
+ :param suggested_post_declined: Optional. Service message: a suggested post was declined
+ :type suggested_post_declined: :class:`telebot.types.SuggestedPostDecl
+
+ :param suggested_post_paid: Optional. Service message: payment for a suggested post was received
+ :type suggested_post_paid: :class:`telebot.types.SuggestedPostPaid`
+
+ :param suggested_post_refunded: Optional. Service message: payment for a suggested post was refunded
+ :type suggested_post_refunded: :class:`telebot.types.SuggestedPostRefunded`
+
:param video_chat_scheduled: Optional. Service message: video chat scheduled
:type video_chat_scheduled: :class:`telebot.types.VideoChatScheduled`
@@ -1484,6 +1523,30 @@ def de_json(cls, json_string):
if 'direct_message_price_changed' in obj:
opts['direct_message_price_changed'] = DirectMessagePriceChanged.de_json(obj['direct_message_price_changed'])
content_type = 'direct_message_price_changed'
+ if 'reply_to_checklist_task_id' in obj:
+ opts['reply_to_checklist_task_id'] = obj['reply_to_checklist_task_id']
+ if 'direct_messages_topic' in obj:
+ opts['direct_messages_topic'] = DirectMessagesTopic.de_json(obj['direct_messages_topic'])
+ if 'is_paid_post' in obj:
+ opts['is_paid_post'] = obj['is_paid_post']
+ if 'suggested_post_info' in obj:
+ opts['suggested_post_info'] = SuggestedPostInfo.de_json(obj['suggested_post_info'])
+ content_type = 'suggested_post_info'
+ if 'suggested_post_approved' in obj:
+ opts['suggested_post_approved'] = SuggestedPostApproved.de_json(obj['suggested_post_approved'])
+ content_type = 'suggested_post_approved'
+ if 'suggested_post_approval_failed' in obj:
+ opts['suggested_post_approval_failed'] = SuggestedPostApprovalFailed.de_json(obj['suggested_post_approval_failed'])
+ content_type = 'suggested_post_approval_failed'
+ if 'suggested_post_declined' in obj:
+ opts['suggested_post_declined'] = SuggestedPostDeclined.de_json(obj['suggested_post_declined'])
+ content_type = 'suggested_post_declined'
+ if 'suggested_post_paid' in obj:
+ opts['suggested_post_paid'] = SuggestedPostPaid.de_json(obj['suggested_post_paid'])
+ content_type = 'suggested_post_paid'
+ if 'suggested_post_refunded' in obj:
+ opts['suggested_post_refunded'] = SuggestedPostRefunded.de_json(obj['suggested_post_refunded'])
+ content_type = 'suggested_post_refunded'
return cls(message_id, from_user, date, chat, content_type, opts, json_string)
@@ -1610,6 +1673,15 @@ def __init__(self, message_id, from_user, date, chat, content_type, options, jso
self.checklist_tasks_done: Optional[ChecklistTasksDone] = None
self.checklist_tasks_added: Optional[List[ChecklistTasksAdded]] = None
self.direct_message_price_changed: Optional[DirectMessagePriceChanged] = None
+ self.reply_to_checklist_task_id: Optional[int] = None
+ self.direct_messages_topic: Optional[DirectMessagesTopic] = None
+ self.is_paid_post: Optional[bool] = None
+ self.suggested_post_info: Optional[SuggestedPostInfo] = None
+ self.suggested_post_approved: Optional[SuggestedPostApproved] = None
+ self.suggested_post_approval_failed: Optional[SuggestedPostApprovalFailed] = None
+ self.suggested_post_declined: Optional[SuggestedPostDeclined] = None
+ self.suggested_post_paid: Optional[SuggestedPostPaid] = None
+ self.suggested_post_refunded: Optional[SuggestedPostRefunded] = None
for key in options:
setattr(self, key, options[key])
@@ -3386,6 +3458,9 @@ class ChatMemberAdministrator(ChatMember):
:param can_manage_topics: Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only
:type can_manage_topics: :obj:`bool`
+ :param can_manage_direct_messages: Optional. True, if the administrator can manage direct messages of the channel and decline suggested posts; for channels only
+ :type can_manage_direct_messages: :obj:`bool`
+
:param custom_title: Optional. Custom title for this user
:type custom_title: :obj:`str`
@@ -3395,7 +3470,7 @@ class ChatMemberAdministrator(ChatMember):
def __init__(self, user, status, can_be_edited, is_anonymous, can_manage_chat, can_delete_messages,
can_manage_video_chats, can_restrict_members, can_promote_members, can_change_info, can_invite_users,
can_post_stories, can_edit_stories, can_delete_stories, can_post_messages=None, can_edit_messages=None,
- can_pin_messages=None, can_manage_topics=None, custom_title=None, **kwargs):
+ can_pin_messages=None, can_manage_topics=None, custom_title=None, can_manage_direct_messages=None, **kwargs):
super().__init__(user, status, **kwargs)
self.can_be_edited: bool = can_be_edited
self.is_anonymous: bool = is_anonymous
@@ -3414,6 +3489,7 @@ def __init__(self, user, status, can_be_edited, is_anonymous, can_manage_chat, c
self.can_pin_messages: Optional[bool] = can_pin_messages
self.can_manage_topics: Optional[bool] = can_manage_topics
self.custom_title: Optional[str] = custom_title
+ self.can_manage_direct_messages: Optional[bool] = can_manage_direct_messages
@property
def can_manage_voice_chats(self):
@@ -7881,6 +7957,9 @@ class ChatAdministratorRights(JsonDeserializable, JsonSerializable, Dictionaryab
:param can_delete_stories: Optional. True, if the administrator can delete stories of other users
:type can_delete_stories: :obj:`bool`
+ :param can_manage_direct_messages: Optional. True, if the administrator can manage direct messages of the channel and decline suggested posts; for channels only
+ :type can_manage_direct_messages: :obj:`bool`
+
:return: Instance of the class
:rtype: :class:`telebot.types.ChatAdministratorRights`
"""
@@ -7897,7 +7976,8 @@ def __init__(self, is_anonymous: bool, can_manage_chat: bool,
can_post_messages: Optional[bool]=None, can_edit_messages: Optional[bool]=None,
can_pin_messages: Optional[bool]=None, can_manage_topics: Optional[bool]=None,
can_post_stories: Optional[bool]=None, can_edit_stories: Optional[bool]=None,
- can_delete_stories: Optional[bool]=None, **kwargs
+ can_delete_stories: Optional[bool]=None, can_manage_direct_messages: Optional[bool]=None,
+ **kwargs
) -> None:
self.is_anonymous: bool = is_anonymous
@@ -7915,6 +7995,7 @@ def __init__(self, is_anonymous: bool, can_manage_chat: bool,
self.can_post_stories: Optional[bool] = can_post_stories
self.can_edit_stories: Optional[bool] = can_edit_stories
self.can_delete_stories: Optional[bool] = can_delete_stories
+ self.can_manage_direct_messages: Optional[bool] = can_manage_direct_messages
def to_dict(self):
json_dict = {
@@ -7941,6 +8022,8 @@ def to_dict(self):
json_dict['can_edit_stories'] = self.can_edit_stories
if self.can_delete_stories is not None:
json_dict['can_delete_stories'] = self.can_delete_stories
+ if self.can_manage_direct_messages is not None:
+ json_dict['can_manage_direct_messages'] = self.can_manage_direct_messages
return json_dict
@@ -9390,6 +9473,9 @@ class ReplyParameters(JsonDeserializable, Dictionaryable, JsonSerializable):
:param quote_position: Optional. Position of the quote in the original message in UTF-16 code units
:type quote_position: :obj:`int`
+ :param checklist_task_id: Optional. Optional. Identifier of the specific checklist task to be replied to
+ :type checklist_task_id: :obj:`int`
+
:return: Instance of the class
:rtype: :class:`ReplyParameters`
"""
@@ -9405,7 +9491,7 @@ def de_json(cls, json_string):
def __init__(self, message_id: int, chat_id: Optional[Union[int, str]] = None,
allow_sending_without_reply: Optional[bool] = None, quote: Optional[str] = None,
quote_parse_mode: Optional[str] = None, quote_entities: Optional[List[MessageEntity]] = None,
- quote_position: Optional[int] = None, **kwargs) -> None:
+ quote_position: Optional[int] = None, checklist_task_id: Optional[int] = None, **kwargs) -> None:
self.message_id: int = message_id
self.chat_id: Optional[Union[int, str]] = chat_id
self.allow_sending_without_reply: Optional[bool] = allow_sending_without_reply
@@ -9413,6 +9499,7 @@ def __init__(self, message_id: int, chat_id: Optional[Union[int, str]] = None,
self.quote_parse_mode: Optional[str] = quote_parse_mode
self.quote_entities: Optional[List[MessageEntity]] = quote_entities
self.quote_position: Optional[int] = quote_position
+ self.checklist_task_id: Optional[int] = checklist_task_id
def to_dict(self) -> dict:
json_dict = {
@@ -9430,6 +9517,8 @@ def to_dict(self) -> dict:
json_dict['quote_entities'] = [entity.to_dict() for entity in self.quote_entities]
if self.quote_position is not None:
json_dict['quote_position'] = self.quote_position
+ if self.checklist_task_id is not None:
+ json_dict['checklist_task_id'] = self.checklist_task_id
return json_dict
def to_json(self) -> str:
@@ -11260,23 +11349,30 @@ class Gift(JsonDeserializable):
:param remaining_count: Optional. The number of remaining gifts of this type that can be sent; for limited gifts only
:type remaining_count: :obj:`int`
+ :param publisher_chat: Optional. Information about the chat that published the gift
+ :type publisher_chat: :class:`Chat`
+
:return: Instance of the class
:rtype: :class:`Gift`
"""
- def __init__(self, id, sticker, star_count, total_count=None, remaining_count=None, upgrade_star_count=None, **kwargs):
+ def __init__(self, id, sticker, star_count, total_count=None, remaining_count=None, upgrade_star_count=None,
+ publisher_chat=None, **kwargs):
self.id: str = id
self.sticker: Sticker = sticker
self.star_count: int = star_count
self.total_count: Optional[int] = total_count
self.remaining_count: Optional[int] = remaining_count
self.upgrade_star_count: Optional[int] = upgrade_star_count
+ self.publisher_chat: Optional[Chat] = publisher_chat
@classmethod
def de_json(cls, json_string):
if json_string is None: return None
obj = cls.check_json(json_string)
obj['sticker'] = Sticker.de_json(obj['sticker'])
+ if 'publisher_chat' in obj:
+ obj['publisher_chat'] = Chat.de_json(obj['publisher_chat'])
return cls(**obj)
@@ -11786,16 +11882,20 @@ class UniqueGift(JsonDeserializable):
:param backdrop: Backdrop of the gift
:type backdrop: :class:`UniqueGiftBackdrop`
+ :param publisher_chat: Optional. Information about the chat that published the gift
+ :type publisher_chat: :class:`Chat`
+
:return: Instance of the class
:rtype: :class:`UniqueGift`
"""
- def __init__(self, base_name, name, number, model, symbol, backdrop, **kwargs):
+ def __init__(self, base_name, name, number, model, symbol, backdrop, publisher_chat=None, **kwargs):
self.base_name: str = base_name
self.name: str = name
self.number: int = number
self.model: UniqueGiftModel = model
self.symbol: UniqueGiftSymbol = symbol
self.backdrop: UniqueGiftBackdrop = backdrop
+ self.publisher_chat: Optional[Chat] = publisher_chat
@classmethod
def de_json(cls, json_string):
@@ -11804,6 +11904,8 @@ def de_json(cls, json_string):
obj['model'] = UniqueGiftModel.de_json(obj['model'])
obj['symbol'] = UniqueGiftSymbol.de_json(obj['symbol'])
obj['backdrop'] = UniqueGiftBackdrop.de_json(obj['backdrop'])
+ if 'publisher_chat' in obj:
+ obj['publisher_chat'] = Chat.de_json(obj['publisher_chat'])
return cls(**obj)
@@ -12853,3 +12955,293 @@ def de_json(cls, json_string):
if json_string is None: return None
obj = cls.check_json(json_string)
return cls(**obj)
+
+
+class DirectMessagesTopic(JsonDeserializable):
+ """
+ Describes a topic of a direct messages chat.
+
+ Telegram documentation: https://core.telegram.org/bots/api#directmessagestopic
+
+ :param topic_id: Unique identifier of the topic
+ :type topic_id: :obj:`int`
+
+ :param user: Optional. Information about the user that created the topic. Currently, it is always present
+ :type user: :class:`User`
+
+ :return: Instance of the class
+ :rtype: :class:`DirectMessagesTopic`
+ """
+ def __init__(self, topic_id: int, user: Optional[User] = None, **kwargs):
+ self.topic_id: int = topic_id
+ self.user: Optional[User] = user # for future compatibility, currently always present
+
+ @classmethod
+ def de_json(cls, json_string):
+ if json_string is None: return None
+ obj = cls.check_json(json_string)
+ if 'user' in obj:
+ obj['user'] = User.de_json(obj['user'])
+ return cls(**obj)
+
+
+class SuggestedPostPrice(JsonSerializable, JsonDeserializable):
+ """
+ Describes the price of a suggested post.
+
+ Telegram documentation: https://core.telegram.org/bots/api#suggestedpostprice
+
+ :param currency: Currency in which the post will be paid. Currently, must be one of “XTR” for Telegram Stars or “TON” for toncoins
+ :type currency: :obj:`str`
+
+ :param amount: The amount of the currency that will be paid for the post in the smallest units of the currency, i.e. Telegram Stars or nanotoncoins. Currently, price in Telegram Stars must be between 5 and 100000, and price in nanotoncoins must be between 10000000 and 10000000000000.
+ :type amount: :obj:`int`
+
+ :return: Instance of the class
+ :rtype: :class:`SuggestedPostPrice`
+ """
+ def __init__(self, currency: str, amount: int, **kwargs):
+ self.currency: str = currency
+ self.amount: int = amount
+
+ def to_json(self):
+ return json.dumps(self.to_dict())
+
+ def to_dict(self):
+ data = {
+ 'currency': self.currency,
+ 'amount': self.amount
+ }
+ return data
+
+ @classmethod
+ def de_json(cls, json_string):
+ if json_string is None: return None
+ obj = cls.check_json(json_string)
+ return cls(**obj)
+
+
+class SuggestedPostParameters(JsonSerializable):
+ """
+ Contains parameters of a post that is being suggested by the bot.
+
+ Telegram documentation: https://core.telegram.org/bots/api#suggestedpostparameters
+
+ :param price: Optional. Proposed price for the post. If the field is omitted, then the post is unpaid.
+ :type price: :class:`SuggestedPostPrice`
+
+ :param send_date: Optional. Proposed send date of the post. If specified, then the date must be between 300 second and 2678400 seconds (30 days) in the future. If the field is omitted, then the post can be published at any time within 30 days at the sole discretion of the user who approves it.
+ :type send_date: :obj:`int`
+
+ :return: Instance of the class
+ :rtype: :class:`SuggestedPostParameters`
+ """
+ def __init__(self, price: Optional[SuggestedPostPrice] = None, send_date: Optional[int] = None, **kwargs):
+ self.price: Optional[SuggestedPostPrice] = price
+ self.send_date: Optional[int] = send_date
+
+ def to_json(self):
+ return json.dumps(self.to_dict())
+
+ def to_dict(self):
+ data = {}
+ if self.price is not None:
+ data['price'] = self.price.to_dict()
+ if self.send_date is not None:
+ data['send_date'] = self.send_date
+ return data
+
+
+class SuggestedPostInfo(JsonDeserializable):
+ """
+ Contains information about a suggested post.
+
+ Telegram documentation: https://core.telegram.org/bots/api#suggestedpostinfo
+
+ :param state: State of the suggested post. Currently, it can be one of “pending”, “approved”, “declined”.
+ :type state: :obj:`str`
+
+ :param price: Optional. Proposed price of the post. If the field is omitted, then the post is unpaid.
+ :type price: :class:`SuggestedPostPrice`
+
+ :param send_date: Optional. Proposed send date of the post. If the field is omitted, then the post can be published at any time within 30 days at the sole discretion of the user or administrator who approves it.
+ :type send_date: :obj:`int`
+
+ :return: Instance of the class
+ :rtype: :class:`SuggestedPostInfo`
+ """
+ def __init__(self, state: str, price: Optional[SuggestedPostPrice]
+ = None, send_date: Optional[int] = None, **kwargs):
+ self.state: str = state
+ self.price: Optional[SuggestedPostPrice] = price
+ self.send_date: Optional[int] = send_date
+
+ @classmethod
+ def de_json(cls, json_string):
+ if json_string is None: return None
+ obj = cls.check_json(json_string)
+ if 'price' in obj:
+ obj['price'] = SuggestedPostPrice.de_json(obj['price'])
+ return cls(**obj)
+
+
+class SuggestedPostApproved(JsonDeserializable):
+ """
+ Describes a service message about the approval of a suggested post.
+
+ Telegram documentation: https://core.telegram.org/bots/api#suggestedpostapproved
+
+ :param suggested_post_message: Optional. Message containing the suggested post. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply.
+ :type suggested_post_message: :class:`Message`
+
+ :param price: Optional. Amount paid for the post
+ :type price: :class:`SuggestedPostPrice`
+
+ :param send_date: Date when the post will be published
+ :type send_date: :obj:`int`
+
+ :return: Instance of the class
+ :rtype: :class:`SuggestedPostApproved`
+ """
+ def __init__(self, send_date: int,
+ suggested_post_message: Optional[Message] = None,
+ price: Optional[SuggestedPostPrice] = None,
+ **kwargs):
+ self.suggested_post_message: Optional[Message] = suggested_post_message
+ self.price: Optional[SuggestedPostPrice] = price
+ self.send_date: int = send_date
+
+ @classmethod
+ def de_json(cls, json_string):
+ if json_string is None: return None
+ obj = cls.check_json(json_string)
+ if 'suggested_post_message' in obj:
+ obj['suggested_post_message'] = Message.de_json(obj['suggested_post_message'])
+ if 'price' in obj:
+ obj['price'] = SuggestedPostPrice.de_json(obj['price'])
+ return cls(**obj)
+
+class SuggestedPostApprovalFailed(JsonDeserializable):
+ """
+ Describes a service message about the failed approval of a suggested post.
+ Currently, only caused by insufficient user funds at the time of approval.
+
+ Telegram documentation: https://core.telegram.org/bots/api#suggestedpostapprovalfailed
+
+ :param suggested_post_message: Optional. Message containing the suggested post whose approval has failed. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply.
+ :type suggested_post_message: :class:`Message`
+
+ :param price: Expected price of the post
+ :type price: :class:`SuggestedPostPrice`
+
+ :return: Instance of the class
+ :rtype: :class:`SuggestedPostApprovalFailed`
+ """
+ def __init__(self, price: SuggestedPostPrice,
+ suggested_post_message: Optional[Message] = None, **kwargs):
+ self.suggested_post_message: Optional[Message] = suggested_post_message
+ self.price: SuggestedPostPrice = price
+
+ @classmethod
+ def de_json(cls, json_string):
+ if json_string is None: return None
+ obj = cls.check_json(json_string)
+ if 'suggested_post_message' in obj:
+ obj['suggested_post_message'] = Message.de_json(obj['suggested_post_message'])
+ obj['price'] = SuggestedPostPrice.de_json(obj['price'])
+ return cls(**obj)
+
+class SuggestedPostDeclined(JsonDeserializable):
+ """
+ Describes a service message about the rejection of a suggested post.
+
+ Telegram documentation: https://core.telegram.org/bots/api#suggestedpostdeclined
+
+ :param suggested_post_message: Optional. Message containing the suggested post. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply.
+ :type suggested_post_message: :class:`Message`
+
+ :param comment: Optional. Comment with which the post was declined
+ :type comment: :obj:`str`
+
+ :return: Instance of the class
+ :rtype: :class:`SuggestedPostDeclined`
+ """
+ def __init__(self, suggested_post_message: Optional[Message] = None, comment: Optional[str] = None, **kwargs):
+ self.suggested_post_message: Optional[Message] = suggested_post_message
+ self.comment: Optional[str] = comment
+
+ @classmethod
+ def de_json(cls, json_string):
+ if json_string is None: return None
+ obj = cls.check_json(json_string)
+ if 'suggested_post_message' in obj:
+ obj['suggested_post_message'] = Message.de_json(obj['suggested_post_message'])
+ return cls(**obj)
+
+class SuggestedPostPaid(JsonDeserializable):
+ """
+ Describes a service message about a successful payment for a suggested post.
+
+ Telegram documentation: https://core.telegram.org/bots/api#suggestedpostpaid
+
+ :param suggested_post_message: Optional. Message containing the suggested post. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply.
+ :type suggested_post_message: :class:`Message`
+
+ :param currency: Currency in which the payment was made. Currently, one of “XTR” for Telegram Stars or “TON” for toncoins
+ :type currency: :obj:`str`
+
+ :param amount: Optional. The amount of the currency that was received by the channel in nanotoncoins; for payments in toncoins only
+ :type amount: :obj:`int`
+
+ :param star_amount: Optional. The amount of Telegram Stars that was received by the channel; for payments in Telegram Stars only
+ :type star_amount: :class:`StarAmount`
+
+ :return: Instance of the class
+ :rtype: :class:`SuggestedPostPaid`
+ """
+ def __init__(self, currency: str,suggested_post_message: Optional[Message] = None,
+ amount: Optional[int] = None,
+ star_amount: Optional[StarAmount] = None, **kwargs):
+ self.suggested_post_message: Optional[Message] = suggested_post_message
+ self.currency: str = currency
+ self.amount: Optional[int] = amount
+ self.star_amount: Optional[StarAmount] = star_amount
+ @classmethod
+ def de_json(cls, json_string):
+ if json_string is None: return None
+ obj = cls.check_json(json_string)
+ if 'suggested_post_message' in obj:
+ obj['suggested_post_message'] = Message.de_json(obj['suggested_post_message'])
+ if 'star_amount' in obj:
+ obj['star_amount'] = StarAmount.de_json(obj['star_amount'])
+ return cls(**obj)
+
+class SuggestedPostRefunded(JsonDeserializable):
+ """
+ Describes a service message about a payment refund for a suggested post.
+
+ Telegram documentation: https://core.telegram.org/bots/api#suggestedpostrefunded
+
+ :param suggested_post_message: Optional. Message containing the suggested post. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply.
+ :type suggested_post_message: :class:`Message`
+
+ :param reason: Reason for the refund. Currently, one of “post_deleted” if the post was deleted within 24 hours of being posted or removed from scheduled messages without being posted, or “payment_refunded” if the payer refunded their payment.
+ :type reason: :obj:`str`
+
+ :return: Instance of the class
+ :rtype: :class:`SuggestedPostRefunded`
+ """
+ def __init__(self, reason: str, suggested_post_message: Optional[Message] = None, **kwargs):
+ self.suggested_post_message: Optional[Message] = suggested_post_message
+ self.reason: str = reason
+
+ @classmethod
+ def de_json(cls, json_string):
+ if json_string is None: return None
+ obj = cls.check_json(json_string)
+ if 'suggested_post_message' in obj:
+ obj['suggested_post_message'] = Message.de_json(obj['suggested_post_message'])
+ return cls(**obj)
+
+
+
\ No newline at end of file
diff --git a/telebot/util.py b/telebot/util.py
index 2f92ae781..0d37866e1 100644
--- a/telebot/util.py
+++ b/telebot/util.py
@@ -41,7 +41,9 @@
'chat_background_set', 'forum_topic_created', 'forum_topic_closed', 'forum_topic_reopened', 'forum_topic_edited',
'general_forum_topic_hidden', 'general_forum_topic_unhidden', 'write_access_allowed', 'users_shared', 'chat_shared',
'giveaway_created', 'giveaway_winners', 'giveaway_completed', 'boost_added', 'paid_message_price_changed',
- 'checklist_tasks_done', 'checklist_tasks_added', 'direct_message_price_changed',
+ 'checklist_tasks_done', 'checklist_tasks_added', 'direct_message_price_changed', 'suggested_post_refunded',
+ 'suggested_post_info', 'suggested_post_approved', 'suggested_post_approval_failed', 'suggested_post_declined',
+ 'suggested_post_paid'
]
#: All update types, should be used for allowed_updates parameter in polling.