Files
fckbot/bots/commands/clear.py
Markov Andrey b4452dfeea Add new file
2026-06-30 21:36:43 +00:00

36 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""
Команда !clear очистка базы знаний (личной, комнатной, глобальной).
Использует RAGClient.
"""
import logging
from core.commands.base import Command
logger = logging.getLogger(__name__)
class ClearCommand(Command):
name = "!clear"
aliases = ["/clear"]
async def execute(self, msg, args: str, user_jid: str, room_jid: str = None):
"""
Очищает базу знаний:
- В личном чате личную БЗ пользователя.
- В групповом чате БЗ комнаты (требует прав администратора бота).
"""
try:
result = await self.bot.rag_client.clear(user_jid, room_jid, is_global=False)
if result.get('status') == 'ok':
reply = msg.reply("🗑 База знаний очищена.")
else:
reply = msg.reply(f"❌ Ошибка очистки: {result}")
except Exception as e:
logger.exception(f"Ошибка в !clear: {e}")
reply = msg.reply(f"❌ Ошибка: {e}")
if reply:
reply.send()
def get_help(self) -> str:
return "Очищает базу знаний (личную/комнатную)."