Files
fckbot/bots/commands/create.py
Markov Andrey 890c18fd86 Add new file
2026-06-30 21:44:09 +00:00

36 lines
1.4 KiB
Python

import logging
from core.commands.base import Command
logger = logging.getLogger(__name__)
class CreateCommand(Command):
name = "!create"
aliases = ["/create"]
async def execute(self, msg, args: str, user_jid: str, room_jid: str = None):
if not room_jid:
reply = msg.reply("⚠️ Команда работает только в комнатах.")
if reply: reply.send()
return
template_name = args.strip()
if template_name.startswith('"') and template_name.endswith('"'):
template_name = template_name[1:-1]
if not template_name:
reply = msg.reply("Укажите название шаблона: !create \"Название\"")
if reply: reply.send()
return
try:
result = await self.bot.rag_client.generate_document(template_name, user_jid, room_jid)
doc_url = result.get('document')
if doc_url:
reply = msg.reply(f"📄 Документ создан: {doc_url}")
else:
reply = msg.reply(f"❌ Ошибка генерации: {result}")
except Exception as e:
logger.exception(f"Ошибка в !create: {e}")
reply = msg.reply(f"❌ Ошибка: {e}")
if reply:
reply.send()
def get_help(self) -> str:
return "Генерирует документ по шаблону в комнате."