From 202176c3b4a05e2f96403743dd56ba5273b0bbba Mon Sep 17 00:00:00 2001 From: wulan17 Date: Fri, 25 Aug 2023 23:54:04 +0700 Subject: [PATCH] Pyrofork: add MessageStory media type Signed-off-by: wulan17 --- pyrogram/enums/message_media_type.py | 3 ++ pyrogram/types/messages_and_media/__init__.py | 3 +- pyrogram/types/messages_and_media/message.py | 10 ++++ .../types/messages_and_media/message_story.py | 54 +++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 pyrogram/types/messages_and_media/message_story.py diff --git a/pyrogram/enums/message_media_type.py b/pyrogram/enums/message_media_type.py index 58878114..2b6c08ae 100644 --- a/pyrogram/enums/message_media_type.py +++ b/pyrogram/enums/message_media_type.py @@ -68,3 +68,6 @@ class MessageMediaType(AutoName): GAME = auto() "Game media" + + STORY = auto() + "Forwarded story media" diff --git a/pyrogram/types/messages_and_media/__init__.py b/pyrogram/types/messages_and_media/__init__.py index f1d64ae6..642ec8ab 100644 --- a/pyrogram/types/messages_and_media/__init__.py +++ b/pyrogram/types/messages_and_media/__init__.py @@ -41,6 +41,7 @@ from .voice import Voice from .web_app_data import WebAppData from .web_page import WebPage from .message_reactions import MessageReactions +from .message_story import MessageStory from .story import Story from .story_views import StoryViews from .exported_story_link import ExportedStoryLink @@ -48,5 +49,5 @@ from .exported_story_link import ExportedStoryLink __all__ = [ "Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Photo", "Thumbnail", "StrippedThumbnail", "Poll", "PollOption", "Sticker", "StickerSet", "Venue", "Video", "VideoNote", "Voice", "WebPage", "Dice", - "Reaction", "WebAppData", "MessageReactions", "Story", "StoryViews", "StoriesPrivacy", "ExportedStoryLink" + "Reaction", "WebAppData", "MessageReactions", "MessageStory", "Story", "StoryViews", "StoriesPrivacy", "ExportedStoryLink" ] diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index 431869bc..8a0d8d0a 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -182,6 +182,9 @@ class Message(Object, Update): game (:obj:`~pyrogram.types.Game`, *optional*): Message is a game, information about the game. + story (:obj:`~pyrogram.types.MessageStory`): + Message is a forwarded story, information about the forwarded story. + video (:obj:`~pyrogram.types.Video`, *optional*): Message is a video, information about the video. @@ -387,6 +390,7 @@ class Message(Object, Update): sticker: "types.Sticker" = None, animation: "types.Animation" = None, game: "types.Game" = None, + story: "types.MessageStory" = None, video: "types.Video" = None, voice: "types.Voice" = None, video_note: "types.VideoNote" = None, @@ -476,6 +480,7 @@ class Message(Object, Update): self.sticker = sticker self.animation = animation self.game = game + self.story = story self.video = video self.voice = voice self.video_note = video_note @@ -780,6 +785,7 @@ class Message(Object, Update): contact = None venue = None game = None + story = None audio = None voice = None animation = None @@ -812,6 +818,9 @@ class Message(Object, Update): elif isinstance(media, raw.types.MessageMediaGame): game = types.Game._parse(client, message) media_type = enums.MessageMediaType.GAME + elif isinstance(media, raw.types.MessageMediaStory): + story = types.MessageStory._parse(media) + media_type = enums.MessageMediaType.STORY elif isinstance(media, raw.types.MessageMediaDocument): doc = media.document @@ -940,6 +949,7 @@ class Message(Object, Update): voice=voice, animation=animation, game=game, + story=story, video=video, video_note=video_note, sticker=sticker, diff --git a/pyrogram/types/messages_and_media/message_story.py b/pyrogram/types/messages_and_media/message_story.py new file mode 100644 index 00000000..42b35d83 --- /dev/null +++ b/pyrogram/types/messages_and_media/message_story.py @@ -0,0 +1,54 @@ +# Pyrofork - Telegram MTProto API Client Library for Python +# Copyright (C) 2022-present Mayuri-Chan +# +# This file is part of Pyrofork. +# +# Pyrofork 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. +# +# Pyrofork 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 Pyrofork. If not, see . + +from typing import Optional, List + +import pyrogram +from pyrogram import raw, types +from ..object import Object + + +class MessageStory(Object): + """Contains information about a forwarded story. + + Parameters: + user_id (``int``): + Unique user identifier of story sender. + + story_id (``int``): + Unique story identifier. + + """ + + def __init__( + self, + *, + user_id: int, + story_id: int + ): + super().__init__() + + self.user_id = user_id + self.story_id = story_id + + @staticmethod + def _parse(message_story: "raw.types.MessageMediaStory") -> "MessageStory": + return MessageStory( + user_id=message_story.user_id, + story_id=message_story.id + )