mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-27 16:45:19 +00:00
Remove StoryViews type
This commit is contained in:
parent
8053ce4589
commit
05e453a8d1
@ -42,7 +42,6 @@ from .reaction import Reaction
|
|||||||
from .sticker import Sticker
|
from .sticker import Sticker
|
||||||
from .stripped_thumbnail import StrippedThumbnail
|
from .stripped_thumbnail import StrippedThumbnail
|
||||||
from .story import Story
|
from .story import Story
|
||||||
from .story_views import StoryViews
|
|
||||||
from .thumbnail import Thumbnail
|
from .thumbnail import Thumbnail
|
||||||
from .venue import Venue
|
from .venue import Venue
|
||||||
from .video import Video
|
from .video import Video
|
||||||
@ -57,7 +56,7 @@ __all__ = [
|
|||||||
"Animation", "Audio", "BoostsStatus", "Contact", "Document", "ForumTopic", "ForumTopicCreated",
|
"Animation", "Audio", "BoostsStatus", "Contact", "Document", "ForumTopic", "ForumTopicCreated",
|
||||||
"ForumTopicClosed", "ForumTopicReopened", "ForumTopicEdited", "GeneralTopicHidden",
|
"ForumTopicClosed", "ForumTopicReopened", "ForumTopicEdited", "GeneralTopicHidden",
|
||||||
"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", "Poll", "PollOption", "Sticker", "Venue",
|
||||||
"Sticker", "Venue", "Video", "VideoNote", "Voice", "WebPage", "Dice", "Reaction",
|
"Video", "VideoNote", "Voice", "WebPage", "Dice", "Reaction", "WebAppData", "MessageReactions",
|
||||||
"WebAppData", "MessageReactions", "MyBoost"
|
"MyBoost"
|
||||||
]
|
]
|
||||||
|
@ -98,9 +98,12 @@ class Story(Object, Update):
|
|||||||
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`, *optional*):
|
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`, *optional*):
|
||||||
For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the caption.
|
For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the caption.
|
||||||
|
|
||||||
views (:obj:`~pyrogram.types.StoryViews`, *optional*):
|
views (``int``, *optional*):
|
||||||
Stories views.
|
Stories views.
|
||||||
|
|
||||||
|
forwards (``int``, *optional*):
|
||||||
|
Stories forwards.
|
||||||
|
|
||||||
privacy (:obj:`~pyrogram.enums.StoryPrivacyRules`, *optional*):
|
privacy (:obj:`~pyrogram.enums.StoryPrivacyRules`, *optional*):
|
||||||
Story privacy.
|
Story privacy.
|
||||||
|
|
||||||
@ -110,6 +113,9 @@ class Story(Object, Update):
|
|||||||
disallowed_users (List of ``int`` | ``str``, *optional*):
|
disallowed_users (List of ``int`` | ``str``, *optional*):
|
||||||
List of user_ids whos denied to view the story.
|
List of user_ids whos denied to view the story.
|
||||||
|
|
||||||
|
reactions (List of :obj:`~pyrogram.types.Reaction`):
|
||||||
|
List of the reactions to this story.
|
||||||
|
|
||||||
skipped (``bool``, *optional*):
|
skipped (``bool``, *optional*):
|
||||||
The story is skipped.
|
The story is skipped.
|
||||||
A story can be skipped in case it was skipped.
|
A story can be skipped in case it was skipped.
|
||||||
@ -147,10 +153,12 @@ class Story(Object, Update):
|
|||||||
selected_contacts: bool = None,
|
selected_contacts: bool = None,
|
||||||
caption: str = None,
|
caption: str = None,
|
||||||
caption_entities: List["types.MessageEntity"] = None,
|
caption_entities: List["types.MessageEntity"] = None,
|
||||||
views: "types.StoryViews" = None,
|
views: int = None,
|
||||||
|
forwards: int = None,
|
||||||
privacy: "enums.StoryPrivacyRules" = None,
|
privacy: "enums.StoryPrivacyRules" = None,
|
||||||
allowed_users: List[Union[int, str]] = None,
|
allowed_users: List[Union[int, str]] = None,
|
||||||
disallowed_users: List[Union[int, str]] = None,
|
disallowed_users: List[Union[int, str]] = None,
|
||||||
|
reactions: List["types.Reaction"] = None,
|
||||||
skipped: bool = None,
|
skipped: bool = None,
|
||||||
deleted: bool = None
|
deleted: bool = None
|
||||||
):
|
):
|
||||||
@ -179,9 +187,11 @@ class Story(Object, Update):
|
|||||||
self.caption = caption
|
self.caption = caption
|
||||||
self.caption_entities = caption_entities
|
self.caption_entities = caption_entities
|
||||||
self.views = views
|
self.views = views
|
||||||
|
self.forwards = forwards
|
||||||
self.privacy = privacy
|
self.privacy = privacy
|
||||||
self.allowed_users = allowed_users
|
self.allowed_users = allowed_users
|
||||||
self.disallowed_users = disallowed_users
|
self.disallowed_users = disallowed_users
|
||||||
|
self.reactions = reactions
|
||||||
self.skipped = skipped
|
self.skipped = skipped
|
||||||
self.deleted = deleted
|
self.deleted = deleted
|
||||||
|
|
||||||
@ -230,6 +240,9 @@ class Story(Object, Update):
|
|||||||
allowed_users = None
|
allowed_users = None
|
||||||
disallowed_users = None
|
disallowed_users = None
|
||||||
media_type = None
|
media_type = None
|
||||||
|
views = None
|
||||||
|
forwards = None
|
||||||
|
reactions = None
|
||||||
|
|
||||||
from_user = types.User._parse(client, users.get(peer_id, None))
|
from_user = types.User._parse(client, users.get(peer_id, None))
|
||||||
sender_chat = types.Chat._parse_channel_chat(client, chats[peer_id]) if not from_user else None
|
sender_chat = types.Chat._parse_channel_chat(client, chats[peer_id]) if not from_user else None
|
||||||
@ -259,6 +272,14 @@ class Story(Object, Update):
|
|||||||
forward_from_chat = types.Chat._parse_channel_chat(client, chats[raw_peer_id])
|
forward_from_chat = types.Chat._parse_channel_chat(client, chats[raw_peer_id])
|
||||||
forward_from_story_id = forward_header.story_id
|
forward_from_story_id = forward_header.story_id
|
||||||
|
|
||||||
|
if story.views:
|
||||||
|
views=getattr(story.views, "views_count", None)
|
||||||
|
forwards=getattr(story.views, "forwards_count", None)
|
||||||
|
reactions=[
|
||||||
|
types.Reaction._parse_count(client, reaction)
|
||||||
|
for reaction in getattr(story.views, "reactions", [])
|
||||||
|
] or None
|
||||||
|
|
||||||
if isinstance(story.media, raw.types.MessageMediaPhoto):
|
if isinstance(story.media, raw.types.MessageMediaPhoto):
|
||||||
photo = types.Photo._parse(client, story.media.photo, story.media.ttl_seconds)
|
photo = types.Photo._parse(client, story.media.photo, story.media.ttl_seconds)
|
||||||
media_type = enums.MessageMediaType.PHOTO
|
media_type = enums.MessageMediaType.PHOTO
|
||||||
@ -313,10 +334,12 @@ class Story(Object, Update):
|
|||||||
selected_contacts=story.selected_contacts,
|
selected_contacts=story.selected_contacts,
|
||||||
caption=story.caption,
|
caption=story.caption,
|
||||||
caption_entities=entities or None,
|
caption_entities=entities or None,
|
||||||
views=types.StoryViews._parse(client, story.views) if story.views else None,
|
views=views,
|
||||||
|
forwards=forwards,
|
||||||
privacy=privacy,
|
privacy=privacy,
|
||||||
allowed_users=allowed_users,
|
allowed_users=allowed_users,
|
||||||
disallowed_users=disallowed_users,
|
disallowed_users=disallowed_users,
|
||||||
|
reactions=reactions,
|
||||||
client=client
|
client=client
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,75 +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/>.
|
|
||||||
|
|
||||||
from pyrogram import raw, types
|
|
||||||
from typing import List
|
|
||||||
from ..object import Object
|
|
||||||
|
|
||||||
class StoryViews(Object):
|
|
||||||
"""Contains information about a story viewers.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
views_count (``int`` ``32-bit``):
|
|
||||||
Views count.
|
|
||||||
|
|
||||||
has_viewers (``bool``, *optional*):
|
|
||||||
Has viewers.
|
|
||||||
|
|
||||||
forwards_count (``int`` ``32-bit``, *optional*):
|
|
||||||
Forwards count.
|
|
||||||
|
|
||||||
reactions (List of :obj:`~pyrogram.types.Reaction`, *optional*):
|
|
||||||
Reactions list.
|
|
||||||
|
|
||||||
reactions_count (``int`` ``32-bit``, *optional*):
|
|
||||||
Reactions count.
|
|
||||||
|
|
||||||
recent_viewers (List of ``int`` ``64-bit``, *optional*):
|
|
||||||
Viewers list.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self, *,
|
|
||||||
views_count: int,
|
|
||||||
has_viewers: bool = None,
|
|
||||||
forwards_count: int = None,
|
|
||||||
reactions: List["types.Reaction"] = None,
|
|
||||||
reactions_count: int = None,
|
|
||||||
recent_viewers: List[int] = None
|
|
||||||
):
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
self.views_count = views_count
|
|
||||||
self.has_viewers = has_viewers
|
|
||||||
self.forwards_count = forwards_count
|
|
||||||
self.reactions = reactions
|
|
||||||
self.reactions_count = reactions_count
|
|
||||||
self.recent_viewers = recent_viewers
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _parse(client, storyviews: "raw.types.StoryViews") -> "StoryViews":
|
|
||||||
return StoryViews(
|
|
||||||
views_count=getattr(storyviews, "views_count", None),
|
|
||||||
has_viewers=getattr(storyviews, "has_viewers", None),
|
|
||||||
forwards_count=getattr(storyviews, "forwards_count", None),
|
|
||||||
reactions=[
|
|
||||||
types.Reaction._parse_count(client, reaction)
|
|
||||||
for reaction in getattr(storyviews, "reactions", [])
|
|
||||||
] or None,
|
|
||||||
recent_viewers=getattr(storyviews, "recent_viewers", None) or None,
|
|
||||||
)
|
|
Loading…
Reference in New Issue
Block a user