diff --git a/bots/commands/create.py b/bots/commands/create.py new file mode 100644 index 0000000..53d486b --- /dev/null +++ b/bots/commands/create.py @@ -0,0 +1,36 @@ +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 "Генерирует документ по шаблону в комнате." \ No newline at end of file