Skip to content

Commit

Permalink
Fix minor bugs in types.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Badiboy authored Jan 3, 2024
1 parent 9831ae2 commit 71f53d3
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions telebot/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,14 +1272,10 @@ def de_json(cls, json_string):
content_type = 'story'
if 'external_reply' in obj:
opts['external_reply'] = ExternalReplyInfo.de_json(obj['external_reply'])
content_type = 'text' # @Badiboy not sure about content_types in here, please check
if 'quote' in obj:
opts['quote'] = TextQuote.de_json(obj['quote'])
content_type = 'text' # Here too, check the content types

if 'link_preview_options' in obj:
opts['link_preview_options'] = LinkPreviewOptions.de_json(obj['link_preview_options'])

if 'giveaway_created' in obj:
opts['giveaway_created'] = GiveawayCreated.de_json(obj['giveaway_created'])
content_type = 'giveaway_created'
Expand Down Expand Up @@ -1396,7 +1392,7 @@ def __init__(self, message_id, from_user, date, chat, content_type, options, jso
self.story: Optional[Story] = None
self.external_reply: Optional[ExternalReplyInfo] = None
self.quote: Optional[TextQuote] = None
self.LinkPreviewOptions: Optional[LinkPreviewOptions] = None
self.link_preview_options: Optional[LinkPreviewOptions] = None
self.giveaway_created: Optional[GiveawayCreated] = None
self.giveaway: Optional[Giveaway] = None
self.giveaway_winners: Optional[GiveawayWinners] = None
Expand Down Expand Up @@ -3713,7 +3709,7 @@ class InputTextMessageContent(Dictionaryable):
parse_mode
:type entities: :obj:`list` of :class:`telebot.types.MessageEntity`
:param disable_web_page_preview: Optional. Disables link previews for links in the sent message
:param disable_web_page_preview: Optional, deprecated. Disables link previews for links in the sent message
:type disable_web_page_preview: :obj:`bool`
:return: Instance of the class
Expand All @@ -3724,11 +3720,13 @@ def __init__(self, message_text, parse_mode=None, entities=None, disable_web_pag
self.parse_mode: str = parse_mode
self.entities: List[MessageEntity] = entities
link_preview_options: LinkPreviewOptions = link_preview_options
if disable_web_page_preview is not None and link_preview_options is None:
# deprecated
self.link_preview_options: LinkPreviewOptions = LinkPreviewOptions(disable_web_page_preview)
if disable_web_page_preview is not None:
logger.warning("The parameter 'disable_web_page_preview' is deprecated. Use 'link_preview_options' instead.")


if link_preview_options:
logger.warning("Both 'link_preview_options' and 'disable_web_page_preview' parameters are set: conflicting, 'disable_web_page_preview' is deprecated")
else:
self.link_preview_options: LinkPreviewOptions = LinkPreviewOptions(disable_web_page_preview)

def to_dict(self):
json_dict = {'message_text': self.message_text}
Expand Down Expand Up @@ -9215,4 +9213,4 @@ def de_json(cls, json_string):
obj['chat'] = Chat.de_json(obj.get('chat'))

return cls(**obj)


0 comments on commit 71f53d3

Please sign in to comment.