From b3a642dc24362b182f69f2916eab7a1cc5105ae5 Mon Sep 17 00:00:00 2001 From: wulan17 Date: Sat, 9 Sep 2023 14:57:08 +0700 Subject: [PATCH] Pyrofork: Add topic id to topic created services messages Signed-off-by: wulan17 --- pyrogram/methods/chats/create_forum_topic.py | 2 +- pyrogram/types/messages_and_media/message.py | 2 +- .../types/user_and_chats/forum_topic_created.py | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pyrogram/methods/chats/create_forum_topic.py b/pyrogram/methods/chats/create_forum_topic.py index 4e9bb95c..f0ed4a57 100644 --- a/pyrogram/methods/chats/create_forum_topic.py +++ b/pyrogram/methods/chats/create_forum_topic.py @@ -64,4 +64,4 @@ class CreateForumTopic: ) ) - return types.ForumTopicCreated._parse(r.updates[1].message.action) + return types.ForumTopicCreated._parse(r.updates[1].message) diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index b3cd7138..5519c1d2 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -634,7 +634,7 @@ class Message(Object, Update): user_shared = action.peer.user_id service_type = enums.MessageServiceType.UserShared elif isinstance(action, raw.types.MessageActionTopicCreate): - forum_topic_created = types.ForumTopicCreated._parse(action) + forum_topic_created = types.ForumTopicCreated._parse(message) service_type = enums.MessageServiceType.FORUM_TOPIC_CREATED elif isinstance(action, raw.types.MessageActionTopicEdit): if action.title: diff --git a/pyrogram/types/user_and_chats/forum_topic_created.py b/pyrogram/types/user_and_chats/forum_topic_created.py index ed058760..da7daacc 100644 --- a/pyrogram/types/user_and_chats/forum_topic_created.py +++ b/pyrogram/types/user_and_chats/forum_topic_created.py @@ -25,6 +25,9 @@ class ForumTopicCreated(Object): Parameters: + id (``Integer``): + Id of the topic + title (``String``): Name of the topic. @@ -37,22 +40,25 @@ class ForumTopicCreated(Object): def __init__( self, *, + id: int, title: str, icon_color: int, icon_emoji_id: int = None ): super().__init__() + self.id = id self.title = title self.icon_color = icon_color self.icon_emoji_id = icon_emoji_id @staticmethod - def _parse(action: "raw.types.MessageActionTopicCreate") -> "ForumTopicCreated": + def _parse(message: "raw.base.Message") -> "ForumTopicCreated": return ForumTopicCreated( - title=getattr(action,"title", None), - icon_color=getattr(action,"icon_color", None), - icon_emoji_id=getattr(action,"icon_emoji_id", None) + id=getattr(message, "id", None), + title=getattr(message.action,"title", None), + icon_color=getattr(message.action,"icon_color", None), + icon_emoji_id=getattr(message.action,"icon_emoji_id", None) )