Pyrogram: add GeneralTopicHidden and GeneralTopicUnhidden service messages types

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2023-01-01 22:36:39 +07:00
parent 85184be318
commit 8428de1722
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
5 changed files with 91 additions and 2 deletions

View file

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

View file

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

View file

@ -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",

View file

@ -0,0 +1,29 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
# 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 <http://www.gnu.org/licenses/>.
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__()

View file

@ -0,0 +1,29 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
# 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 <http://www.gnu.org/licenses/>.
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__()