Add new file

This commit is contained in:
Markov Andrey
2026-06-30 21:36:43 +00:00
parent 25ad77f400
commit b4452dfeea

36
bots/commands/clear.py Normal file
View File

@@ -0,0 +1,36 @@
# -*- 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 "Очищает базу знаний (личную/комнатную)."