mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-03 14:04:51 +00:00
Pyrogram: Add {CREATED,EDITED,DELETED}_FORUM_TOPIC ChatEvent
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
9f32305c3a
commit
b76bf48862
2 changed files with 55 additions and 2 deletions
|
|
@ -123,5 +123,14 @@ class ChatEventAction(AutoName):
|
||||||
MESSAGE_UNPINNED = auto()
|
MESSAGE_UNPINNED = auto()
|
||||||
"a message has been unpinned (see ``unpinned_message``)"
|
"a message has been unpinned (see ``unpinned_message``)"
|
||||||
|
|
||||||
|
CREATED_FORUM_TOPIC = auto()
|
||||||
|
"a new forum topic has been created (see `created_forum_topic`)"
|
||||||
|
|
||||||
|
EDITED_FORUM_TOPIC = auto()
|
||||||
|
"a forum topic has been edited (see `old_forum_topic` and `new_forum_topic`)"
|
||||||
|
|
||||||
|
DELETED_FORUM_TOPIC = auto()
|
||||||
|
"a forum topic has been deleted (see `deleted_forum_topic`)"
|
||||||
|
|
||||||
UNKNOWN = auto()
|
UNKNOWN = auto()
|
||||||
"Unknown chat event action"
|
"Unknown chat event action"
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,18 @@ class ChatEvent(Object):
|
||||||
deleted_invite_link (:obj:`~pyrogram.types.ChatInviteLink`, *optional*):
|
deleted_invite_link (:obj:`~pyrogram.types.ChatInviteLink`, *optional*):
|
||||||
Deleted invite link.
|
Deleted invite link.
|
||||||
For :obj:`~pyrogram.enums.ChatEventAction.INVITE_LINK_DELETED` action only.
|
For :obj:`~pyrogram.enums.ChatEventAction.INVITE_LINK_DELETED` action only.
|
||||||
|
|
||||||
|
created_forum_topic (:obj:`~pyrogram.types.ForumTopic`, *optional*):
|
||||||
|
New forum topic.
|
||||||
|
For :obj:`~pyrogram.enums.ChatEvenAction.CREATED_FORUM_TOPIC` action only.
|
||||||
|
|
||||||
|
old_forum_topic, new_forum_topic (:obj:`~pyrogram.types.ForumTopic`, *optional*):
|
||||||
|
Edited forum topic.
|
||||||
|
For :obj:`~pyrogram.enums.ChatEvenAction.EDITED_FORUM_TOPIC` action only.
|
||||||
|
|
||||||
|
deleted_forum_topic (:obj:`~pyrogram.types.ForumTopic`, *optional*):
|
||||||
|
Deleted forum topic.
|
||||||
|
For :obj:`~pyrogram.enums.ChatEvenAction.DELETED_FORUM_TOPIC` action only.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
@ -190,7 +202,12 @@ class ChatEvent(Object):
|
||||||
old_invite_link: "types.ChatInviteLink" = None,
|
old_invite_link: "types.ChatInviteLink" = None,
|
||||||
new_invite_link: "types.ChatInviteLink" = None,
|
new_invite_link: "types.ChatInviteLink" = None,
|
||||||
revoked_invite_link: "types.ChatInviteLink" = None,
|
revoked_invite_link: "types.ChatInviteLink" = None,
|
||||||
deleted_invite_link: "types.ChatInviteLink" = None
|
deleted_invite_link: "types.ChatInviteLink" = None,
|
||||||
|
|
||||||
|
created_forum_topic: "types.ForumTopic" = None,
|
||||||
|
old_forum_topic: "types.ForumTopic" = None,
|
||||||
|
new_forum_topic: "types.ForumTopic" = None,
|
||||||
|
deleted_forum_topic: "types.ForumTopic" = None
|
||||||
):
|
):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
|
@ -252,6 +269,11 @@ class ChatEvent(Object):
|
||||||
self.revoked_invite_link = revoked_invite_link
|
self.revoked_invite_link = revoked_invite_link
|
||||||
self.deleted_invite_link = deleted_invite_link
|
self.deleted_invite_link = deleted_invite_link
|
||||||
|
|
||||||
|
self.created_forum_topic = created_forum_topic
|
||||||
|
self.old_forum_topic = old_forum_topic
|
||||||
|
self.new_forum_topic = new_forum_topic
|
||||||
|
self.deleted_forum_topic = deleted_forum_topic
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def _parse(
|
async def _parse(
|
||||||
client: "pyrogram.Client",
|
client: "pyrogram.Client",
|
||||||
|
|
@ -318,6 +340,11 @@ class ChatEvent(Object):
|
||||||
revoked_invite_link: Optional[types.ChatInviteLink] = None
|
revoked_invite_link: Optional[types.ChatInviteLink] = None
|
||||||
deleted_invite_link: Optional[types.ChatInviteLink] = None
|
deleted_invite_link: Optional[types.ChatInviteLink] = None
|
||||||
|
|
||||||
|
created_forum_topic: Optional[types.ForumTopic] = None
|
||||||
|
old_forum_topic: Optional[types.ForumTopic] = None
|
||||||
|
new_forum_topic: Optional[types.ForumTopic] = None
|
||||||
|
deleted_forum_topic: Optional[types.ForumTopic] = None
|
||||||
|
|
||||||
if isinstance(action, raw.types.ChannelAdminLogEventActionChangeAbout):
|
if isinstance(action, raw.types.ChannelAdminLogEventActionChangeAbout):
|
||||||
old_description = action.prev_value
|
old_description = action.prev_value
|
||||||
new_description = action.new_value
|
new_description = action.new_value
|
||||||
|
|
@ -426,6 +453,19 @@ class ChatEvent(Object):
|
||||||
deleted_invite_link = types.ChatInviteLink._parse(client, action.invite, users)
|
deleted_invite_link = types.ChatInviteLink._parse(client, action.invite, users)
|
||||||
action = enums.ChatEventAction.INVITE_LINK_DELETED
|
action = enums.ChatEventAction.INVITE_LINK_DELETED
|
||||||
|
|
||||||
|
elif isinstance(action, raw.types.ChannelAdminLogEventActionCreateTopic):
|
||||||
|
created_forum_topic = types.ForumTopic._parse(action.topic)
|
||||||
|
action = enums.ChatEventAction.CREATED_FORUM_TOPIC
|
||||||
|
|
||||||
|
elif isinstance(action, raw.types.ChannelAdminLogEventActionEditTopic):
|
||||||
|
old_forum_topic = types.ForumTopic._parse(action.prev_topic)
|
||||||
|
new_forum_topic = types.ForumTopic._parse(action.new_topic)
|
||||||
|
action = enums.ChatEventAction.EDITED_FORUM_TOPIC
|
||||||
|
|
||||||
|
elif isinstance(action, raw.types.ChannelAdminLogEventActionDeleteTopic):
|
||||||
|
created_forum_topic = types.ForumTopic._parse(action.topic)
|
||||||
|
action = enums.ChatEventAction.DELETED_FORUM_TOPIC
|
||||||
|
|
||||||
else:
|
else:
|
||||||
action = f"{enums.ChatEventAction.UNKNOWN}-{action.QUALNAME}"
|
action = f"{enums.ChatEventAction.UNKNOWN}-{action.QUALNAME}"
|
||||||
|
|
||||||
|
|
@ -485,5 +525,9 @@ class ChatEvent(Object):
|
||||||
old_invite_link=old_invite_link,
|
old_invite_link=old_invite_link,
|
||||||
new_invite_link=new_invite_link,
|
new_invite_link=new_invite_link,
|
||||||
revoked_invite_link=revoked_invite_link,
|
revoked_invite_link=revoked_invite_link,
|
||||||
deleted_invite_link=deleted_invite_link
|
deleted_invite_link=deleted_invite_link,
|
||||||
|
created_forum_topic=created_forum_topic,
|
||||||
|
old_forum_topic=old_forum_topic,
|
||||||
|
new_forum_topic=new_forum_topic,
|
||||||
|
deleted_forum_topic=deleted_forum_topic
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue