Skip to content

Commit

Permalink
Remove StoryViews type
Browse files Browse the repository at this point in the history
  • Loading branch information
KurimuzonAkuma committed Dec 6, 2023
1 parent ab4f2ad commit f0e2e6e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 85 deletions.
7 changes: 3 additions & 4 deletions pyrogram/types/messages_and_media/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
from .sticker import Sticker
from .stripped_thumbnail import StrippedThumbnail
from .story import Story
from .story_views import StoryViews
from .thumbnail import Thumbnail
from .venue import Venue
from .video import Video
Expand All @@ -57,7 +56,7 @@
"Animation", "Audio", "BoostsStatus", "Contact", "Document", "ForumTopic", "ForumTopicCreated",
"ForumTopicClosed", "ForumTopicReopened", "ForumTopicEdited", "GeneralTopicHidden",
"GeneralTopicUnhidden", "Game", "GiftCode", "Giveaway", "Location", "Message", "MessageEntity",
"Photo", "Thumbnail", "StrippedThumbnail", "Story", "StoryViews", "Poll", "PollOption",
"Sticker", "Venue", "Video", "VideoNote", "Voice", "WebPage", "Dice", "Reaction",
"WebAppData", "MessageReactions", "MyBoost"
"Photo", "Thumbnail", "StrippedThumbnail", "Story", "Poll", "PollOption", "Sticker", "Venue",
"Video", "VideoNote", "Voice", "WebPage", "Dice", "Reaction", "WebAppData", "MessageReactions",
"MyBoost"
]
32 changes: 26 additions & 6 deletions pyrogram/types/messages_and_media/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,12 @@ class Story(Object, Update):
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.
views (:obj:`~pyrogram.types.StoryViews`, *optional*):
views (``int``, *optional*):
Stories views.
forwards (``int``, *optional*):
Stories forwards.
privacy (:obj:`~pyrogram.enums.StoryPrivacyRules`, *optional*):
Story privacy.
Expand All @@ -110,6 +113,9 @@ class Story(Object, Update):
disallowed_users (List of ``int`` | ``str``, *optional*):
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*):
The story is skipped.
A story can be skipped in case it was skipped.
Expand Down Expand Up @@ -147,10 +153,12 @@ def __init__(
selected_contacts: bool = None,
caption: str = None,
caption_entities: List["types.MessageEntity"] = None,
views: "types.StoryViews" = None,
views: int = None,
forwards: int = None,
privacy: "enums.StoryPrivacyRules" = None,
allowed_users: List[Union[int, str]] = None,
disallowed_users: List[Union[int, str]] = None,
reactions: List["types.Reaction"] = None,
skipped: bool = None,
deleted: bool = None
):
Expand Down Expand Up @@ -179,9 +187,11 @@ def __init__(
self.caption = caption
self.caption_entities = caption_entities
self.views = views
self.forwards = forwards
self.privacy = privacy
self.allowed_users = allowed_users
self.disallowed_users = disallowed_users
self.reactions = reactions
self.skipped = skipped
self.deleted = deleted

Expand Down Expand Up @@ -230,6 +240,9 @@ async def _parse(
allowed_users = None
disallowed_users = None
media_type = None
views = None
forwards = None
reactions = 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
Expand All @@ -239,9 +252,6 @@ async def _parse(
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 client.get_stories(chat.id, story.id)
return Story(client=client, id=story.id, from_user=from_user, sender_chat=sender_chat, chat=chat)

forward_from = None
forward_sender_name = None
Expand All @@ -260,6 +270,14 @@ async def _parse(
forward_from_chat = types.Chat._parse_channel_chat(client, chats[raw_peer_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):
photo = types.Photo._parse(client, story.media.photo, story.media.ttl_seconds)
media_type = enums.MessageMediaType.PHOTO
Expand Down Expand Up @@ -314,10 +332,12 @@ async def _parse(
selected_contacts=story.selected_contacts,
caption=story.caption,
caption_entities=entities or None,
views=types.StoryViews._parse(client, story.views) if story.views else None,
views=views,
forwards=forwards,
privacy=privacy,
allowed_users=allowed_users,
disallowed_users=disallowed_users,
reactions=reactions,
client=client
)

Expand Down
75 changes: 0 additions & 75 deletions pyrogram/types/messages_and_media/story_views.py

This file was deleted.

0 comments on commit f0e2e6e

Please sign in to comment.