diff --git a/telegram/_bot.py b/telegram/_bot.py index f526101164c..d1c0f3710ef 100644 --- a/telegram/_bot.py +++ b/telegram/_bot.py @@ -433,6 +433,7 @@ async def _send_message( reply_markup: ReplyMarkup = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -452,6 +453,9 @@ async def _send_message( if reply_markup is not None: data["reply_markup"] = reply_markup + if message_thread_id is not None: + data["message_thread_id"] = message_thread_id + result = await self._post( endpoint, data, @@ -669,6 +673,7 @@ async def send_message( reply_to_message_id: int = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, reply_markup: ReplyMarkup = None, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -709,6 +714,10 @@ async def send_message( :class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional): Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + + .. versionadded:: 20.0 Keyword Args: read_timeout (:obj:`float` | :obj:`None`, optional): Value to pass to @@ -751,6 +760,7 @@ async def send_message( reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -836,6 +846,7 @@ async def forward_message( message_id: int, disable_notification: DVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -869,6 +880,10 @@ async def forward_message( forwarding and saving. .. versionadded:: 13.10 + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + + .. versionadded:: 20.0 Keyword Args: read_timeout (:obj:`float` | :obj:`None`, optional): Value to pass to @@ -905,6 +920,7 @@ async def forward_message( data, disable_notification=disable_notification, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -925,6 +941,7 @@ async def send_photo( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -967,7 +984,10 @@ async def send_photo( forwarding and saving. .. versionadded:: 13.10 + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + .. versionadded:: 20.0 reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the original message. allow_sending_without_reply (:obj:`bool`, optional): Pass :obj:`True`, if the message @@ -1024,6 +1044,7 @@ async def send_photo( reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -1048,6 +1069,7 @@ async def send_audio( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1101,6 +1123,10 @@ async def send_audio( forwarding and saving. .. versionadded:: 13.10 + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + + .. versionadded:: 20.0 reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the original message. @@ -1175,6 +1201,7 @@ async def send_audio( reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -1197,6 +1224,7 @@ async def send_document( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1249,6 +1277,10 @@ async def send_document( forwarding and saving. .. versionadded:: 13.10 + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + + .. versionadded:: 20.0 reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the original message. @@ -1317,6 +1349,7 @@ async def send_document( reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -1334,6 +1367,7 @@ async def send_sticker( reply_markup: ReplyMarkup = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = 20, @@ -1367,6 +1401,10 @@ async def send_sticker( forwarding and saving. .. versionadded:: 13.10 + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + + .. versionadded:: 20.0 reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the original message. @@ -1408,6 +1446,7 @@ async def send_sticker( reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -1433,6 +1472,7 @@ async def send_video( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1491,6 +1531,10 @@ async def send_video( forwarding and saving. .. versionadded:: 13.10 + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + + .. versionadded:: 20.0 reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the original message. @@ -1566,6 +1610,7 @@ async def send_video( reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -1586,6 +1631,7 @@ async def send_video_note( thumb: FileInput = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1633,6 +1679,10 @@ async def send_video_note( forwarding and saving. .. versionadded:: 13.10 + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + + .. versionadded:: 20.0 reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the original message. @@ -1699,6 +1749,7 @@ async def send_video_note( reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -1723,6 +1774,7 @@ async def send_animation( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1785,6 +1837,10 @@ async def send_animation( forwarding and saving. .. versionadded:: 13.10 + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + + .. versionadded:: 20.0 reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the original message. @@ -1849,6 +1905,7 @@ async def send_animation( reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -1870,6 +1927,7 @@ async def send_voice( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1922,6 +1980,10 @@ async def send_voice( forwarding and saving. .. versionadded:: 13.10 + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + + .. versionadded:: 20.0 reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the original message. @@ -1981,6 +2043,7 @@ async def send_voice( reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -1999,6 +2062,7 @@ async def send_media_group( reply_to_message_id: int = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = 20, @@ -2032,6 +2096,10 @@ async def send_media_group( forwarding and saving. .. versionadded:: 13.10 + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + + .. versionadded:: 20.0 reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the original message. @@ -2105,6 +2173,9 @@ async def send_media_group( if reply_to_message_id: data["reply_to_message_id"] = reply_to_message_id + if message_thread_id: + data["message_thread_id"] = message_thread_id + result = await self._post( "sendMediaGroup", data, @@ -2132,6 +2203,7 @@ async def send_location( proximity_alert_radius: int = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, location: Location = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2171,6 +2243,10 @@ async def send_location( forwarding and saving. .. versionadded:: 13.10 + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + + .. versionadded:: 20.0 reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the original message. @@ -2238,6 +2314,7 @@ async def send_location( reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -2447,6 +2524,7 @@ async def send_venue( google_place_type: str = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, venue: Venue = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2489,6 +2567,10 @@ async def send_venue( forwarding and saving. .. versionadded:: 13.10 + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + + .. versionadded:: 20.0 reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the original message. @@ -2571,6 +2653,7 @@ async def send_venue( reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -2591,6 +2674,7 @@ async def send_contact( vcard: str = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, contact: Contact = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2623,6 +2707,10 @@ async def send_contact( forwarding and saving. .. versionadded:: 13.10 + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + + .. versionadded:: 20.0 reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the original message. @@ -2694,6 +2782,7 @@ async def send_contact( reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -2711,6 +2800,7 @@ async def send_game( reply_markup: InlineKeyboardMarkup = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2733,6 +2823,10 @@ async def send_game( forwarding and saving. .. versionadded:: 13.10 + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + + .. versionadded:: 20.0 reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the original message. @@ -2775,6 +2869,7 @@ async def send_game( reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -4845,6 +4940,7 @@ async def send_invoice( max_tip_amount: int = None, suggested_tip_amounts: List[int] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -4938,6 +5034,10 @@ async def send_invoice( forwarding and saving. .. versionadded:: 13.10 + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + + .. versionadded:: 20.0 reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the original message. @@ -5018,6 +5118,7 @@ async def send_invoice( reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -7146,6 +7247,7 @@ async def send_poll( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, explanation_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -7201,6 +7303,10 @@ async def send_poll( forwarding and saving. .. versionadded:: 13.10 + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + + .. versionadded:: 20.0 reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the original message. @@ -7268,6 +7374,7 @@ async def send_poll( reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -7349,6 +7456,7 @@ async def send_dice( emoji: str = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -7391,6 +7499,10 @@ async def send_dice( forwarding and saving. .. versionadded:: 13.10 + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + + .. versionadded:: 20.0 Keyword Args: read_timeout (:obj:`float` | :obj:`None`, optional): Value to pass to @@ -7427,6 +7539,7 @@ async def send_dice( reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -7897,6 +8010,7 @@ async def copy_message( allow_sending_without_reply: DVInput[bool] = DEFAULT_NONE, reply_markup: ReplyMarkup = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -7933,6 +8047,10 @@ async def copy_message( forwarding and saving. .. versionadded:: 13.10 + message_thread_id (:obj:`int`, optional): Unique identifier for the target message + thread (topic) of the forum; for forum supergroups only. + + .. versionadded:: 20.0 reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the original message. @@ -7983,6 +8101,8 @@ async def copy_message( data["reply_to_message_id"] = reply_to_message_id if reply_markup: data["reply_markup"] = reply_markup + if message_thread_id: + data["message_thread_id"] = message_thread_id result = await self._post( "copyMessage", diff --git a/telegram/_chat.py b/telegram/_chat.py index 60dc7245b6c..ea27ad74462 100644 --- a/telegram/_chat.py +++ b/telegram/_chat.py @@ -1225,6 +1225,7 @@ async def send_message( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1253,6 +1254,7 @@ async def send_message( allow_sending_without_reply=allow_sending_without_reply, entities=entities, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -1269,6 +1271,7 @@ async def send_media_group( reply_to_message_id: int = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = 20, @@ -1301,6 +1304,7 @@ async def send_media_group( api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities, @@ -1350,6 +1354,7 @@ async def send_photo( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1380,6 +1385,7 @@ async def send_photo( caption_entities=caption_entities, filename=filename, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -1398,6 +1404,7 @@ async def send_contact( vcard: str = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, contact: "Contact" = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1433,6 +1440,7 @@ async def send_contact( api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_audio( @@ -1450,6 +1458,7 @@ async def send_audio( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1484,6 +1493,7 @@ async def send_audio( caption_entities=caption_entities, filename=filename, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -1504,6 +1514,7 @@ async def send_document( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1541,6 +1552,7 @@ async def send_document( allow_sending_without_reply=allow_sending_without_reply, caption_entities=caption_entities, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_dice( @@ -1551,6 +1563,7 @@ async def send_dice( emoji: str = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1581,6 +1594,7 @@ async def send_dice( api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_game( @@ -1591,6 +1605,7 @@ async def send_game( reply_markup: "InlineKeyboardMarkup" = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1621,6 +1636,7 @@ async def send_game( api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_invoice( @@ -1651,6 +1667,7 @@ async def send_invoice( max_tip_amount: int = None, suggested_tip_amounts: List[int] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1711,6 +1728,7 @@ async def send_invoice( max_tip_amount=max_tip_amount, suggested_tip_amounts=suggested_tip_amounts, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_location( @@ -1726,6 +1744,7 @@ async def send_location( proximity_alert_radius: int = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, location: "Location" = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1763,6 +1782,7 @@ async def send_location( proximity_alert_radius=proximity_alert_radius, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_animation( @@ -1780,6 +1800,7 @@ async def send_animation( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1819,6 +1840,7 @@ async def send_animation( caption_entities=caption_entities, filename=filename, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_sticker( @@ -1829,6 +1851,7 @@ async def send_sticker( reply_markup: ReplyMarkup = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = 20, @@ -1859,6 +1882,7 @@ async def send_sticker( api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_venue( @@ -1876,6 +1900,7 @@ async def send_venue( google_place_type: str = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, venue: "Venue" = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1915,6 +1940,7 @@ async def send_venue( google_place_type=google_place_type, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_video( @@ -1933,6 +1959,7 @@ async def send_video( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1973,6 +2000,7 @@ async def send_video( caption_entities=caption_entities, filename=filename, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_video_note( @@ -1986,6 +2014,7 @@ async def send_video_note( thumb: FileInput = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2021,6 +2050,7 @@ async def send_video_note( allow_sending_without_reply=allow_sending_without_reply, filename=filename, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_voice( @@ -2035,6 +2065,7 @@ async def send_voice( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2071,6 +2102,7 @@ async def send_voice( caption_entities=caption_entities, filename=filename, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_poll( @@ -2092,6 +2124,7 @@ async def send_poll( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, explanation_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2133,6 +2166,7 @@ async def send_poll( allow_sending_without_reply=allow_sending_without_reply, explanation_entities=explanation_entities, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_copy( @@ -2147,6 +2181,7 @@ async def send_copy( allow_sending_without_reply: DVInput[bool] = DEFAULT_NONE, reply_markup: ReplyMarkup = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2181,6 +2216,7 @@ async def send_copy( pool_timeout=pool_timeout, api_kwargs=api_kwargs, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def copy_message( @@ -2195,6 +2231,7 @@ async def copy_message( allow_sending_without_reply: DVInput[bool] = DEFAULT_NONE, reply_markup: ReplyMarkup = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2229,6 +2266,7 @@ async def copy_message( pool_timeout=pool_timeout, api_kwargs=api_kwargs, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def forward_from( @@ -2237,6 +2275,7 @@ async def forward_from( message_id: int, disable_notification: DVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2269,6 +2308,7 @@ async def forward_from( pool_timeout=pool_timeout, api_kwargs=api_kwargs, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def forward_to( @@ -2277,6 +2317,7 @@ async def forward_to( message_id: int, disable_notification: DVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2309,6 +2350,7 @@ async def forward_to( pool_timeout=pool_timeout, api_kwargs=api_kwargs, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def export_invite_link( diff --git a/telegram/_message.py b/telegram/_message.py index 86d40a1a355..cbbbfc3b581 100644 --- a/telegram/_message.py +++ b/telegram/_message.py @@ -247,6 +247,13 @@ class Message(TelegramObject): .. versionadded:: 20.0 reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached to the message. ``login_url`` buttons are represented as ordinary url buttons. + is_topic_message (:obj:`bool`, optional): True, if the message is sent to a forum topic. + + .. versionadded:: 20.0 + message_thread_id (:obj:`int`, optional): Unique identifier of a message thread to which + the message belongs; for supergroups only. + + .. versionadded:: 20.0 Attributes: message_id (:obj:`int`): Unique message identifier inside this chat. @@ -367,6 +374,13 @@ class Message(TelegramObject): .. versionadded:: 20.0 reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached to the message. + is_topic_message (:obj:`bool`, optional): True, if the message is sent to a forum topic. + + .. versionadded:: 20.0 + message_thread_id (:obj:`int`, optional): Unique identifier of a message thread to which + the message belongs; for supergroups only. + + .. versionadded:: 20.0 .. |custom_emoji_formatting_note| replace:: Custom emoji entities will currently be ignored by this function. Instead, the supplied replacement for the emoji will be used. @@ -434,6 +448,8 @@ class Message(TelegramObject): "is_automatic_forward", "has_protected_content", "web_app_data", + "is_topic_message", + "message_thread_id", ) def __init__( @@ -497,6 +513,8 @@ def __init__( is_automatic_forward: bool = None, has_protected_content: bool = None, web_app_data: WebAppData = None, + is_topic_message: bool = None, + message_thread_id: int = None, *, api_kwargs: JSONDict = None, ): @@ -563,6 +581,8 @@ def __init__( self.video_chat_participants_invited = video_chat_participants_invited self.reply_markup = reply_markup self.web_app_data = web_app_data + self.is_topic_message = is_topic_message + self.message_thread_id = message_thread_id self._effective_attachment = DEFAULT_NONE @@ -775,6 +795,7 @@ async def reply_text( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, quote: bool = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -810,6 +831,7 @@ async def reply_text( allow_sending_without_reply=allow_sending_without_reply, entities=entities, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -827,6 +849,7 @@ async def reply_markdown( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, quote: bool = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -872,6 +895,7 @@ async def reply_markdown( allow_sending_without_reply=allow_sending_without_reply, entities=entities, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -889,6 +913,7 @@ async def reply_markdown_v2( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, quote: bool = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -930,6 +955,7 @@ async def reply_markdown_v2( allow_sending_without_reply=allow_sending_without_reply, entities=entities, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -947,6 +973,7 @@ async def reply_html( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, quote: bool = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -988,6 +1015,7 @@ async def reply_html( allow_sending_without_reply=allow_sending_without_reply, entities=entities, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -1004,6 +1032,7 @@ async def reply_media_group( reply_to_message_id: int = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, quote: bool = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1046,6 +1075,7 @@ async def reply_media_group( api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities, @@ -1062,6 +1092,7 @@ async def reply_photo( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, quote: bool = None, @@ -1099,6 +1130,7 @@ async def reply_photo( caption_entities=caption_entities, filename=filename, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -1121,6 +1153,7 @@ async def reply_audio( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, quote: bool = None, @@ -1162,6 +1195,7 @@ async def reply_audio( caption_entities=caption_entities, filename=filename, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -1182,6 +1216,7 @@ async def reply_document( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, quote: bool = None, @@ -1226,6 +1261,7 @@ async def reply_document( allow_sending_without_reply=allow_sending_without_reply, caption_entities=caption_entities, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def reply_animation( @@ -1243,6 +1279,7 @@ async def reply_animation( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, quote: bool = None, @@ -1290,6 +1327,7 @@ async def reply_animation( caption_entities=caption_entities, filename=filename, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def reply_sticker( @@ -1300,6 +1338,7 @@ async def reply_sticker( reply_markup: ReplyMarkup = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, quote: bool = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1337,6 +1376,7 @@ async def reply_sticker( api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def reply_video( @@ -1355,6 +1395,7 @@ async def reply_video( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, quote: bool = None, @@ -1402,6 +1443,7 @@ async def reply_video( caption_entities=caption_entities, filename=filename, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def reply_video_note( @@ -1415,6 +1457,7 @@ async def reply_video_note( thumb: FileInput = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, quote: bool = None, @@ -1458,6 +1501,7 @@ async def reply_video_note( allow_sending_without_reply=allow_sending_without_reply, filename=filename, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def reply_voice( @@ -1472,6 +1516,7 @@ async def reply_voice( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, quote: bool = None, @@ -1516,6 +1561,7 @@ async def reply_voice( caption_entities=caption_entities, filename=filename, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def reply_location( @@ -1531,6 +1577,7 @@ async def reply_location( proximity_alert_radius: int = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, location: Location = None, quote: bool = None, @@ -1575,6 +1622,7 @@ async def reply_location( proximity_alert_radius=proximity_alert_radius, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def reply_venue( @@ -1592,6 +1640,7 @@ async def reply_venue( google_place_type: str = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, venue: Venue = None, quote: bool = None, @@ -1638,6 +1687,7 @@ async def reply_venue( google_place_type=google_place_type, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def reply_contact( @@ -1651,6 +1701,7 @@ async def reply_contact( vcard: str = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, contact: Contact = None, quote: bool = None, @@ -1693,6 +1744,7 @@ async def reply_contact( api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def reply_poll( @@ -1714,6 +1766,7 @@ async def reply_poll( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, explanation_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, quote: bool = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1762,6 +1815,7 @@ async def reply_poll( allow_sending_without_reply=allow_sending_without_reply, explanation_entities=explanation_entities, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def reply_dice( @@ -1772,6 +1826,7 @@ async def reply_dice( emoji: str = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, quote: bool = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1809,6 +1864,7 @@ async def reply_dice( api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def reply_chat_action( @@ -1851,6 +1907,7 @@ async def reply_game( reply_markup: "InlineKeyboardMarkup" = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, quote: bool = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1890,6 +1947,7 @@ async def reply_game( api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def reply_invoice( @@ -1920,6 +1978,7 @@ async def reply_invoice( max_tip_amount: int = None, suggested_tip_amounts: List[int] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, quote: bool = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1989,6 +2048,7 @@ async def reply_invoice( max_tip_amount=max_tip_amount, suggested_tip_amounts=suggested_tip_amounts, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def forward( @@ -1996,6 +2056,7 @@ async def forward( chat_id: Union[int, str], disable_notification: DVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2032,6 +2093,7 @@ async def forward( message_id=self.message_id, disable_notification=disable_notification, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -2050,6 +2112,7 @@ async def copy( allow_sending_without_reply: DVInput[bool] = DEFAULT_NONE, reply_markup: ReplyMarkup = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2090,6 +2153,7 @@ async def copy( pool_timeout=pool_timeout, api_kwargs=api_kwargs, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def reply_copy( @@ -2104,6 +2168,7 @@ async def reply_copy( allow_sending_without_reply: DVInput[bool] = DEFAULT_NONE, reply_markup: ReplyMarkup = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, quote: bool = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2152,6 +2217,7 @@ async def reply_copy( pool_timeout=pool_timeout, api_kwargs=api_kwargs, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def edit_text( diff --git a/telegram/_user.py b/telegram/_user.py index 01bf0d93a87..015ec93234e 100644 --- a/telegram/_user.py +++ b/telegram/_user.py @@ -376,6 +376,7 @@ async def send_message( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -404,6 +405,7 @@ async def send_message( allow_sending_without_reply=allow_sending_without_reply, entities=entities, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -422,6 +424,7 @@ async def send_photo( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -452,6 +455,7 @@ async def send_photo( caption_entities=caption_entities, filename=filename, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -468,6 +472,7 @@ async def send_media_group( reply_to_message_id: int = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = 20, @@ -500,6 +505,7 @@ async def send_media_group( api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, caption=caption, parse_mode=parse_mode, caption_entities=caption_entities, @@ -520,6 +526,7 @@ async def send_audio( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -554,6 +561,7 @@ async def send_audio( caption_entities=caption_entities, filename=filename, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -605,6 +613,7 @@ async def send_contact( vcard: str = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, contact: "Contact" = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -640,6 +649,7 @@ async def send_contact( api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_dice( @@ -650,6 +660,7 @@ async def send_dice( emoji: str = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -680,6 +691,7 @@ async def send_dice( api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_document( @@ -695,6 +707,7 @@ async def send_document( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -732,6 +745,7 @@ async def send_document( allow_sending_without_reply=allow_sending_without_reply, caption_entities=caption_entities, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_game( @@ -742,6 +756,7 @@ async def send_game( reply_markup: "InlineKeyboardMarkup" = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -772,6 +787,7 @@ async def send_game( api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_invoice( @@ -802,6 +818,7 @@ async def send_invoice( max_tip_amount: int = None, suggested_tip_amounts: List[int] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -862,6 +879,7 @@ async def send_invoice( max_tip_amount=max_tip_amount, suggested_tip_amounts=suggested_tip_amounts, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_location( @@ -877,6 +895,7 @@ async def send_location( proximity_alert_radius: int = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, location: "Location" = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -914,6 +933,7 @@ async def send_location( proximity_alert_radius=proximity_alert_radius, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_animation( @@ -931,6 +951,7 @@ async def send_animation( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -970,6 +991,7 @@ async def send_animation( caption_entities=caption_entities, filename=filename, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_sticker( @@ -980,6 +1002,7 @@ async def send_sticker( reply_markup: ReplyMarkup = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = 20, @@ -1010,6 +1033,7 @@ async def send_sticker( api_kwargs=api_kwargs, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_video( @@ -1028,6 +1052,7 @@ async def send_video( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1068,6 +1093,7 @@ async def send_video( caption_entities=caption_entities, filename=filename, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_venue( @@ -1085,6 +1111,7 @@ async def send_venue( google_place_type: str = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, venue: "Venue" = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1124,6 +1151,7 @@ async def send_venue( google_place_type=google_place_type, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_video_note( @@ -1137,6 +1165,7 @@ async def send_video_note( thumb: FileInput = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1172,6 +1201,7 @@ async def send_video_note( allow_sending_without_reply=allow_sending_without_reply, filename=filename, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_voice( @@ -1186,6 +1216,7 @@ async def send_voice( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1222,6 +1253,7 @@ async def send_voice( caption_entities=caption_entities, filename=filename, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_poll( @@ -1243,6 +1275,7 @@ async def send_poll( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, explanation_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1284,6 +1317,7 @@ async def send_poll( allow_sending_without_reply=allow_sending_without_reply, explanation_entities=explanation_entities, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def send_copy( @@ -1298,6 +1332,7 @@ async def send_copy( allow_sending_without_reply: DVInput[bool] = DEFAULT_NONE, reply_markup: ReplyMarkup = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1332,6 +1367,7 @@ async def send_copy( pool_timeout=pool_timeout, api_kwargs=api_kwargs, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def copy_message( @@ -1346,6 +1382,7 @@ async def copy_message( allow_sending_without_reply: DVInput[bool] = DEFAULT_NONE, reply_markup: ReplyMarkup = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1380,6 +1417,7 @@ async def copy_message( pool_timeout=pool_timeout, api_kwargs=api_kwargs, protect_content=protect_content, + message_thread_id=message_thread_id, ) async def approve_join_request( diff --git a/telegram/ext/_extbot.py b/telegram/ext/_extbot.py index a344123f965..6a68f5a9971 100644 --- a/telegram/ext/_extbot.py +++ b/telegram/ext/_extbot.py @@ -460,6 +460,7 @@ async def _send_message( reply_markup: ReplyMarkup = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -477,6 +478,7 @@ async def _send_message( reply_markup=self._replace_keyboard(reply_markup), allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -624,6 +626,7 @@ async def copy_message( allow_sending_without_reply: DVInput[bool] = DEFAULT_NONE, reply_markup: ReplyMarkup = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -645,6 +648,7 @@ async def copy_message( allow_sending_without_reply=allow_sending_without_reply, reply_markup=self._replace_keyboard(reply_markup), protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -1395,6 +1399,7 @@ async def forward_message( message_id: int, disable_notification: DVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1409,6 +1414,7 @@ async def forward_message( message_id=message_id, disable_notification=disable_notification, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -1876,6 +1882,7 @@ async def send_animation( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1900,6 +1907,7 @@ async def send_animation( allow_sending_without_reply=allow_sending_without_reply, caption_entities=caption_entities, protect_content=protect_content, + message_thread_id=message_thread_id, filename=filename, read_timeout=read_timeout, write_timeout=write_timeout, @@ -1924,6 +1932,7 @@ async def send_audio( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -1948,6 +1957,7 @@ async def send_audio( allow_sending_without_reply=allow_sending_without_reply, caption_entities=caption_entities, protect_content=protect_content, + message_thread_id=message_thread_id, filename=filename, read_timeout=read_timeout, write_timeout=write_timeout, @@ -1990,6 +2000,7 @@ async def send_contact( vcard: str = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, contact: Contact = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2010,6 +2021,7 @@ async def send_contact( vcard=vcard, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, contact=contact, read_timeout=read_timeout, write_timeout=write_timeout, @@ -2027,6 +2039,7 @@ async def send_dice( emoji: str = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2043,6 +2056,7 @@ async def send_dice( emoji=emoji, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -2064,6 +2078,7 @@ async def send_document( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2086,6 +2101,7 @@ async def send_document( allow_sending_without_reply=allow_sending_without_reply, caption_entities=caption_entities, protect_content=protect_content, + message_thread_id=message_thread_id, filename=filename, read_timeout=read_timeout, write_timeout=write_timeout, @@ -2103,6 +2119,7 @@ async def send_game( reply_markup: InlineKeyboardMarkup = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2119,6 +2136,7 @@ async def send_game( reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -2155,6 +2173,7 @@ async def send_invoice( max_tip_amount: int = None, suggested_tip_amounts: List[int] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2191,6 +2210,7 @@ async def send_invoice( max_tip_amount=max_tip_amount, suggested_tip_amounts=suggested_tip_amounts, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -2212,6 +2232,7 @@ async def send_location( proximity_alert_radius: int = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, location: Location = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2234,6 +2255,7 @@ async def send_location( proximity_alert_radius=proximity_alert_radius, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, location=location, read_timeout=read_timeout, write_timeout=write_timeout, @@ -2252,6 +2274,7 @@ async def send_media_group( reply_to_message_id: int = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = 20, @@ -2270,6 +2293,7 @@ async def send_media_group( reply_to_message_id=reply_to_message_id, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -2292,6 +2316,7 @@ async def send_message( reply_to_message_id: int = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, reply_markup: ReplyMarkup = None, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2308,6 +2333,7 @@ async def send_message( disable_web_page_preview=disable_web_page_preview, disable_notification=disable_notification, protect_content=protect_content, + message_thread_id=message_thread_id, reply_to_message_id=reply_to_message_id, allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, @@ -2330,6 +2356,7 @@ async def send_photo( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2350,6 +2377,7 @@ async def send_photo( allow_sending_without_reply=allow_sending_without_reply, caption_entities=caption_entities, protect_content=protect_content, + message_thread_id=message_thread_id, filename=filename, read_timeout=read_timeout, write_timeout=write_timeout, @@ -2378,6 +2406,7 @@ async def send_poll( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, explanation_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2405,6 +2434,7 @@ async def send_poll( allow_sending_without_reply=allow_sending_without_reply, explanation_entities=explanation_entities, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -2421,6 +2451,7 @@ async def send_sticker( reply_markup: ReplyMarkup = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, read_timeout: ODVInput[float] = DEFAULT_NONE, write_timeout: ODVInput[float] = 20, @@ -2437,6 +2468,7 @@ async def send_sticker( reply_markup=reply_markup, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, read_timeout=read_timeout, write_timeout=write_timeout, connect_timeout=connect_timeout, @@ -2460,6 +2492,7 @@ async def send_venue( google_place_type: str = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, venue: Venue = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2484,6 +2517,7 @@ async def send_venue( google_place_type=google_place_type, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, venue=venue, read_timeout=read_timeout, write_timeout=write_timeout, @@ -2509,6 +2543,7 @@ async def send_video( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2534,6 +2569,7 @@ async def send_video( allow_sending_without_reply=allow_sending_without_reply, caption_entities=caption_entities, protect_content=protect_content, + message_thread_id=message_thread_id, filename=filename, read_timeout=read_timeout, write_timeout=write_timeout, @@ -2554,6 +2590,7 @@ async def send_video_note( thumb: FileInput = None, allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2574,6 +2611,7 @@ async def send_video_note( thumb=thumb, allow_sending_without_reply=allow_sending_without_reply, protect_content=protect_content, + message_thread_id=message_thread_id, filename=filename, read_timeout=read_timeout, write_timeout=write_timeout, @@ -2595,6 +2633,7 @@ async def send_voice( allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE, caption_entities: Union[List["MessageEntity"], Tuple["MessageEntity", ...]] = None, protect_content: ODVInput[bool] = DEFAULT_NONE, + message_thread_id: int = None, *, filename: str = None, read_timeout: ODVInput[float] = DEFAULT_NONE, @@ -2616,6 +2655,7 @@ async def send_voice( allow_sending_without_reply=allow_sending_without_reply, caption_entities=caption_entities, protect_content=protect_content, + message_thread_id=message_thread_id, filename=filename, read_timeout=read_timeout, write_timeout=write_timeout, diff --git a/tests/test_bot.py b/tests/test_bot.py index 0189763799a..e6655fdefe4 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -2494,6 +2494,32 @@ async def test_send_message_entities(self, bot, chat_id): assert message.text == test_string assert message.entities == entities + @flaky(3, 1) + async def test_send_message_to_topic(self, bot, forum_group_id): + # TODO rework when new methods and attributes become available + test_string = "Topics are forever" + + result = await bot._post( + "createForumTopic", + {"chat_id": forum_group_id, "name": "Is just a yellow lemon tree"}, + ) + + message_thread_id = result["message_thread_id"] + + message = await bot.send_message( + chat_id=forum_group_id, text=test_string, message_thread_id=message_thread_id + ) + + assert message.text == test_string + assert message.is_topic_message is True + assert message.message_thread_id == message_thread_id + + result = await bot._post( + "deleteForumTopic", + {"chat_id": forum_group_id, "message_thread_id": message_thread_id}, + ) + assert result is True + @flaky(3, 1) @pytest.mark.parametrize("default_bot", [{"parse_mode": "Markdown"}], indirect=True) async def test_send_message_default_parse_mode(self, default_bot, chat_id): diff --git a/tests/test_chat.py b/tests/test_chat.py index 8422148c0fb..4f2305180b8 100644 --- a/tests/test_chat.py +++ b/tests/test_chat.py @@ -106,7 +106,7 @@ def test_de_json(self, bot): ), "is_forum": self.is_forum, "active_usernames": self.active_usernames, - "emoji_status_custom_emoji_id": self.emoji_status_custom_emoji_id + "emoji_status_custom_emoji_id": self.emoji_status_custom_emoji_id, } chat = Chat.de_json(json_dict, bot)