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
575 B
Python
Raw Normal View History

2022-08-07 04:45:35 -04:00
import logging
from load import dp,bot
import config
from aiogram.utils.exceptions import Unauthorized
@dp.errors_handler()
async def errors_handler(update, exception):
if (isinstance(exception,Unauthorized)):
logging.info(f"Unathorized:{config.token}")
return True
await update.message.answer("Error happaned!\nBot terminated!")
await bot.send_message(
config.telegram_log_chat_id,
f"**Bot terminated**!\nException:{exception}",
parse_mode="Markdown"
)
logging.info(f"Bot terminated!Exception:{exception}")