Pyrofork: Add topic id to topic created services messages

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2023-09-09 14:57:08 +07:00
parent 24dfde46ce
commit b3a642dc24
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
3 changed files with 12 additions and 6 deletions

View file

@ -64,4 +64,4 @@ class CreateForumTopic:
)
)
return types.ForumTopicCreated._parse(r.updates[1].message.action)
return types.ForumTopicCreated._parse(r.updates[1].message)

View file

@ -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:

View file

@ -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)
)