From e35ab566f7762932eaa733cb2f29c3e954100f15 Mon Sep 17 00:00:00 2001 From: katant Date: Sun, 6 Nov 2022 16:43:15 +1000 Subject: [PATCH 1/4] Added check for is_topic_message --- aiogram/types/message.py | 68 ++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/aiogram/types/message.py b/aiogram/types/message.py index 971aa6b4c2..f761543d97 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -412,7 +412,7 @@ async def answer( """ return await self.bot.send_message( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, text=text, parse_mode=parse_mode, entities=entities, @@ -485,7 +485,7 @@ async def answer_photo( """ return await self.bot.send_photo( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, photo=photo, caption=caption, parse_mode=parse_mode, @@ -578,7 +578,7 @@ async def answer_audio( """ return await self.bot.send_audio( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, audio=audio, caption=caption, parse_mode=parse_mode, @@ -677,7 +677,7 @@ async def answer_animation( """ return await self.bot.send_animation( self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, animation=animation, duration=duration, width=width, @@ -769,7 +769,7 @@ async def answer_document( """ return await self.bot.send_document( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, thumb=thumb, document=document, caption=caption, @@ -867,7 +867,7 @@ async def answer_video( """ return await self.bot.send_video( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, video=video, duration=duration, width=width, @@ -953,7 +953,7 @@ async def answer_voice( """ return await self.bot.send_voice( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, voice=voice, caption=caption, parse_mode=parse_mode, @@ -1027,7 +1027,7 @@ async def answer_video_note( """ return await self.bot.send_video_note( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, video_note=video_note, duration=duration, length=length, @@ -1078,7 +1078,7 @@ async def answer_media_group( """ return await self.bot.send_media_group( self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, media=media, disable_notification=disable_notification, protect_content=protect_content, @@ -1157,7 +1157,7 @@ async def answer_location( """ return await self.bot.send_location( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, latitude=latitude, longitude=longitude, horizontal_accuracy=horizontal_accuracy, @@ -1250,7 +1250,7 @@ async def answer_venue( """ return await self.bot.send_venue( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, latitude=latitude, longitude=longitude, title=title, @@ -1321,7 +1321,7 @@ async def answer_contact( """ return await self.bot.send_contact( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, phone_number=phone_number, first_name=first_name, last_name=last_name, @@ -1379,7 +1379,7 @@ async def answer_sticker( """ return await self.bot.send_sticker( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, sticker=sticker, disable_notification=disable_notification, protect_content=protect_content, @@ -1493,7 +1493,7 @@ async def answer_poll( """ return await self.bot.send_poll( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, question=question, options=options, is_anonymous=is_anonymous, @@ -1567,7 +1567,7 @@ async def answer_dice( """ return await self.bot.send_dice( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, emoji=emoji, disable_notification=disable_notification, protect_content=protect_content, @@ -1659,7 +1659,7 @@ async def reply( """ return await self.bot.send_message( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, text=text, parse_mode=parse_mode, entities=entities, @@ -1732,7 +1732,7 @@ async def reply_photo( """ return await self.bot.send_photo( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, photo=photo, caption=caption, parse_mode=parse_mode, @@ -1825,7 +1825,7 @@ async def reply_audio( """ return await self.bot.send_audio( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, audio=audio, caption=caption, parse_mode=parse_mode, @@ -1924,7 +1924,7 @@ async def reply_animation( """ return await self.bot.send_animation( self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, animation=animation, duration=duration, width=width, @@ -2016,7 +2016,7 @@ async def reply_document( """ return await self.bot.send_document( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, document=document, thumb=thumb, caption=caption, @@ -2114,7 +2114,7 @@ async def reply_video( """ return await self.bot.send_video( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, video=video, duration=duration, width=width, @@ -2200,7 +2200,7 @@ async def reply_voice( """ return await self.bot.send_voice( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, voice=voice, caption=caption, parse_mode=parse_mode, @@ -2274,7 +2274,7 @@ async def reply_video_note( """ return await self.bot.send_video_note( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, video_note=video_note, duration=duration, length=length, @@ -2325,7 +2325,7 @@ async def reply_media_group( """ return await self.bot.send_media_group( self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, media=media, disable_notification=disable_notification, protect_content=protect_content, @@ -2399,7 +2399,7 @@ async def reply_location( """ return await self.bot.send_location( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, latitude=latitude, longitude=longitude, horizontal_accuracy=horizontal_accuracy, @@ -2491,7 +2491,7 @@ async def reply_venue( """ return await self.bot.send_venue( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, latitude=latitude, longitude=longitude, title=title, @@ -2562,7 +2562,7 @@ async def reply_contact( """ return await self.bot.send_contact( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, phone_number=phone_number, first_name=first_name, last_name=last_name, @@ -2678,7 +2678,7 @@ async def reply_poll( """ return await self.bot.send_poll( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, question=question, options=options, is_anonymous=is_anonymous, @@ -2745,7 +2745,7 @@ async def reply_sticker( """ return await self.bot.send_sticker( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, sticker=sticker, disable_notification=disable_notification, protect_content=protect_content, @@ -2808,7 +2808,7 @@ async def reply_dice( """ return await self.bot.send_dice( chat_id=self.chat.id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, emoji=emoji, disable_notification=disable_notification, protect_content=protect_content, @@ -2848,7 +2848,7 @@ async def forward( """ return await self.bot.forward_message( chat_id=chat_id, - message_thread_id=self.message_thread_id, + message_thread_id=self.message_thread_id if self.is_topic_message else None, from_chat_id=self.chat.id, message_id=self.message_id, disable_notification=disable_notification, @@ -3334,9 +3334,6 @@ class ContentType(helper.Helper): VOICE_CHAT_ENDED = helper.Item() # voice_chat_ended VOICE_CHAT_PARTICIPANTS_INVITED = helper.Item() # voice_chat_participants_invited WEB_APP_DATA = helper.Item() # web_app_data - FORUM_TOPIC_CREATED = helper.Item() # forum_topic_created - FORUM_TOPIC_CLOSED = helper.Item() # forum_topic_closed - FORUM_TOPIC_REOPENED = helper.Item() # forum_topic_reopened VIDEO_CHAT_SCHEDULED = helper.Item() # video_chat_scheduled VIDEO_CHAT_STARTED = helper.Item() # video_chat_started VIDEO_CHAT_ENDED = helper.Item() # video_chat_ended @@ -3408,9 +3405,6 @@ class ContentTypes(helper.Helper): GROUP_CHAT_CREATED = helper.ListItem() # group_chat_created PASSPORT_DATA = helper.ListItem() # passport_data WEB_APP_DATA = helper.Item() # web_app_data - FORUM_TOPIC_CREATED = helper.ListItem() # forum_topic_created - FORUM_TOPIC_CLOSED = helper.ListItem() # forum_topic_closed - FORUM_TOPIC_REOPENED = helper.ListItem() # forum_topic_reopened VIDEO_CHAT_SCHEDULED = helper.Item() # video_chat_scheduled VIDEO_CHAT_STARTED = helper.Item() # video_chat_started VIDEO_CHAT_ENDED = helper.Item() # video_chat_ended From 5dd860237ab1bfe31d5b173283862734a859fcd8 Mon Sep 17 00:00:00 2001 From: katant Date: Sun, 6 Nov 2022 16:44:54 +1000 Subject: [PATCH 2/4] Added check for is_topic_message --- aiogram/types/message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiogram/types/message.py b/aiogram/types/message.py index f761543d97..d811715037 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -2848,7 +2848,7 @@ async def forward( """ return await self.bot.forward_message( chat_id=chat_id, - message_thread_id=self.message_thread_id if self.is_topic_message else None, + message_thread_id=message_thread_id, from_chat_id=self.chat.id, message_id=self.message_id, disable_notification=disable_notification, From c52daae2bf4020d756eca9ae0052f5bdee30c20d Mon Sep 17 00:00:00 2001 From: katant Date: Sun, 6 Nov 2022 16:47:12 +1000 Subject: [PATCH 3/4] Added check for is_topic_message --- aiogram/types/message.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/aiogram/types/message.py b/aiogram/types/message.py index d811715037..2fc7b910fb 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -3334,6 +3334,9 @@ class ContentType(helper.Helper): VOICE_CHAT_ENDED = helper.Item() # voice_chat_ended VOICE_CHAT_PARTICIPANTS_INVITED = helper.Item() # voice_chat_participants_invited WEB_APP_DATA = helper.Item() # web_app_data + FORUM_TOPIC_CREATED = helper.Item() # forum_topic_created + FORUM_TOPIC_CLOSED = helper.Item() # forum_topic_closed + FORUM_TOPIC_REOPENED = helper.Item() # forum_topic_reopened VIDEO_CHAT_SCHEDULED = helper.Item() # video_chat_scheduled VIDEO_CHAT_STARTED = helper.Item() # video_chat_started VIDEO_CHAT_ENDED = helper.Item() # video_chat_ended @@ -3405,6 +3408,9 @@ class ContentTypes(helper.Helper): GROUP_CHAT_CREATED = helper.ListItem() # group_chat_created PASSPORT_DATA = helper.ListItem() # passport_data WEB_APP_DATA = helper.Item() # web_app_data + FORUM_TOPIC_CREATED = helper.ListItem() # forum_topic_created + FORUM_TOPIC_CLOSED = helper.ListItem() # forum_topic_closed + FORUM_TOPIC_REOPENED = helper.ListItem() # forum_topic_reopened VIDEO_CHAT_SCHEDULED = helper.Item() # video_chat_scheduled VIDEO_CHAT_STARTED = helper.Item() # video_chat_started VIDEO_CHAT_ENDED = helper.Item() # video_chat_ended From b8647db3f234b53862e87413731c3757b0ad332a Mon Sep 17 00:00:00 2001 From: katant Date: Sun, 6 Nov 2022 16:59:18 +1000 Subject: [PATCH 4/4] Added check for is_topic_message --- aiogram/types/message.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aiogram/types/message.py b/aiogram/types/message.py index 2fc7b910fb..b191b82709 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -3239,6 +3239,7 @@ async def copy_to( caption: typing.Optional[base.String] = None, parse_mode: typing.Optional[base.String] = None, caption_entities: typing.Optional[typing.List[MessageEntity]] = None, + message_thread_id: typing.Optional[base.Integer] = None, disable_notification: typing.Optional[base.Boolean] = None, protect_content: typing.Optional[base.Boolean] = None, reply_to_message_id: typing.Optional[base.Integer] = None, @@ -3251,6 +3252,7 @@ async def copy_to( return await self.bot.copy_message( chat_id=chat_id, from_chat_id=self.chat.id, + message_thread_id=message_thread_id, message_id=self.message_id, caption=caption, parse_mode=parse_mode,