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

import logging
from load import dp, bot, types
import config
from peewee import DoesNotExist
from aiogram.exceptions import TelegramUnauthorizedError
@dp.errors()
async def errors_handler(event: types.error_event.ErrorEvent):
if (isinstance(event.exception, TelegramUnauthorizedError)):
logging.info(f"Unathorized: {config.token}")
return True
if (isinstance(event.exception, DoesNotExist)):
event.update.message.reply("Membser not found, you shoud update database data `!reload`")
return True
await bot.send_message(config.second_group_id, (
"Bot terminated\n"
f"Exception: {event.exception}"
))