mirror of
https://github.com/RockChinQ/QChatGPT.git
synced 2024-11-16 19:57:04 +08:00
50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
from .. import aamgr
|
|
|
|
|
|
@aamgr.AbstractCommandNode.register(
|
|
parent=None,
|
|
name="delhst",
|
|
description="删除指定会话的所有历史记录",
|
|
usage="!delhst <会话名称>\n!delhst all",
|
|
aliases=[],
|
|
privilege=2
|
|
)
|
|
class DelHistoryCommand(aamgr.AbstractCommandNode):
|
|
@classmethod
|
|
def process(cls, ctx: aamgr.Context) -> tuple[bool, list]:
|
|
import pkg.openai.session
|
|
import pkg.utils.context
|
|
params = ctx.params
|
|
reply = []
|
|
if len(params) == 0:
|
|
reply = [
|
|
"[bot]err:请输入要删除的会话名: group_<群号> 或者 person_<QQ号>, 或使用 !delhst all 删除所有会话的历史记录"]
|
|
else:
|
|
if params[0] == 'all':
|
|
return False, []
|
|
else:
|
|
if pkg.utils.context.get_database_manager().delete_all_history(params[0]):
|
|
reply = ["[bot]已删除会话 {} 的所有历史记录".format(params[0])]
|
|
else:
|
|
reply = ["[bot]未找到会话 {} 的历史记录".format(params[0])]
|
|
|
|
return True, reply
|
|
|
|
|
|
@aamgr.AbstractCommandNode.register(
|
|
parent=DelHistoryCommand,
|
|
name="all",
|
|
description="删除所有会话的全部历史记录",
|
|
usage="!delhst all",
|
|
aliases=[],
|
|
privilege=2
|
|
)
|
|
class DelAllHistoryCommand(aamgr.AbstractCommandNode):
|
|
@classmethod
|
|
def process(cls, ctx: aamgr.Context) -> tuple[bool, list]:
|
|
import pkg.utils.context
|
|
reply = []
|
|
pkg.utils.context.get_database_manager().delete_all_session_history()
|
|
reply = ["[bot]已删除所有会话的历史记录"]
|
|
return True, reply
|
|
|