mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-08 16:04:51 +00:00
Pyrofork: add MessageStory media type
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
c0ca286c04
commit
202176c3b4
4 changed files with 69 additions and 1 deletions
|
|
@ -68,3 +68,6 @@ class MessageMediaType(AutoName):
|
||||||
|
|
||||||
GAME = auto()
|
GAME = auto()
|
||||||
"Game media"
|
"Game media"
|
||||||
|
|
||||||
|
STORY = auto()
|
||||||
|
"Forwarded story media"
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ from .voice import Voice
|
||||||
from .web_app_data import WebAppData
|
from .web_app_data import WebAppData
|
||||||
from .web_page import WebPage
|
from .web_page import WebPage
|
||||||
from .message_reactions import MessageReactions
|
from .message_reactions import MessageReactions
|
||||||
|
from .message_story import MessageStory
|
||||||
from .story import Story
|
from .story import Story
|
||||||
from .story_views import StoryViews
|
from .story_views import StoryViews
|
||||||
from .exported_story_link import ExportedStoryLink
|
from .exported_story_link import ExportedStoryLink
|
||||||
|
|
@ -48,5 +49,5 @@ from .exported_story_link import ExportedStoryLink
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Photo", "Thumbnail",
|
"Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Photo", "Thumbnail",
|
||||||
"StrippedThumbnail", "Poll", "PollOption", "Sticker", "StickerSet", "Venue", "Video", "VideoNote", "Voice", "WebPage", "Dice",
|
"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"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -182,6 +182,9 @@ class Message(Object, Update):
|
||||||
game (:obj:`~pyrogram.types.Game`, *optional*):
|
game (:obj:`~pyrogram.types.Game`, *optional*):
|
||||||
Message is a game, information about the game.
|
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*):
|
video (:obj:`~pyrogram.types.Video`, *optional*):
|
||||||
Message is a video, information about the video.
|
Message is a video, information about the video.
|
||||||
|
|
||||||
|
|
@ -387,6 +390,7 @@ class Message(Object, Update):
|
||||||
sticker: "types.Sticker" = None,
|
sticker: "types.Sticker" = None,
|
||||||
animation: "types.Animation" = None,
|
animation: "types.Animation" = None,
|
||||||
game: "types.Game" = None,
|
game: "types.Game" = None,
|
||||||
|
story: "types.MessageStory" = None,
|
||||||
video: "types.Video" = None,
|
video: "types.Video" = None,
|
||||||
voice: "types.Voice" = None,
|
voice: "types.Voice" = None,
|
||||||
video_note: "types.VideoNote" = None,
|
video_note: "types.VideoNote" = None,
|
||||||
|
|
@ -476,6 +480,7 @@ class Message(Object, Update):
|
||||||
self.sticker = sticker
|
self.sticker = sticker
|
||||||
self.animation = animation
|
self.animation = animation
|
||||||
self.game = game
|
self.game = game
|
||||||
|
self.story = story
|
||||||
self.video = video
|
self.video = video
|
||||||
self.voice = voice
|
self.voice = voice
|
||||||
self.video_note = video_note
|
self.video_note = video_note
|
||||||
|
|
@ -780,6 +785,7 @@ class Message(Object, Update):
|
||||||
contact = None
|
contact = None
|
||||||
venue = None
|
venue = None
|
||||||
game = None
|
game = None
|
||||||
|
story = None
|
||||||
audio = None
|
audio = None
|
||||||
voice = None
|
voice = None
|
||||||
animation = None
|
animation = None
|
||||||
|
|
@ -812,6 +818,9 @@ class Message(Object, Update):
|
||||||
elif isinstance(media, raw.types.MessageMediaGame):
|
elif isinstance(media, raw.types.MessageMediaGame):
|
||||||
game = types.Game._parse(client, message)
|
game = types.Game._parse(client, message)
|
||||||
media_type = enums.MessageMediaType.GAME
|
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):
|
elif isinstance(media, raw.types.MessageMediaDocument):
|
||||||
doc = media.document
|
doc = media.document
|
||||||
|
|
||||||
|
|
@ -940,6 +949,7 @@ class Message(Object, Update):
|
||||||
voice=voice,
|
voice=voice,
|
||||||
animation=animation,
|
animation=animation,
|
||||||
game=game,
|
game=game,
|
||||||
|
story=story,
|
||||||
video=video,
|
video=video,
|
||||||
video_note=video_note,
|
video_note=video_note,
|
||||||
sticker=sticker,
|
sticker=sticker,
|
||||||
|
|
|
||||||
54
pyrogram/types/messages_and_media/message_story.py
Normal file
54
pyrogram/types/messages_and_media/message_story.py
Normal 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
|
||||||
|
)
|
||||||
Loading…
Reference in a new issue