Testing text2img command (will be replaced, only for tests); added exception handling, queue and database table with generated images
This commit is contained in:
0
bot/callbacks/__init__.py
Normal file
0
bot/callbacks/__init__.py
Normal file
15
bot/callbacks/exception.py
Normal file
15
bot/callbacks/exception.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from bot.common import dp
|
||||
from bot.db import db, DBTables
|
||||
from aiogram import types
|
||||
from .factories.exception import exception_callback
|
||||
|
||||
|
||||
async def on_exception(call: types.CallbackQuery, callback_data: dict):
|
||||
e_id = callback_data['e_id']
|
||||
e = db[DBTables.exceptions][e_id]
|
||||
del db[DBTables.exceptions][e_id]
|
||||
await call.message.edit_text(e, parse_mode='html')
|
||||
|
||||
|
||||
def register():
|
||||
dp.register_callback_query_handler(on_exception, exception_callback.filter())
|
||||
0
bot/callbacks/factories/__init__.py
Normal file
0
bot/callbacks/factories/__init__.py
Normal file
4
bot/callbacks/factories/exception.py
Normal file
4
bot/callbacks/factories/exception.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from aiogram.utils.callback_data import CallbackData
|
||||
|
||||
|
||||
exception_callback = CallbackData("full_exception", "e_id")
|
||||
11
bot/callbacks/register.py
Normal file
11
bot/callbacks/register.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from rich import print
|
||||
|
||||
|
||||
def register_callbacks():
|
||||
from bot.callbacks import (
|
||||
exception
|
||||
)
|
||||
|
||||
exception.register()
|
||||
|
||||
print('[gray]All callbacks registered[/]')
|
||||
Reference in New Issue
Block a user