Added config and current commands, Close button for inline menus, pass to all __init__s

This commit is contained in:
BarsTiger
2023-03-08 16:10:22 +02:00
parent ebdd27ece8
commit b83e649349
19 changed files with 119 additions and 5 deletions

View File

@@ -0,0 +1 @@
pass

15
bot/callbacks/common.py Normal file
View File

@@ -0,0 +1,15 @@
from bot.common import dp
from bot.callbacks.factories.common import close_keyboard_data
from aiogram import types
from bot.utils.private_keyboard import other_user
async def on_close_keyboard(call: types.CallbackQuery):
if await other_user(call):
return
await call.message.delete()
def register():
dp.register_callback_query_handler(on_close_keyboard, close_keyboard_data.filter())

View File

@@ -0,0 +1 @@
pass

View File

@@ -0,0 +1 @@
pass

View File

@@ -0,0 +1,4 @@
from aiogram.utils.callback_data import CallbackData
close_keyboard_data = CallbackData("close_keyboard")

View File

@@ -0,0 +1,6 @@
from aiogram.utils.callback_data import CallbackData
prompt_settings_data = CallbackData("prompt_settings")
global_settings_data = CallbackData("global_settings")
admin_settings_data = CallbackData("admin_settings")

View File

@@ -6,8 +6,10 @@ from bot.keyboards.image_info import get_img_info_keyboard, get_img_back_keyboar
from bot.utils.cooldown import throttle
from bot.utils.private_keyboard import other_user
from bot.modules.api.objects.prompt_request import Generated
from bot.utils.errorable_command import wrap_exception
@wrap_exception()
async def on_back(call: types.CallbackQuery, callback_data: dict):
p_id = callback_data['p_id']
if await other_user(call):
@@ -20,6 +22,7 @@ async def on_back(call: types.CallbackQuery, callback_data: dict):
)
@wrap_exception()
@throttle(5)
async def on_prompt_only(call: types.CallbackQuery, callback_data: dict):
p_id = callback_data['p_id']
@@ -36,6 +39,7 @@ async def on_prompt_only(call: types.CallbackQuery, callback_data: dict):
)
@wrap_exception()
@throttle(5)
async def on_full_info(call: types.CallbackQuery, callback_data: dict):
p_id = callback_data['p_id']
@@ -59,17 +63,21 @@ async def on_full_info(call: types.CallbackQuery, callback_data: dict):
)
@wrap_exception()
@throttle(5)
async def on_import(call: types.CallbackQuery, callback_data: dict):
p_id = callback_data['p_id']
if await other_user(call):
return
prompt: Generated = db[DBTables.generated].get(p_id)
generated: Generated = db[DBTables.generated].get(p_id)
prompt = generated.prompt
prompt.creator = call.from_user.id
db[DBTables.prompts][call.from_user.id] = prompt
await db[DBTables.config].write()
await call.message.edit_text(
f"😶‍🌫️ Not implemented yet",
parse_mode='html',
f"️🥐 Prompt imported",
reply_markup=get_img_back_keyboard(p_id)
)

View File

@@ -5,11 +5,13 @@ def register_callbacks():
from bot.callbacks import (
exception,
image_info,
set_model
set_model,
common
)
exception.register()
image_info.register()
set_model.register()
common.register()
print('[gray]All callbacks registered[/]')