From 592dcbfedf7fc0c1f02b7fb630e4807bc98c61fc Mon Sep 17 00:00:00 2001 From: oleg Date: Tue, 12 May 2020 10:42:17 +0500 Subject: [PATCH] Add PollAnswer type; Add poll_answer_handler --- telebot/types.py | 1 + tests/test_types.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/telebot/types.py b/telebot/types.py index 9cc9162..cf3d7e9 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -117,6 +117,7 @@ class Update(JsonDeserializable): self.shipping_query = shipping_query self.pre_checkout_query = pre_checkout_query self.poll = poll + self.poll_answer = poll_answer class WebhookInfo(JsonDeserializable): diff --git a/tests/test_types.py b/tests/test_types.py index cc0c4cf..1a4abe8 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -190,6 +190,14 @@ def test_json_poll_answer(): assert poll_answer.options_ids == [1] +def test_json_poll_answer(): + json_string = r'{"poll_id": "qwerty963852741","user": {"id": 111,"is_bot": false,"first_name": "Tele","last_name": "Bot","username": "Telebot","language_code": "ru"},"option_ids": [1, 2]}' + msg = types.PollAnswer.de_json(json_string) + assert isinstance(msg.user, types.User) + assert msg.poll_id == 'qwerty963852741' + assert len(msg.option_ids) == 2 + + def test_KeyboardButtonPollType(): markup = types.ReplyKeyboardMarkup() markup.add(types.KeyboardButton('send me a poll', request_poll=types.KeyboardButtonPollType(type='quiz')))