mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-23 23:34:28 +00:00
Remove MessageStory type
This commit is contained in:
parent
7b199bde9c
commit
d99c3f511c
@ -457,7 +457,6 @@ def pyrogram_api():
|
||||
WebAppData
|
||||
MessageReactions
|
||||
ChatReactions
|
||||
MessageStory
|
||||
Story
|
||||
StoryViews
|
||||
MyBoost
|
||||
|
@ -51,7 +51,6 @@ 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 .my_boost import MyBoost
|
||||
|
||||
__all__ = [
|
||||
@ -60,5 +59,5 @@ __all__ = [
|
||||
"GeneralTopicUnhidden", "Game", "GiftCode", "Giveaway", "Location", "Message", "MessageEntity",
|
||||
"Photo", "Thumbnail", "StrippedThumbnail", "Story", "StoryViews", "Poll", "PollOption",
|
||||
"Sticker", "Venue", "Video", "VideoNote", "Voice", "WebPage", "Dice", "Reaction",
|
||||
"WebAppData", "MessageReactions", "MessageStory", "MyBoost"
|
||||
"WebAppData", "MessageReactions", "MyBoost"
|
||||
]
|
||||
|
@ -201,7 +201,7 @@ class Message(Object, Update):
|
||||
giveaway (:obj:`~pyrogram.types.Giveaway`, *optional*):
|
||||
Message is a giveaway, information about the giveaway.
|
||||
|
||||
story (:obj:`~pyrogram.types.MessageStory`, *optional*):
|
||||
story (:obj:`~pyrogram.types.Story`, *optional*):
|
||||
Message is a story, information about the story.
|
||||
|
||||
video (:obj:`~pyrogram.types.Video`, *optional*):
|
||||
@ -415,7 +415,7 @@ class Message(Object, Update):
|
||||
animation: "types.Animation" = None,
|
||||
game: "types.Game" = None,
|
||||
giveaway: "types.Giveaway" = None,
|
||||
story: "types.MessageStory" = None,
|
||||
story: "types.Story" = None,
|
||||
video: "types.Video" = None,
|
||||
voice: "types.Voice" = None,
|
||||
video_note: "types.VideoNote" = None,
|
||||
@ -867,7 +867,13 @@ class Message(Object, Update):
|
||||
giveaway = types.Giveaway._parse(client, media, chats)
|
||||
media_type = enums.MessageMediaType.GIVEAWAY
|
||||
elif isinstance(media, raw.types.MessageMediaStory):
|
||||
story = types.MessageStory._parse(client, media, users, chats)
|
||||
if not media.story:
|
||||
story = await client.get_stories(utils.get_peer_id(media.peer), media.id)
|
||||
if not story:
|
||||
story = await types.Story._parse(client, media, users, chats, media.peer)
|
||||
else:
|
||||
story = await types.Story._parse(client, media.story, users, chats, media.peer)
|
||||
|
||||
media_type = enums.MessageMediaType.STORY
|
||||
elif isinstance(media, raw.types.MessageMediaDocument):
|
||||
doc = media.document
|
||||
|
@ -1,59 +0,0 @@
|
||||
# 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/>.
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw, types, utils
|
||||
from ..object import Object
|
||||
|
||||
|
||||
class MessageStory(Object):
|
||||
"""Contains information about a forwarded story.
|
||||
|
||||
Parameters:
|
||||
chat (:obj:`~pyrogram.types.Chat`):
|
||||
Conversation the story belongs to.
|
||||
|
||||
story_id (``int``):
|
||||
Unique story identifier.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
chat: "types.Chat",
|
||||
story_id: int
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
self.chat = chat
|
||||
self.story_id = story_id
|
||||
|
||||
@staticmethod
|
||||
def _parse(client: "pyrogram.Client", message_story: "raw.types.MessageMediaStory", users, chats) -> "MessageStory":
|
||||
peer_id = utils.get_raw_peer_id(message_story.peer)
|
||||
|
||||
if isinstance(message_story.peer, raw.types.PeerChannel):
|
||||
chat = types.Chat._parse_channel_chat(client, chats.get(peer_id, None))
|
||||
else:
|
||||
chat = types.Chat._parse_user_chat(client, users.get(peer_id, None))
|
||||
|
||||
return MessageStory(
|
||||
chat=chat,
|
||||
story_id=message_story.id
|
||||
)
|
@ -135,7 +135,7 @@ class Story(Object, Update):
|
||||
forward_from_chat: "types.Chat" = None,
|
||||
forward_from_story_id: int = None,
|
||||
expire_date: datetime = None,
|
||||
media: "enums.MessageMediaType",
|
||||
media: "enums.MessageMediaType" = None,
|
||||
has_protected_content: bool = None,
|
||||
photo: "types.Photo" = None,
|
||||
video: "types.Video" = None,
|
||||
@ -239,6 +239,8 @@ class Story(Object, Update):
|
||||
return Story(client=client, id=story.id, deleted=True, from_user=from_user, sender_chat=sender_chat, chat=chat)
|
||||
if isinstance(story, raw.types.StoryItemSkipped):
|
||||
return Story(client=client, id=story.id, skipped=True, from_user=from_user, sender_chat=sender_chat, chat=chat)
|
||||
if isinstance(story, raw.types.MessageMediaStory):
|
||||
return Story(client=client, id=story.id, from_user=from_user, sender_chat=sender_chat, chat=chat)
|
||||
|
||||
forward_from = None
|
||||
forward_sender_name = None
|
||||
|
Loading…
Reference in New Issue
Block a user