From 8428de1722da2e4fd7c27779eab5cac37599412a Mon Sep 17 00:00:00 2001 From: wulan17 Date: Sun, 1 Jan 2023 22:36:39 +0700 Subject: [PATCH] Pyrogram: add GeneralTopicHidden and GeneralTopicUnhidden service messages types Signed-off-by: wulan17 --- pyrogram/enums/message_service_type.py | 6 ++++ pyrogram/types/messages_and_media/message.py | 25 ++++++++++++++-- pyrogram/types/user_and_chats/__init__.py | 4 +++ .../general_forum_topic_hidden.py | 29 +++++++++++++++++++ .../general_forum_topic_unhidden.py | 29 +++++++++++++++++++ 5 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 pyrogram/types/user_and_chats/general_forum_topic_hidden.py create mode 100644 pyrogram/types/user_and_chats/general_forum_topic_unhidden.py diff --git a/pyrogram/enums/message_service_type.py b/pyrogram/enums/message_service_type.py index f6933003..3229cf14 100644 --- a/pyrogram/enums/message_service_type.py +++ b/pyrogram/enums/message_service_type.py @@ -72,6 +72,12 @@ class MessageServiceType(AutoName): FORUM_TOPIC_EDITED = auto() "a new forum topic renamed in the chat" + GENERAL_TOPIC_HIDDEN = auto() + "a forum general topic hidden in the chat" + + GENERAL_TOPIC_UNHIDDEN = auto() + "a forum general topic unhidden in the chat" + VIDEO_CHAT_STARTED = auto() "Video chat started" diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index 4ec80599..ada07e5a 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -302,6 +302,12 @@ class Message(Object, Update): forum_topic_edited (:obj:`~pyrogram.types.ForumTopicEdited`, *optional*): Service message: forum topic edited + general_topic_hidden (:obj:`~pyrogram.types.GeneralForumTopicHidden`, *optional*): + Service message: forum general topic hidden + + general_topic_unhidden (:obj:`~pyrogram.types.GeneralForumTopicUnhidden`, *optional*): + Service message: forum general topic unhidden + video_chat_scheduled (:obj:`~pyrogram.types.VideoChatScheduled`, *optional*): Service message: voice chat scheduled. @@ -403,6 +409,8 @@ class Message(Object, Update): forum_topic_closed: "types.ForumTopicClosed" = None, forum_topic_reopened: "types.ForumTopicReopened" = None, forum_topic_edited: "types.ForumTopicEdited" = None, + general_topic_hidden: "types.GeneralForumTopicHidden" = None, + general_topic_unhidden: "types.GeneralForumTopicUnhidden" = None, video_chat_scheduled: "types.VideoChatScheduled" = None, video_chat_started: "types.VideoChatStarted" = None, video_chat_ended: "types.VideoChatEnded" = None, @@ -488,6 +496,8 @@ class Message(Object, Update): self.forum_topic_closed = forum_topic_closed self.forum_topic_reopened = forum_topic_reopened self.forum_topic_edited = forum_topic_edited + self.general_topic_hidden = general_topic_hidden + self.general_topic_unhidden = general_topic_unhidden self.video_chat_scheduled = video_chat_scheduled self.video_chat_started = video_chat_started self.video_chat_ended = video_chat_ended @@ -547,6 +557,8 @@ class Message(Object, Update): forum_topic_closed = None forum_topic_reopened = None forum_topic_edited = None + general_topic_hidden = None + general_topic_unhidden = None video_chat_scheduled = None video_chat_started = None video_chat_ended = None @@ -595,12 +607,19 @@ class Message(Object, Update): if action.title: forum_topic_edited = types.ForumTopicEdited._parse(action) service_type = enums.MessageServiceType.FORUM_TOPIC_EDITED + elif action.hidden: + general_topic_hidden = types.GeneralTopicHidden() + service_type = enums.MessageServiceType.GENERAL_TOPIC_HIDDEN elif action.closed: forum_topic_closed = types.ForumTopicClosed() service_type = enums.MessageServiceType.FORUM_TOPIC_CLOSED else: - forum_topic_reopened = types.ForumTopicReopened() - service_type = enums.MessageServiceType.FORUM_TOPIC_REOPENED + if hasattr(action, "hidden"): + general_topic_unhidden = types.GeneralTopicUnhidden() + service_type = enums.MessageServiceType.GENERAL_TOPIC_UNHIDDEN + else: + forum_topic_reopened = types.ForumTopicReopened() + service_type = enums.MessageServiceType.FORUM_TOPIC_REOPENED elif isinstance(action, raw.types.MessageActionGroupCallScheduled): video_chat_scheduled = types.VideoChatScheduled._parse(action) service_type = enums.MessageServiceType.VIDEO_CHAT_SCHEDULED @@ -645,6 +664,8 @@ class Message(Object, Update): forum_topic_closed=forum_topic_closed, forum_topic_reopened=forum_topic_reopened, forum_topic_edited=forum_topic_edited, + general_topic_hidden=general_topic_hidden, + general_topic_unhidden=general_topic_unhidden, video_chat_scheduled=video_chat_scheduled, video_chat_started=video_chat_started, video_chat_ended=video_chat_ended, diff --git a/pyrogram/types/user_and_chats/__init__.py b/pyrogram/types/user_and_chats/__init__.py index bc1e7f71..981a5c77 100644 --- a/pyrogram/types/user_and_chats/__init__.py +++ b/pyrogram/types/user_and_chats/__init__.py @@ -41,6 +41,8 @@ from .forum_topic_created import ForumTopicCreated from .forum_topic_closed import ForumTopicClosed from .forum_topic_reopened import ForumTopicReopened from .forum_topic_edited import ForumTopicEdited +from .general_forum_topic_hidden import GeneralTopicHidden +from .general_forum_topic_unhidden import GeneralTopicUnhidden from .peer_channel import PeerChannel from .peer_user import PeerUser from .video_chat_ended import VideoChatEnded @@ -67,6 +69,8 @@ __all__ = [ "ForumTopicClosed", "ForumTopicReopened", "ForumTopicEdited", + "GeneralTopicHidden", + "GeneralTopicUnhidden", "PeerChannel", "PeerUser", "VideoChatStarted", diff --git a/pyrogram/types/user_and_chats/general_forum_topic_hidden.py b/pyrogram/types/user_and_chats/general_forum_topic_hidden.py new file mode 100644 index 00000000..203d4b99 --- /dev/null +++ b/pyrogram/types/user_and_chats/general_forum_topic_hidden.py @@ -0,0 +1,29 @@ +# Pyrogram - Telegram MTProto API Client Library for Python +# Copyright (C) 2017-present Dan +# +# This file is part of Pyrogram. +# +# Pyrogram is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pyrogram is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Pyrogram. If not, see . + +from ..object import Object + + +class GeneralTopicHidden(Object): + """A service message about a general topic hidden in the chat. + + Currently holds no information. + """ + + def __init__(self): + super().__init__() diff --git a/pyrogram/types/user_and_chats/general_forum_topic_unhidden.py b/pyrogram/types/user_and_chats/general_forum_topic_unhidden.py new file mode 100644 index 00000000..44881830 --- /dev/null +++ b/pyrogram/types/user_and_chats/general_forum_topic_unhidden.py @@ -0,0 +1,29 @@ +# Pyrogram - Telegram MTProto API Client Library for Python +# Copyright (C) 2017-present Dan +# +# This file is part of Pyrogram. +# +# Pyrogram is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pyrogram is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Pyrogram. If not, see . + +from ..object import Object + + +class GeneralTopicUnhidden(Object): + """A service message about a general topic unhidden in the chat. + + Currently holds no information. + """ + + def __init__(self): + super().__init__()