mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Add request_poll attribute to KeyboardButton;
Add KeyboardButtonPollType object
This commit is contained in:
parent
783fe56566
commit
03b02561a5
@ -117,7 +117,6 @@ class Update(JsonDeserializable):
|
|||||||
self.shipping_query = shipping_query
|
self.shipping_query = shipping_query
|
||||||
self.pre_checkout_query = pre_checkout_query
|
self.pre_checkout_query = pre_checkout_query
|
||||||
self.poll = poll
|
self.poll = poll
|
||||||
self.poll_answer = poll_answer
|
|
||||||
|
|
||||||
|
|
||||||
class WebhookInfo(JsonDeserializable):
|
class WebhookInfo(JsonDeserializable):
|
||||||
@ -223,7 +222,7 @@ class Chat(JsonDeserializable):
|
|||||||
def __init__(self, id, type, title=None, username=None, first_name=None,
|
def __init__(self, id, type, title=None, username=None, first_name=None,
|
||||||
last_name=None, all_members_are_administrators=None,
|
last_name=None, all_members_are_administrators=None,
|
||||||
photo=None, description=None, invite_link=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):
|
sticker_set_name=None, can_set_sticker_set=None):
|
||||||
self.id = id
|
self.id = id
|
||||||
self.type = type
|
self.type = type
|
||||||
@ -859,10 +858,11 @@ class ReplyKeyboardMarkup(JsonSerializable):
|
|||||||
|
|
||||||
|
|
||||||
class KeyboardButton(Dictionaryable, 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.text = text
|
||||||
self.request_contact = request_contact
|
self.request_contact = request_contact
|
||||||
self.request_location = request_location
|
self.request_location = request_location
|
||||||
|
self.request_poll = request_poll
|
||||||
|
|
||||||
def to_json(self):
|
def to_json(self):
|
||||||
return json.dumps(self.to_dict())
|
return json.dumps(self.to_dict())
|
||||||
@ -873,9 +873,19 @@ class KeyboardButton(Dictionaryable, JsonSerializable):
|
|||||||
json_dict['request_contact'] = self.request_contact
|
json_dict['request_contact'] = self.request_contact
|
||||||
if self.request_location:
|
if self.request_location:
|
||||||
json_dict['request_location'] = 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
|
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):
|
class InlineKeyboardMarkup(Dictionaryable, JsonSerializable):
|
||||||
def __init__(self, row_width=3):
|
def __init__(self, row_width=3):
|
||||||
"""
|
"""
|
||||||
|
@ -188,3 +188,11 @@ def test_json_poll_answer():
|
|||||||
assert poll_answer.poll_id == '5895675970559410186'
|
assert poll_answer.poll_id == '5895675970559410186'
|
||||||
assert isinstance(poll_answer.user, types.User)
|
assert isinstance(poll_answer.user, types.User)
|
||||||
assert poll_answer.options_ids == [1]
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user