Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for groups without topics #1062

Merged
merged 4 commits into from Nov 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
76 changes: 39 additions & 37 deletions aiogram/types/message.py
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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=message_thread_id,
from_chat_id=self.chat.id,
message_id=self.message_id,
disable_notification=disable_notification,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -3334,9 +3336,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
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
Expand Down Expand Up @@ -3408,9 +3410,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
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
Expand Down