Pyrofork: add MessageStory media type

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2023-08-25 23:54:04 +07:00
parent c0ca286c04
commit 202176c3b4
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
4 changed files with 69 additions and 1 deletions

View file

@ -68,3 +68,6 @@ class MessageMediaType(AutoName):
GAME = auto()
"Game media"
STORY = auto()
"Forwarded story media"

View file

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

View file

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

View file

@ -0,0 +1,54 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/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 <http://www.gnu.org/licenses/>.
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
)