pyrofork: Drop Chat.is_forum and add new ChatType (FORUM)

Signed-off-by: wulan17 <wulan17@komodos.id>
This commit is contained in:
wulan17 2025-06-09 21:02:30 +07:00
parent a8a7bb5c03
commit 88d8a40900
No known key found for this signature in database
GPG key ID: 737814D4B5FF0420
4 changed files with 8 additions and 9 deletions

View file

@ -40,5 +40,8 @@ class ChatType(AutoName):
CHANNEL = auto() CHANNEL = auto()
"Chat is a channel" "Chat is a channel"
FORUM = auto()
"Chat is a forum"
MONOFORUM = auto() MONOFORUM = auto()
"Chat is a monoforum" "Chat is a monoforum"

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>. # along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from pyrogram import raw, types from pyrogram import enums, raw, types
from ..object import Object from ..object import Object
from typing import Union from typing import Union

View file

@ -970,7 +970,7 @@ class Message(Object, Update):
else: else:
parsed_message.message_thread_id = message.reply_to.reply_to_msg_id parsed_message.message_thread_id = message.reply_to.reply_to_msg_id
parsed_message.is_topic_message = True 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.message_thread_id = 1
parsed_message.is_topic_message = True parsed_message.is_topic_message = True
@ -1299,7 +1299,7 @@ class Message(Object, Update):
pass pass
else: else:
parsed_message.reply_to_story = reply_to_story 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.message_thread_id = 1
parsed_message.is_topic_message = True parsed_message.is_topic_message = True

View file

@ -56,9 +56,6 @@ class Chat(Object):
is_support (``bool``): is_support (``bool``):
True, if this chat is part of the Telegram support team. Users and bots only. 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*): is_participants_hidden (``bool``, *optional*):
True, if the chat members are hidden. True, if the chat members are hidden.
Returned only in :meth:`~pyrogram.Client.get_chat`. Returned only in :meth:`~pyrogram.Client.get_chat`.
@ -231,7 +228,6 @@ class Chat(Object):
is_scam: bool = None, is_scam: bool = None,
is_fake: bool = None, is_fake: bool = None,
is_support: bool = None, is_support: bool = None,
is_forum: bool = None,
is_participants_hidden: bool = None, is_participants_hidden: bool = None,
is_join_request: bool = None, is_join_request: bool = None,
is_join_to_send: bool = None, is_join_to_send: bool = None,
@ -286,7 +282,6 @@ class Chat(Object):
self.is_scam = is_scam self.is_scam = is_scam
self.is_fake = is_fake self.is_fake = is_fake
self.is_support = is_support self.is_support = is_support
self.is_forum = is_forum
self.is_participants_hidden = is_participants_hidden self.is_participants_hidden = is_participants_hidden
self.is_join_request = is_join_request self.is_join_request = is_join_request
self.is_join_to_send = is_join_to_send self.is_join_to_send = is_join_to_send
@ -396,6 +391,8 @@ class Chat(Object):
active_usernames = getattr(channel, "usernames", []) active_usernames = getattr(channel, "usernames", [])
if getattr(channel, "monoforum", None): if getattr(channel, "monoforum", None):
chat_type = enums.ChatType.MONOFORUM chat_type = enums.ChatType.MONOFORUM
elif getattr(channel, "forum", None):
chat_type = enums.ChatType.FORUM
elif getattr(channel, "megagroup", None): elif getattr(channel, "megagroup", None):
chat_type = enums.ChatType.SUPERGROUP chat_type = enums.ChatType.SUPERGROUP
elif getattr(channel, "broadcast", None): elif getattr(channel, "broadcast", None):
@ -424,7 +421,6 @@ class Chat(Object):
is_creator=getattr(channel, "creator", None), is_creator=getattr(channel, "creator", None),
is_scam=getattr(channel, "scam", None), is_scam=getattr(channel, "scam", None),
is_fake=getattr(channel, "fake", None), is_fake=getattr(channel, "fake", None),
is_forum=getattr(channel, "forum", None),
is_join_request=getattr(channel, "join_request", None), is_join_request=getattr(channel, "join_request", None),
is_join_to_send=getattr(channel, "join_to_send", None), is_join_to_send=getattr(channel, "join_to_send", None),
is_slowmode_enabled=getattr(channel, "slowmode_enabled", None), is_slowmode_enabled=getattr(channel, "slowmode_enabled", None),