Remove MessageStory type

This commit is contained in:
KurimuzonAkuma 2023-12-06 12:42:39 +03:00
parent 7b199bde9c
commit d99c3f511c
5 changed files with 13 additions and 66 deletions

View File

@ -457,7 +457,6 @@ def pyrogram_api():
WebAppData WebAppData
MessageReactions MessageReactions
ChatReactions ChatReactions
MessageStory
Story Story
StoryViews StoryViews
MyBoost MyBoost

View File

@ -51,7 +51,6 @@ 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 .my_boost import MyBoost from .my_boost import MyBoost
__all__ = [ __all__ = [
@ -60,5 +59,5 @@ __all__ = [
"GeneralTopicUnhidden", "Game", "GiftCode", "Giveaway", "Location", "Message", "MessageEntity", "GeneralTopicUnhidden", "Game", "GiftCode", "Giveaway", "Location", "Message", "MessageEntity",
"Photo", "Thumbnail", "StrippedThumbnail", "Story", "StoryViews", "Poll", "PollOption", "Photo", "Thumbnail", "StrippedThumbnail", "Story", "StoryViews", "Poll", "PollOption",
"Sticker", "Venue", "Video", "VideoNote", "Voice", "WebPage", "Dice", "Reaction", "Sticker", "Venue", "Video", "VideoNote", "Voice", "WebPage", "Dice", "Reaction",
"WebAppData", "MessageReactions", "MessageStory", "MyBoost" "WebAppData", "MessageReactions", "MyBoost"
] ]

View File

@ -201,7 +201,7 @@ class Message(Object, Update):
giveaway (:obj:`~pyrogram.types.Giveaway`, *optional*): giveaway (:obj:`~pyrogram.types.Giveaway`, *optional*):
Message is a giveaway, information about the giveaway. 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. Message is a story, information about the story.
video (:obj:`~pyrogram.types.Video`, *optional*): video (:obj:`~pyrogram.types.Video`, *optional*):
@ -415,7 +415,7 @@ class Message(Object, Update):
animation: "types.Animation" = None, animation: "types.Animation" = None,
game: "types.Game" = None, game: "types.Game" = None,
giveaway: "types.Giveaway" = None, giveaway: "types.Giveaway" = None,
story: "types.MessageStory" = None, story: "types.Story" = 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,
@ -867,7 +867,13 @@ class Message(Object, Update):
giveaway = types.Giveaway._parse(client, media, chats) giveaway = types.Giveaway._parse(client, media, chats)
media_type = enums.MessageMediaType.GIVEAWAY media_type = enums.MessageMediaType.GIVEAWAY
elif isinstance(media, raw.types.MessageMediaStory): 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 media_type = enums.MessageMediaType.STORY
elif isinstance(media, raw.types.MessageMediaDocument): elif isinstance(media, raw.types.MessageMediaDocument):
doc = media.document doc = media.document

View File

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

View File

@ -135,7 +135,7 @@ class Story(Object, Update):
forward_from_chat: "types.Chat" = None, forward_from_chat: "types.Chat" = None,
forward_from_story_id: int = None, forward_from_story_id: int = None,
expire_date: datetime = None, expire_date: datetime = None,
media: "enums.MessageMediaType", media: "enums.MessageMediaType" = None,
has_protected_content: bool = None, has_protected_content: bool = None,
photo: "types.Photo" = None, photo: "types.Photo" = None,
video: "types.Video" = 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) 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): 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) 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_from = None
forward_sender_name = None forward_sender_name = None