27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
from aiogram import types
|
|
from bot.db import db, DBTables
|
|
from bot.utils.cooldown import throttle
|
|
from bot.modules.api.txt2img import txt2img
|
|
|
|
|
|
@throttle(cooldown=30, admin_ids=db[DBTables.config].get('admins'))
|
|
async def txt2img_comand(message: types.Message):
|
|
temp_message = await message.reply("⏳ Generating image...")
|
|
if not message.get_args():
|
|
await temp_message.edit_text("Specify prompt for this command. Check /help txt2img")
|
|
return
|
|
|
|
try:
|
|
image = await txt2img(message.get_args())
|
|
await message.reply_photo(photo=image[0], caption=str(
|
|
image[1]["infotexts"][0]))
|
|
except Exception as e:
|
|
assert e
|
|
await message.reply("We ran into error while processing your request. StableDiffusion models may not be "
|
|
"configured on specified endpoint or server with StableDiffusion may be turned "
|
|
"off. Ask admins of this bot instance if you have contacts for further info")
|
|
await temp_message.delete()
|
|
return
|
|
|
|
await temp_message.delete()
|