Pyrofork: Add channel_shared and user_shared service message types

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2023-08-03 14:00:06 +07:00
parent d3ef8fb24a
commit b06422078e
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
2 changed files with 30 additions and 0 deletions

View file

@ -60,6 +60,12 @@ class MessageServiceType(AutoName):
GAME_HIGH_SCORE = auto()
"Game high score"
ChannelShared = auto()
"a shared chat/channel"
UserShared = auto()
"a shared user"
FORUM_TOPIC_CREATED = auto()
"a new forum topic created in the chat"

View file

@ -293,6 +293,12 @@ class Message(Object, Update):
E.g.: "/start 1 2 3" would produce ["start", "1", "2", "3"].
Only applicable when using :obj:`~pyrogram.filters.command`.
channel_shared (``int``, *optional*):
Service message: chat/channel shared
user_shared (``int``, *optional*):
Service message: user shared
forum_topic_created (:obj:`~pyrogram.types.ForumTopicCreated`, *optional*):
Service message: forum topic created
@ -409,6 +415,8 @@ class Message(Object, Update):
outgoing: bool = None,
matches: List[Match] = None,
command: List[str] = None,
channel_shared: int = None,
user_shared: int = None,
forum_topic_created: "types.ForumTopicCreated" = None,
forum_topic_closed: "types.ForumTopicClosed" = None,
forum_topic_reopened: "types.ForumTopicReopened" = None,
@ -497,6 +505,8 @@ class Message(Object, Update):
self.matches = matches
self.command = command
self.reply_markup = reply_markup
self.channel_shared = channel_shared
self.user_shared = user_shared
self.forum_topic_created = forum_topic_created
self.forum_topic_closed = forum_topic_closed
self.forum_topic_reopened = forum_topic_reopened
@ -557,6 +567,8 @@ class Message(Object, Update):
group_chat_created = None
channel_chat_created = None
new_chat_photo = None
channel_shared = None
user_shared = None
is_topic_message = None
forum_topic_created = None
forum_topic_closed = None
@ -605,6 +617,16 @@ class Message(Object, Update):
elif isinstance(action, raw.types.MessageActionChatEditPhoto):
new_chat_photo = types.Photo._parse(client, action.photo)
service_type = enums.MessageServiceType.NEW_CHAT_PHOTO
elif isinstance(action, raw.types.MessageActionRequestedPeer):
if isinstance(action.peer, raw.types.PeerChannel):
channel_shared = int(f"-100{action.peer.channel_id}")
service_type = enums.MessageServiceType.ChannelShared
elif isinstance(action.peer, raw.types.PeerChat):
channel_shared = int(f"-100{action.peer.chat_id}")
service_type = enums.MessageServiceType.ChannelShared
elif isinstance(action.peer, raw.types.PeerUser):
user_shared = action.peer.user_id
service_type = enums.MessageServiceType.UserShared
elif isinstance(action, raw.types.MessageActionTopicCreate):
forum_topic_created = types.ForumTopicCreated._parse(action)
service_type = enums.MessageServiceType.FORUM_TOPIC_CREATED
@ -664,6 +686,8 @@ class Message(Object, Update):
migrate_from_chat_id=-migrate_from_chat_id if migrate_from_chat_id else None,
group_chat_created=group_chat_created,
channel_chat_created=channel_chat_created,
channel_shared=channel_shared,
user_shared=user_shared,
is_topic_message=is_topic_message,
forum_topic_created=forum_topic_created,
forum_topic_closed=forum_topic_closed,