Implemented polls [From test API]

This commit is contained in:
Alex RootJunior 2019-04-11 00:32:46 +03:00
parent 2a6f36b19b
commit e2e2d9c9fe
10 changed files with 107 additions and 7 deletions

View file

@ -229,6 +229,10 @@ class Methods(Helper):
SET_GAME_SCORE = Item() # setGameScore
GET_GAME_HIGH_SCORES = Item() # getGameHighScores
# Polls
SEND_POLL = Item()
STOP_POLL = Item()
@staticmethod
def api_url(token, method):
"""

View file

@ -2056,3 +2056,20 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
result = await self.request(api.Methods.GET_GAME_HIGH_SCORES, payload)
return [types.GameHighScore(**gamehighscore) for gamehighscore in result]
async def send_poll(self, chat_id: typing.Union[base.Integer, base.String],
question: base.String,
options: typing.List[base.String],
reply_to_message_id: typing.Union[base.Integer, None]):
options = prepare_arg(options)
payload = generate_payload(**locals())
result = await self.request(api.Methods.SEND_POLL, payload)
return types.Message(**result)
async def stop_poll(self, chat_id: typing.Union[base.String, base.Integer],
message_id: base.Integer) -> types.Poll:
payload = generate_payload(**locals())
result = await self.request(api.Methods.STOP_POLL, payload)
return types.Poll(**result)