2022-08-07 04:45:35 -04:00
|
|
|
import logging
|
|
|
|
|
2022-12-01 05:54:32 -05:00
|
|
|
from peewee import DoesNotExist
|
|
|
|
|
|
|
|
from load import dp, bot, types
|
2022-08-07 04:45:35 -04:00
|
|
|
import config
|
|
|
|
|
|
|
|
from aiogram.utils.exceptions import Unauthorized
|
|
|
|
|
|
|
|
|
|
|
|
@dp.errors_handler()
|
2022-12-01 05:54:32 -05:00
|
|
|
async def errors_handler(update: types.Update, exception):
|
2023-01-22 05:27:20 -05:00
|
|
|
if (isinstance(exception, Unauthorized)):
|
2022-08-07 04:45:35 -04:00
|
|
|
logging.info(f"Unathorized:{config.token}")
|
|
|
|
return True
|
2022-12-01 05:54:32 -05:00
|
|
|
|
2023-01-22 05:27:20 -05:00
|
|
|
if (isinstance(exception, DoesNotExist)):
|
2022-12-01 05:54:32 -05:00
|
|
|
await update.message.reply("Membser not found, you shoud update database data `!reload`",
|
|
|
|
parse_mode="Markdown")
|
|
|
|
return True
|
2022-08-07 04:45:35 -04:00
|
|
|
|
|
|
|
await update.message.answer("Error happaned!\nBot terminated!")
|
|
|
|
|
2023-01-22 05:27:20 -05:00
|
|
|
await bot.send_message(config.second_group_id, (
|
2022-12-01 05:54:32 -05:00
|
|
|
"Bot terminated"
|
|
|
|
f"{exception}"
|
2023-01-22 05:27:20 -05:00
|
|
|
), parse_mode="Markdown"
|
2022-08-07 04:45:35 -04:00
|
|
|
)
|