GPQBot
19 строк · 553.0 Байт
1
2"""Handler to work with unexpected errors."""
3
4from pybotx import Bot, BotShuttingDownError, IncomingMessage5
6from app.logger import logger7from app.resources import strings8
9
10async def internal_error_handler(11message: IncomingMessage, bot: Bot, exc: Exception12) -> None:13logger.exception("Internal error:")14
15is_bot_active = not isinstance(exc, BotShuttingDownError)16await bot.answer_message(17strings.SOMETHING_GOES_WRONG,18# We can't receive callback when bot is shutting down19wait_callback=is_bot_active,20)21