Files
fckbot/bots/commands/global_remove.py
2026-06-30 21:43:03 +00:00

41 lines
1.7 KiB
Python

import logging
from core.commands.base import Command
logger = logging.getLogger(__name__)
class GlobalRemoveCommand(Command):
name = "!global_remove"
aliases = ["/global_remove"]
permission = "admin"
async def execute(self, msg, args: str, user_jid: str, room_jid: str = None):
if not self.check_permission(user_jid):
reply = msg.reply("⛔ Нет прав.")
if reply: reply.send()
return
if room_jid:
reply = msg.reply("⚠️ Команда работает только в личном чате.")
if reply: reply.send()
return
_, flags, pos = self.parse_args(args)
if not pos:
reply = msg.reply("❌ Укажите название документа.")
if reply: reply.send()
return
source_name = " ".join(pos).strip()
if source_name.startswith('"') and source_name.endswith('"'):
source_name = source_name[1:-1]
try:
result = await self.bot.rag_client.delete_global(source_name)
if result.get('status') == 'ok':
reply = msg.reply(f"✅ Глобальный документ '{source_name}' удалён.")
else:
reply = msg.reply(f"❌ Ошибка удаления: {result}")
except Exception as e:
logger.exception(f"Ошибка в !global_remove: {e}")
reply = msg.reply(f"❌ Ошибка: {e}")
if reply:
reply.send()
def get_help(self) -> str:
return "Удаляет глобальный документ по названию (админ, только в личном чате)."