diff --git a/telebot/types.py b/telebot/types.py index defe601..9cc9162 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -117,7 +117,6 @@ 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): @@ -223,7 +222,7 @@ class Chat(JsonDeserializable): def __init__(self, id, type, title=None, username=None, first_name=None, last_name=None, all_members_are_administrators=None, photo=None, description=None, invite_link=None, - pinned_message=None, permissions=None, slow_mode_delay=None, + pinned_message=None, permissions=None, slow_mode_delay=None, sticker_set_name=None, can_set_sticker_set=None): self.id = id self.type = type @@ -859,10 +858,11 @@ class ReplyKeyboardMarkup(JsonSerializable): class KeyboardButton(Dictionaryable, JsonSerializable): - def __init__(self, text, request_contact=None, request_location=None): + def __init__(self, text, request_contact=None, request_location=None, request_poll=None): self.text = text self.request_contact = request_contact self.request_location = request_location + self.request_poll = request_poll def to_json(self): return json.dumps(self.to_dict()) @@ -873,9 +873,19 @@ class KeyboardButton(Dictionaryable, JsonSerializable): json_dict['request_contact'] = self.request_contact if self.request_location: json_dict['request_location'] = self.request_location + if self.request_poll: + json_dict['request_poll'] = self.request_poll.to_dict() return json_dict +class KeyboardButtonPollType(Dictionaryable): + def __init__(self, type=''): + self.type = type + + def to_dict(self): + return {'type': self.type} + + class InlineKeyboardMarkup(Dictionaryable, JsonSerializable): def __init__(self, row_width=3): """ diff --git a/tests/test_types.py b/tests/test_types.py index 18337ed..cc0c4cf 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -188,3 +188,11 @@ def test_json_poll_answer(): assert poll_answer.poll_id == '5895675970559410186' assert isinstance(poll_answer.user, types.User) assert poll_answer.options_ids == [1] + + +def test_KeyboardButtonPollType(): + markup = types.ReplyKeyboardMarkup() + markup.add(types.KeyboardButton('send me a poll', request_poll=types.KeyboardButtonPollType(type='quiz'))) + json_str = markup.to_json() + assert 'request_poll' in json_str + assert 'quiz' in json_str