@@ -1289,6 +1289,12 @@ class Message(JsonDeserializable):
12891289 :param paid_message_price_changed: Optional. Service message: the price for paid messages has changed in the chat
12901290 :type paid_message_price_changed: :class:`telebot.types.PaidMessagePriceChanged`
12911291
1292+ :param poll_option_added: Optional. Service message: answer option was added to a poll
1293+ :type poll_option_added: :class:`telebot.types.PollOptionAdded`
1294+
1295+ :param poll_option_deleted: Optional. Service message: answer option was deleted from a poll
1296+ :type poll_option_deleted: :class:`telebot.types.PollOptionDeleted`
1297+
12921298 :param suggested_post_approved: Optional. Service message: a suggested post was approved
12931299 :type suggested_post_approved: :class:`telebot.types.SuggestedPostApproved
12941300
@@ -1621,6 +1627,12 @@ def de_json(cls, json_string):
16211627 if 'managed_bot_created' in obj:
16221628 opts['managed_bot_created'] = ManagedBotCreated.de_json(obj['managed_bot_created'])
16231629 content_type = 'managed_bot_created'
1630+ if 'poll_option_added' in obj:
1631+ opts['poll_option_added'] = PollOptionAdded.de_json(obj['poll_option_added'])
1632+ content_type = 'poll_option_added'
1633+ if 'poll_option_deleted' in obj:
1634+ opts['poll_option_deleted'] = PollOptionDeleted.de_json(obj['poll_option_deleted'])
1635+ content_type = 'poll_option_deleted'
16241636
16251637 return cls(message_id, from_user, date, chat, content_type, opts, json_string)
16261638
@@ -1761,6 +1773,8 @@ def __init__(self, message_id, from_user, date, chat, content_type, options, jso
17611773 self.chat_owner_left: Optional[ChatOwnerLeft] = None
17621774 self.chat_owner_changed: Optional[ChatOwnerChanged] = None
17631775 self.managed_bot_created: Optional[ManagedBotCreated] = None
1776+ self.poll_option_added: Optional[PollOptionAdded] = None
1777+ self.poll_option_deleted: Optional[PollOptionDeleted] = None
17641778
17651779 for key in options:
17661780 setattr(self, key, options[key])
@@ -13899,4 +13913,95 @@ def to_dict(self):
1389913913 data = {
1390013914 'id': self.id
1390113915 }
13902- return data
13916+ return data
13917+
13918+
13919+ class PollOptionAdded(JsonDeserializable):
13920+ """
13921+ Describes a service message about an option added to a poll.
13922+
13923+ Telegram documentation: https://core.telegram.org/bots/api#polloptionadded
13924+
13925+ :param poll_message: Optional. Message containing the poll to which the option was added, if known. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply.
13926+ :type poll_message: :class:`MaybeInaccessibleMessage`
13927+
13928+ :param option_persistent_id: Unique identifier of the added option
13929+ :type option_persistent_id: :obj:`str`
13930+
13931+ :param option_text: Option text
13932+ :type option_text: :obj:`str`
13933+
13934+ :param option_text_entities: Optional. Special entities that appear in the option_text
13935+ :type option_text_entities: :obj:`list` of :class:`MessageEntity`
13936+
13937+ :return: Instance of the class
13938+ :rtype: :class:`PollOptionAdded`
13939+ """
13940+ def __init__(self, option_persistent_id: str, option_text: str,
13941+ poll_message: Optional[Union[InaccessibleMessage, Message]] = None,
13942+ option_text_entities: Optional[List[MessageEntity]] = None, **kwargs):
13943+ self.poll_message: Optional[Union[InaccessibleMessage, Message]] = poll_message
13944+ self.option_persistent_id: str = option_persistent_id
13945+ self.option_text: str = option_text
13946+ self.option_text_entities: Optional[List[MessageEntity]] = option_text_entities
13947+
13948+ @classmethod
13949+ def de_json(cls, json_string):
13950+ if json_string is None: return None
13951+ obj = cls.check_json(json_string)
13952+ if 'poll_message' in obj:
13953+ # if date is 0, then the message is inaccessible, otherwise it is accessible
13954+ poll_message = obj['poll_message']
13955+ if poll_message['date'] == 0:
13956+ obj['poll_message'] = InaccessibleMessage.de_json(poll_message)
13957+ else:
13958+ obj['poll_message'] = Message.de_json(poll_message)
13959+ if 'option_text_entities' in obj:
13960+ obj['option_text_entities'] = [MessageEntity.de_json(entity) for entity in obj['option_text_entities']]
13961+ return cls(**obj)
13962+
13963+
13964+ class PollOptionDeleted(JsonDeserializable):
13965+ """
13966+ Describes a service message about an option deleted from a poll.
13967+
13968+ Telegram documentation: https://core.telegram.org/bots/api#polloptiondeleted
13969+
13970+ :param poll_message: Optional. Message containing the poll from which the option was deleted, if known. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply.
13971+ :type poll_message: :class:`MaybeInaccessibleMessage`
13972+
13973+ :param option_persistent_id: Unique identifier of the deleted option
13974+ :type option_persistent_id: :obj:`str`
13975+
13976+ :param option_text: Option text
13977+ :type option_text: :obj:`str`
13978+
13979+ :param option_text_entities: Optional. Special entities that appear in the option_text
13980+ :type option_text_entities: :obj:`list` of :class:`MessageEntity`
13981+
13982+ :return: Instance of the class
13983+ :rtype: :class:`PollOptionDeleted`
13984+ """
13985+ def __init__(self, option_persistent_id: str, option_text: str,
13986+ poll_message: Optional[Union[InaccessibleMessage, Message]] = None,
13987+ option_text_entities: Optional[List[MessageEntity]] = None, **kwargs):
13988+ self.poll_message: Optional[Union[InaccessibleMessage, Message]] = poll_message
13989+ self.option_persistent_id: str = option_persistent_id
13990+ self.option_text: str = option_text
13991+ self.option_text_entities: Optional[List[MessageEntity]] = option_text_entities
13992+
13993+ @classmethod
13994+ def de_json(cls, json_string):
13995+ if json_string is None: return None
13996+ obj = cls.check_json(json_string)
13997+ if 'poll_message' in obj:
13998+ # if date is 0, then the message is inaccessible, otherwise it is accessible
13999+ poll_message = obj['poll_message']
14000+ if poll_message['date'] == 0:
14001+ obj['poll_message'] = InaccessibleMessage.de_json(poll_message)
14002+ else:
14003+ obj['poll_message'] = Message.de_json(poll_message)
14004+ if 'option_text_entities' in obj:
14005+ obj['option_text_entities'] = [MessageEntity.de_json(entity) for entity in obj['option_text_entities']]
14006+ return cls(**obj)
14007+
0 commit comments