This repository has been archived on 2024-07-28. You can view files and clone it, but cannot push or open issues or pull requests.
moderator-bot/handlers/errors/errors_handler.py

24 lines
675 B
Python
Raw Permalink Normal View History

2022-08-07 04:45:35 -04:00
import logging
2022-12-01 05:54:32 -05:00
from load import dp, bot, types
2022-08-07 04:45:35 -04:00
import config
2023-02-18 08:16:54 -05:00
from peewee import DoesNotExist
from aiogram.exceptions import TelegramUnauthorizedError
2022-08-07 04:45:35 -04:00
2023-02-18 08:16:54 -05:00
@dp.errors()
async def errors_handler(event: types.error_event.ErrorEvent):
if (isinstance(event.exception, TelegramUnauthorizedError)):
logging.info(f"Unathorized: {config.token}")
2022-08-07 04:45:35 -04:00
return True
2022-12-01 05:54:32 -05:00
2023-02-18 08:16:54 -05:00
if (isinstance(event.exception, DoesNotExist)):
event.update.message.reply("Membser not found, you shoud update database data `!reload`")
2022-12-01 05:54:32 -05:00
return True
2023-02-18 08:16:54 -05:00
2023-01-22 05:27:20 -05:00
await bot.send_message(config.second_group_id, (
2023-02-18 08:16:54 -05:00
"Bot terminated\n"
f"Exception: {event.exception}"
))