Skip to content

Commit

Permalink
Support for stories: is_forwarded_story, story object
Browse files Browse the repository at this point in the history
  • Loading branch information
coder2020official committed Aug 18, 2023
1 parent a5cc2f5 commit b5112d8
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions telebot/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,9 @@ class Message(JsonDeserializable):
:param sticker: Optional. Message is a sticker, information about the sticker
:type sticker: :class:`telebot.types.Sticker`
:param story: Optional. Message is a forwarded story
:type story: :class:`telebot.types.Story`
:param video: Optional. Message is a video, information about the video
:type video: :class:`telebot.types.Video`
Expand Down Expand Up @@ -1177,6 +1180,9 @@ def de_json(cls, json_string):
if 'chat_shared' in obj:
opts['chat_shared'] = ChatShared.de_json(obj['chat_shared'])
content_type = 'chat_shared'
if 'story' in obj:
opts['story'] = Story.de_json(obj['story'])
content_type = 'story'
return cls(message_id, from_user, date, chat, content_type, opts, json_string)

@classmethod
Expand Down Expand Up @@ -1274,10 +1280,19 @@ def __init__(self, message_id, from_user, date, chat, content_type, options, jso
self.write_access_allowed: Optional[WriteAccessAllowed] = None
self.user_shared: Optional[UserShared] = None
self.chat_shared: Optional[ChatShared] = None
self.story: Optional[Story] = None
for key in options:
setattr(self, key, options[key])
self.json = json_string

@property
def is_forwarded_story(self):
"""
Returns True if the message is a forwarded story.
"""
# TODO: In future updates this propery might require changes.
return True if self.story is not None else False

def __html_text(self, text, entities):
"""
Author: @sviat9440
Expand Down Expand Up @@ -7743,3 +7758,18 @@ def to_dict(self) -> dict:

def to_json(self) -> str:
return json.dumps(self.to_dict())


class Story(JsonDeserializable):
"""
This object represents a message about a forwarded story in the chat.
Currently holds no information.
"""

@classmethod
def de_json(cls, json_string):
return cls()

def __init__(self) -> None:
pass

0 comments on commit b5112d8

Please sign in to comment.