godcmd: load clear_memory_commands

This commit is contained in:
lanvent
2023-04-04 14:58:51 +08:00
parent 28eb67bc24
commit 186e18fe94
2 changed files with 10 additions and 3 deletions

View File

@@ -77,7 +77,7 @@ available_setting = {
"wechaty_puppet_service_token": "", # wechaty的token "wechaty_puppet_service_token": "", # wechaty的token
# chatgpt指令自定义触发词 # chatgpt指令自定义触发词
"clear_memory_commands": ['#清除记忆'], # 重置会话指令 "clear_memory_commands": ['#清除记忆'], # 重置会话指令,必须以#开头
# channel配置 # channel配置
"channel_type": "wx", # 通道类型支持wx,wxy和terminal "channel_type": "wx", # 通道类型支持wx,wxy和terminal

View File

@@ -7,7 +7,7 @@ from typing import Tuple
from bridge.bridge import Bridge from bridge.bridge import Bridge
from bridge.context import ContextType from bridge.context import ContextType
from bridge.reply import Reply, ReplyType from bridge.reply import Reply, ReplyType
from config import load_config from config import conf, load_config
import plugins import plugins
from plugins import * from plugins import *
from common import const from common import const
@@ -127,6 +127,13 @@ class Godcmd(Plugin):
with open(config_path,"r") as f: with open(config_path,"r") as f:
gconf=json.load(f) gconf=json.load(f)
custom_commands = conf().get("clear_memory_commands", [])
for custom_command in custom_commands:
if custom_command and custom_command.startswith("#"):
custom_command = custom_command[1:]
if custom_command and custom_command not in COMMANDS["reset"]["alias"]:
COMMANDS["reset"]["alias"].append(custom_command)
self.password = gconf["password"] self.password = gconf["password"]
self.admin_users = gconf["admin_users"] # 预存的管理员账号,这些账号不需要认证 TODO: 用户名每次都会变,目前不可用 self.admin_users = gconf["admin_users"] # 预存的管理员账号,这些账号不需要认证 TODO: 用户名每次都会变,目前不可用
self.isrunning = True # 机器人是否运行中 self.isrunning = True # 机器人是否运行中