mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Implemented polls [From test API]
This commit is contained in:
parent
2a6f36b19b
commit
e2e2d9c9fe
10 changed files with 107 additions and 7 deletions
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue