Add new file
This commit is contained in:
31
bots/commands/reset.py
Normal file
31
bots/commands/reset.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
Команда !reset – сброс истории диалога (личной или комнатной).
|
||||||
|
Использует RAGClient.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from core.commands.base import Command
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class ResetCommand(Command):
|
||||||
|
name = "!reset"
|
||||||
|
aliases = ["/reset"]
|
||||||
|
|
||||||
|
async def execute(self, msg, args: str, user_jid: str, room_jid: str = None):
|
||||||
|
try:
|
||||||
|
result = await self.bot.rag_client.reset_history(user_jid, room_jid)
|
||||||
|
if result.get('status') == 'ok':
|
||||||
|
reply = msg.reply("🧹 История сброшена.")
|
||||||
|
else:
|
||||||
|
reply = msg.reply(f"❌ Ошибка сброса: {result}")
|
||||||
|
except Exception as e:
|
||||||
|
logger.exception(f"Ошибка в !reset: {e}")
|
||||||
|
reply = msg.reply(f"❌ Ошибка: {e}")
|
||||||
|
if reply:
|
||||||
|
reply.send()
|
||||||
|
|
||||||
|
def get_help(self) -> str:
|
||||||
|
return "Сбрасывает историю диалога (личную или комнатную)."
|
||||||
Reference in New Issue
Block a user