From 6835bccf11bc60e8628c85fb2372870c46cc1513 Mon Sep 17 00:00:00 2001 From: wulan17 Date: Mon, 9 Jun 2025 21:02:30 +0700 Subject: [PATCH] pyrofork: Drop Chat.is_forum and add new ChatType (FORUM) Signed-off-by: wulan17 --- pyrogram/enums/chat_type.py | 3 +++ pyrogram/types/bots_and_keyboards/keyboard_button.py | 6 +++--- pyrogram/types/messages_and_media/message.py | 4 ++-- pyrogram/types/user_and_chats/chat.py | 8 ++------ 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/pyrogram/enums/chat_type.py b/pyrogram/enums/chat_type.py index 1b6ebe3c..10cf8db6 100644 --- a/pyrogram/enums/chat_type.py +++ b/pyrogram/enums/chat_type.py @@ -40,5 +40,8 @@ class ChatType(AutoName): CHANNEL = auto() "Chat is a channel" + FORUM = auto() + "Chat is a forum" + MONOFORUM = auto() "Chat is a monoforum" diff --git a/pyrogram/types/bots_and_keyboards/keyboard_button.py b/pyrogram/types/bots_and_keyboards/keyboard_button.py index cf40bf2b..3f578c71 100644 --- a/pyrogram/types/bots_and_keyboards/keyboard_button.py +++ b/pyrogram/types/bots_and_keyboards/keyboard_button.py @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrofork. If not, see . -from pyrogram import raw, types +from pyrogram import enums, raw, types from ..object import Object from typing import Union @@ -114,7 +114,7 @@ class KeyboardButton(Object): is_creator=b.peer_type.creator, is_bot_participant=b.peer_type.bot_participant, is_username=b.peer_type.has_username, - is_forum=b.peer_type.forum, + is_forum=True if b.peer_type.type == enums.ChatType.FORUM else False, max=b.max_quantity ) ) @@ -155,7 +155,7 @@ class KeyboardButton(Object): creator=self.request_chat.is_creator, bot_participant=self.request_chat.is_bot_participant, has_username=self.request_chat.is_username, - forum=self.request_chat.is_forum + forum=True if self.request_chat.type == enums.ChatType.FORUM else False ), max_quantity=self.request_chat.max, name_requested=self.request_chat.is_name_requested, diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index e91d915c..7769ec23 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -970,7 +970,7 @@ class Message(Object, Update): else: parsed_message.message_thread_id = message.reply_to.reply_to_msg_id parsed_message.is_topic_message = True - elif parsed_message.chat.is_forum and parsed_message.message_thread_id is None: + elif parsed_message.chat.type == enums.ChatType.FORUM and parsed_message.message_thread_id is None: parsed_message.message_thread_id = 1 parsed_message.is_topic_message = True @@ -1299,7 +1299,7 @@ class Message(Object, Update): pass else: parsed_message.reply_to_story = reply_to_story - if parsed_message.chat.is_forum and parsed_message.message_thread_id is None: + if parsed_message.chat.type == enums.ChatType.FORUM and parsed_message.message_thread_id is None: parsed_message.message_thread_id = 1 parsed_message.is_topic_message = True diff --git a/pyrogram/types/user_and_chats/chat.py b/pyrogram/types/user_and_chats/chat.py index 5395dc8b..163f5d83 100644 --- a/pyrogram/types/user_and_chats/chat.py +++ b/pyrogram/types/user_and_chats/chat.py @@ -56,9 +56,6 @@ class Chat(Object): is_support (``bool``): True, if this chat is part of the Telegram support team. Users and bots only. - is_forum (``bool``, *optional*): - True, if the supergroup chat is a forum - is_participants_hidden (``bool``, *optional*): True, if the chat members are hidden. Returned only in :meth:`~pyrogram.Client.get_chat`. @@ -231,7 +228,6 @@ class Chat(Object): is_scam: bool = None, is_fake: bool = None, is_support: bool = None, - is_forum: bool = None, is_participants_hidden: bool = None, is_join_request: bool = None, is_join_to_send: bool = None, @@ -286,7 +282,6 @@ class Chat(Object): self.is_scam = is_scam self.is_fake = is_fake self.is_support = is_support - self.is_forum = is_forum self.is_participants_hidden = is_participants_hidden self.is_join_request = is_join_request self.is_join_to_send = is_join_to_send @@ -396,6 +391,8 @@ class Chat(Object): active_usernames = getattr(channel, "usernames", []) if getattr(channel, "monoforum", None): chat_type = enums.ChatType.MONOFORUM + elif getattr(channel, "forum", None): + chat_type = enums.ChatType.FORUM elif getattr(channel, "megagroup", None): chat_type = enums.ChatType.SUPERGROUP elif getattr(channel, "broadcast", None): @@ -424,7 +421,6 @@ class Chat(Object): is_creator=getattr(channel, "creator", None), is_scam=getattr(channel, "scam", None), is_fake=getattr(channel, "fake", None), - is_forum=getattr(channel, "forum", None), is_join_request=getattr(channel, "join_request", None), is_join_to_send=getattr(channel, "join_to_send", None), is_slowmode_enabled=getattr(channel, "slowmode_enabled", None),