Added config and current commands, Close button for inline menus, pass to all __init__s
This commit is contained in:
6
bot/handlers/config/__init__.py
Normal file
6
bot/handlers/config/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from bot.common import dp
|
||||
from .config_command import *
|
||||
|
||||
|
||||
def register():
|
||||
dp.register_message_handler(config_command, commands='config')
|
||||
11
bot/handlers/config/config_command.py
Normal file
11
bot/handlers/config/config_command.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from aiogram import types
|
||||
from bot.db import db, DBTables
|
||||
from bot.utils.cooldown import throttle
|
||||
from bot.utils.errorable_command import wrap_exception
|
||||
from bot.keyboards.config import get_config_keyboard
|
||||
|
||||
|
||||
@wrap_exception()
|
||||
@throttle(cooldown=60*60, admin_ids=db[DBTables.config].get('admins'), by_id=False)
|
||||
async def config_command(message: types.Message):
|
||||
await message.reply("⚙️ Configuration:", reply_markup=get_config_keyboard(message.from_id))
|
||||
@@ -2,6 +2,7 @@ help_data = {
|
||||
'generate': 'Generate picture using configuration set by user. You can pass prompt also in command arguments or '
|
||||
'use it without arguments to generate picture with prompt, that was used for last generation',
|
||||
'imginfo': 'Get information about image, that was generated using this bot',
|
||||
'current': 'Get your current prompt',
|
||||
'setprompt': 'Set default prompt for images, will be overwritten if you specify prompt in generate command',
|
||||
'setnegative': 'Set negative prompt',
|
||||
'setsize': 'Set size for image (in hxw format)',
|
||||
@@ -12,6 +13,7 @@ help_data = {
|
||||
'setscale': 'Set CFG Scale (prompt stringency)',
|
||||
'setfaces': 'Set restore faces mode',
|
||||
'status': 'Ping API endpoint host',
|
||||
'config': 'Edit config using inline buttons',
|
||||
'setmodel': '(global) Sets StableDiffusion model for all users. Can be used only once an hour',
|
||||
'setendpoint': '(admin) Set StableDiffusion API endpoint',
|
||||
'addadmin': '(admin) Add new admin - reply to message or type user ID',
|
||||
|
||||
@@ -3,7 +3,7 @@ from rich import print
|
||||
|
||||
def register_handlers():
|
||||
from bot.handlers import (
|
||||
initialize, admin, help_command, txt2img, image_info
|
||||
initialize, admin, help_command, txt2img, image_info, config
|
||||
)
|
||||
|
||||
initialize.register()
|
||||
@@ -11,5 +11,6 @@ def register_handlers():
|
||||
help_command.register()
|
||||
txt2img.register()
|
||||
image_info.register()
|
||||
config.register()
|
||||
|
||||
print('[gray]All handlers registered[/]')
|
||||
|
||||
@@ -2,6 +2,7 @@ from bot.common import dp
|
||||
from .txt2img import generate_command
|
||||
from .set_model import set_model_command
|
||||
from .status import get_status
|
||||
from .current import get_current
|
||||
from .set_settings import (
|
||||
set_height_command, set_negative_prompt_command, set_size_command, set_steps_command, set_width_command,
|
||||
set_prompt_command, set_sampler_command, set_cfg_scale_command, set_restore_faces_command
|
||||
@@ -21,3 +22,4 @@ def register():
|
||||
dp.register_message_handler(set_settings.set_restore_faces_command, commands='setfaces')
|
||||
dp.register_message_handler(set_model.set_model_command, commands='setmodel')
|
||||
dp.register_message_handler(status.get_status, commands='status')
|
||||
dp.register_message_handler(current.get_current, commands='current')
|
||||
|
||||
24
bot/handlers/txt2img/current.py
Normal file
24
bot/handlers/txt2img/current.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from aiogram import types
|
||||
from bot.db import db, DBTables
|
||||
from bot.utils.cooldown import throttle
|
||||
from bot.modules.api.objects.prompt_request import Prompt
|
||||
from bot.utils.errorable_command import wrap_exception
|
||||
|
||||
|
||||
@wrap_exception()
|
||||
@throttle(cooldown=5, admin_ids=db[DBTables.config].get('admins'))
|
||||
async def get_current(message: types.Message):
|
||||
prompt: Prompt = db[DBTables.prompts].get(message.from_id)
|
||||
if prompt is None:
|
||||
await message.reply('❌ No prompts found for you')
|
||||
|
||||
await message.reply(
|
||||
f"🖤 Prompt: {prompt.prompt} \n"
|
||||
f"🐊 Negative: {prompt.negative_prompt} \n"
|
||||
f"🪜 Steps: {prompt.steps} \n"
|
||||
f"🧑🎨 CFG Scale: {prompt.cfg_scale} \n"
|
||||
f"🖥️ Size: {prompt.width}x{prompt.height} \n"
|
||||
f"😀 Restore faces: {'on' if prompt.restore_faces else 'off'} \n"
|
||||
f"⚒️ Sampler: {prompt.sampler} \n",
|
||||
parse_mode='html'
|
||||
)
|
||||
Reference in New Issue
Block a user