diff --git a/bot/handlers/txt2img/set_model.py b/bot/handlers/txt2img/set_model.py index dcc5634..bdc9da5 100644 --- a/bot/handlers/txt2img/set_model.py +++ b/bot/handlers/txt2img/set_model.py @@ -1,5 +1,5 @@ from aiogram import types -from bot.db import db, DBTables, decrypt +from bot.db import db, DBTables from bot.utils.cooldown import throttle from bot.keyboards.set_model import get_set_model_keyboard from bot.modules.api.models import get_models @@ -9,8 +9,10 @@ from bot.utils.errorable_command import wrap_exception @wrap_exception() @throttle(cooldown=5*60, admin_ids=db[DBTables.config].get('admins'), by_id=False) async def set_model_command(message: types.Message): - if (message.chat.id not in db[DBTables.config]['whitelist'] and message.from_id not in db[DBTables.config]['whitelist']): - await message.reply('❌You are not on the white list, access denied. Contact admin @kilisauros for details') + if db[DBTables.config].get('whitelist') and \ + (message.chat.id not in db[DBTables.config]['whitelist'] and + message.from_id not in db[DBTables.config]['whitelist']): + await message.reply('❌ You are not on the white list, access denied. Contact admin @kilisauros for details') return models = await get_models() if models is not None and len(models) > 0: @@ -18,5 +20,5 @@ async def set_model_command(message: types.Message): else: await message.reply('❌ No models available') return - await message.reply("Examples of models (with additional info): https://telegra.ph/Opisanie-raboty-modelej-05-03") + await message.reply("🪄 You can choose model from available:", reply_markup=get_set_model_keyboard(0)) diff --git a/bot/handlers/txt2img/txt2img.py b/bot/handlers/txt2img/txt2img.py index 1da8ee2..67de14e 100644 --- a/bot/handlers/txt2img/txt2img.py +++ b/bot/handlers/txt2img/txt2img.py @@ -2,6 +2,7 @@ import re from bot.common import bot from aiogram import types from bot.db import db, DBTables +from bot.config import ARCHIVE_CHAT from bot.utils.cooldown import throttle from bot.modules.api.txt2img import txt2img from bot.modules.api.objects.get_prompt import get_prompt @@ -9,8 +10,6 @@ from bot.modules.api.objects.prompt_request import Generated from bot.modules.api.status import wait_for_status from bot.keyboards.image_info import get_img_info_keyboard from bot.utils.errorable_command import wrap_exception -from bot.callbacks.factories.image_info import (prompt_only, full_prompt, import_prompt, back) - @wrap_exception([ValueError], custom_loading=True) @@ -21,8 +20,9 @@ async def generate_command(message: types.Message): await message.reply('💔 Generation is disabled by admins now. Try again later') await temp_message.delete() return - elif (message.chat.id not in db[DBTables.config]['whitelist'] and message.from_id not in db[DBTables.config]['whitelist']): - await message.reply('❌You are not on the white list, access denied. Contact admin @kilisauros for details') + elif db[DBTables.config].get('whitelist') and (message.chat.id not in db[DBTables.config]['whitelist'] + and message.from_id not in db[DBTables.config]['whitelist']): + await message.reply('❌ You are not on the white list, access denied. ') await temp_message.delete() return @@ -46,24 +46,25 @@ async def generate_command(message: types.Message): db[DBTables.queue]['n'] = db[DBTables.queue].get('n', 1) - 1 image = await txt2img(prompt) image_message = await message.reply_photo(photo=image[0]) - - #Send photo to SD Image Archive - archive_message = f'User ID: {message.from_id} \n \ - User nickname: {message.from_user.full_name} \n \ - User username: @{message.from_user.username} \n \ - Chat ID: {message.chat.id} \n \ - Chat title: {message.chat.title} \n \ - Info: \n \ - 🖤 Prompt: {prompt.prompt} \n \ - 🐊 Negative: {prompt.negative_prompt} \n \ - 💫 Model: In development \n \ - 🪜 Steps: {prompt.steps} \n \ - 🧑‍🎨 CFG Scale: {prompt.cfg_scale} \n \ - 🖥️ Size: {prompt.width}x{prompt.height} \n \ - 😀 Restore faces: {prompt.restore_faces} \n \ - ⚒️ Sampler: {prompt.sampler} \n ' - await bot.send_photo(-929754401, photo=image[0], caption=archive_message) + if ARCHIVE_CHAT: + archive_message = ( + f"User ID: {message.from_id}" + f"User nickname: {message.from_user.full_name}" + f"User username: @{message.from_user.username}" + f"Chat ID: {message.chat.id}" + f"Chat title: {message.chat.title}" + f"Info:" + f"🖤 Prompt: {prompt.prompt}" + f"🐊 Negative: {prompt.negative_prompt}" + f"💫 Model: In development" + f"🪜 Steps: {prompt.steps}" + f"🧑‍🎨 CFG Scale: {prompt.cfg_scale}" + f"🖥️ Size: {prompt.width}x{prompt.height}" + f"😀 Restore faces: {prompt.restore_faces}" + f"⚒️ Sampler: {prompt.sampler}" + ) + await bot.send_photo(ARCHIVE_CHAT, photo=image[0], caption=archive_message) db[DBTables.generated][image_message.photo[0].file_unique_id] = Generated( prompt=prompt, @@ -82,4 +83,4 @@ async def generate_command(message: types.Message): await message.reply(f'❌ Error! {e.args[0]}') await temp_message.delete() db[DBTables.queue]['n'] = db[DBTables.queue].get('n', 1) - 1 - return \ No newline at end of file + return