mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
- Update docstring of KeyboardButton
- Fix PollAnswer model and export it from `aiogram.types` - Fix dispatcher poll_answer handlers registration - Add actions to LoggingMiddleware
This commit is contained in:
parent
a8debbba04
commit
ca9a4440d1
5 changed files with 25 additions and 6 deletions
|
|
@ -146,6 +146,20 @@ class LoggingMiddleware(BaseMiddleware):
|
|||
if timeout > 0:
|
||||
self.logger.info(f"Process update [ID:{update.update_id}]: [failed] (in {timeout} ms)")
|
||||
|
||||
async def on_pre_process_poll(self, poll, data):
|
||||
self.logger.info(f"Received poll [ID:{poll.id}]")
|
||||
|
||||
async def on_post_process_poll(self, poll, results, data):
|
||||
self.logger.debug(f"{HANDLED_STR[bool(len(results))]} poll [ID:{poll.id}]")
|
||||
|
||||
async def on_pre_process_poll_answer(self, poll_answer, data):
|
||||
self.logger.info(f"Received poll answer [ID:{poll_answer.poll_id}] "
|
||||
f"from user [ID:{poll_answer.user.id}]")
|
||||
|
||||
async def on_post_process_poll_answer(self, poll_answer, results, data):
|
||||
self.logger.debug(f"{HANDLED_STR[bool(len(results))]} poll answer [ID:{poll_answer.poll_id}] "
|
||||
f"from user [ID:{poll_answer.user.id}]")
|
||||
|
||||
|
||||
class LoggingFilter(logging.Filter):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -917,7 +917,7 @@ class Dispatcher(DataMixin, ContextInstanceMixin):
|
|||
filters_set = self.filters_factory.resolve(self.poll_answer_handlers,
|
||||
*custom_filters,
|
||||
**kwargs)
|
||||
self.poll_handlers.register(self._wrap_async_task(callback, run_task), filters_set)
|
||||
self.poll_answer_handlers.register(self._wrap_async_task(callback, run_task), filters_set)
|
||||
|
||||
def poll_answer_handler(self, *custom_filters, run_task=None, **kwargs):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ from .passport_element_error import PassportElementError, PassportElementErrorDa
|
|||
PassportElementErrorSelfie
|
||||
from .passport_file import PassportFile
|
||||
from .photo_size import PhotoSize
|
||||
from .poll import PollOption, Poll
|
||||
from .poll import PollOption, Poll, PollAnswer
|
||||
from .pre_checkout_query import PreCheckoutQuery
|
||||
from .reply_keyboard import KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove
|
||||
from .response_parameters import ResponseParameters
|
||||
|
|
@ -147,6 +147,7 @@ __all__ = (
|
|||
'PassportFile',
|
||||
'PhotoSize',
|
||||
'Poll',
|
||||
'PollAnswer',
|
||||
'PollOption',
|
||||
'PreCheckoutQuery',
|
||||
'ReplyKeyboardMarkup',
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class PollAnswer(base.TelegramObject):
|
|||
https://core.telegram.org/bots/api#pollanswer
|
||||
"""
|
||||
poll_id: base.String = fields.Field()
|
||||
user: User = fields.Field()
|
||||
user: User = fields.Field(base=User)
|
||||
option_ids: typing.List[base.Integer] = fields.ListField()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -93,9 +93,13 @@ class ReplyKeyboardMarkup(base.TelegramObject):
|
|||
|
||||
class KeyboardButton(base.TelegramObject):
|
||||
"""
|
||||
This object represents one button of the reply keyboard. For simple text buttons String can be used instead of this object to specify text of the button. Optional fields request_contact, request_location, and request_poll are mutually exclusive.
|
||||
Note: request_contact and request_location options will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
|
||||
Note: request_poll option will only work in Telegram versions released after 23 January, 2020. Older clients will receive unsupported message.
|
||||
This object represents one button of the reply keyboard.
|
||||
For simple text buttons String can be used instead of this object to specify text of the button.
|
||||
Optional fields request_contact, request_location, and request_poll are mutually exclusive.
|
||||
Note: request_contact and request_location options will only work in Telegram versions released after 9 April, 2016.
|
||||
Older clients will ignore them.
|
||||
Note: request_poll option will only work in Telegram versions released after 23 January, 2020.
|
||||
Older clients will receive unsupported message.
|
||||
|
||||
https://core.telegram.org/bots/api#keyboardbutton
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue