From da0391161002ed96ca3d51bd1cfbecfbbcabd8ce Mon Sep 17 00:00:00 2001 From: 26751 <2675174581@qq.com> Date: Sat, 1 Apr 2023 16:09:07 +0800 Subject: [PATCH] Signed-off-by: 26751 <2675174581@qq.com> --- config-template.py | 2 ++ main.py | 4 ++++ pkg/qqbot/cmds/mgr.py | 4 ++-- pkg/qqbot/command.py | 2 +- tips_custom.py | 24 ++++++++++++---------- tips_custom_template.py | 44 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 67 insertions(+), 13 deletions(-) create mode 100644 tips_custom_template.py diff --git a/config-template.py b/config-template.py index 8e57ad54..391b600a 100644 --- a/config-template.py +++ b/config-template.py @@ -253,6 +253,8 @@ rate_limitation = 60 # - "wait": 每次对话获取到回复时,等待一定时间再发送回复,保证其不会超过限速均值 # - "drop": 此分钟内,若对话次数超过限速次数,则丢弃之后的对话,每自然分钟重置 rate_limit_strategy = "wait" +# drop策略时,超过限速均值时,丢弃的对话的提示信息,仅当rate_limitation_strategy为"drop"时生效 +# 转tips_custom.py中rate_limit_drop_tip字段 # 是否在启动时进行依赖库更新 upgrade_dependencies = True diff --git a/main.py b/main.py index fdac1d67..196a3dc0 100644 --- a/main.py +++ b/main.py @@ -378,6 +378,10 @@ def check_file(): if not os.path.exists("cmdpriv.json"): shutil.copy("cmdpriv-template.json", "cmdpriv.json") + # 检查tips_custom + if not os.path.exists("tips_custom.py"): + shutil.copy("tips_custom_template.py", "tips_custom.py") + # 检查temp目录 if not os.path.exists("temp/"): os.mkdir("temp/") diff --git a/pkg/qqbot/cmds/mgr.py b/pkg/qqbot/cmds/mgr.py index b1022cf7..b2f92853 100644 --- a/pkg/qqbot/cmds/mgr.py +++ b/pkg/qqbot/cmds/mgr.py @@ -265,7 +265,7 @@ def execute(context: Context) -> list: # 检查权限 if ctx.privilege < node['privilege']: - raise CommandPrivilegeError(tips_custom.command_admin_message) + raise CommandPrivilegeError(tips_custom.command_admin_message+"{}".format(path)) # 执行 execed, reply = node['cls'].process(ctx) @@ -278,7 +278,7 @@ def execute(context: Context) -> list: path = path + '.' + ctx.crt_command except KeyError: traceback.print_exc() - raise CommandPrivilegeError(tips_custom.command_err_message) + raise CommandPrivilegeError(tips_custom.command_err_message+"{}".format(path)) def register_all(): diff --git a/pkg/qqbot/command.py b/pkg/qqbot/command.py index 1e01bab3..d3141d95 100644 --- a/pkg/qqbot/command.py +++ b/pkg/qqbot/command.py @@ -54,7 +54,7 @@ def process_command(session_name: str, text_message: str, mgr, config, try: reply = cmdmgr.execute(context) except cmdmgr.CommandPrivilegeError as e: - reply = [format(e)] + reply = ["{}".format(e)] return reply except Exception as e: diff --git a/tips_custom.py b/tips_custom.py index ae40d72e..d37ad1c7 100644 --- a/tips_custom.py +++ b/tips_custom.py @@ -7,29 +7,33 @@ import config # 设置为空字符串时,不发送提示信息 # config.py,line:232 # pkg/qqbot/message.py,line:19 -alter_tip_message = '天空一声巨响,魔法少女闪亮登场,唉呀脚滑了,疼~等会再来~(这是一条全世界最人见人爱花见花开玉树临风英俊潇洒美丽且可爱的出错提醒哦~)' +alter_tip_message = '出错了,请稍后再试' # drop策略时,超过限速均值时,丢弃的对话的提示信息,仅当rate_limitation_strategy为"drop"时生效 # 若设置为空字符串,则不发送提示信息 # config.py,line:265 # pkg/qqbot/process.py,line:122 -rate_limit_drop_tip = "欧尼酱慢点我跟不上" +rate_limit_drop_tip = "本分钟对话次数超过限速次数,此对话被丢弃" # 指令!help帮助消息 # config.py,line:279 # pkg/qqbot/process.py,line:122 -help_message = """ -这是一个很正经的帮助文档 -此处省略10086字... -biu~biu~biu~""".format(config.session_expire_time // 60) +help_message = """【可自定义】 +此机器人通过调用OpenAI的GPT-3大型语言模型生成回复,不具有情感。 +你可以用自然语言与其交流,回复的消息中[GPT]开头的为模型生成的语言,[bot]开头的为程序提示。 +了解此项目请找QQ 1010553892 联系作者 +请不要用其生成整篇文章或大段代码,因为每次只会向模型提交少部分文字,生成大部分文字会产生偏题、前后矛盾等问题 +每次会话最后一次交互后{}分钟后会自动结束,结束后将开启新会话,如需继续前一次会话请发送 !last 重新开启 +欢迎到github.com/RockChinQ/QChatGPT 给个star +指令帮助信息请查看: https://github.com/RockChinQ/QChatGPT/wiki/%E5%8A%9F%E8%83%BD%E4%BD%BF%E7%94%A8#%E6%9C%BA%E5%99%A8%E4%BA%BA%E6%8C%87%E4%BB%A4""".format(config.session_expire_time // 60) # ---原config.py结束-- # QChatGPT/pkg/qqbot/manager.py # 私聊消息超时提示,line:271 -reply_message = "天空一声巨响,魔法少女闪亮登场,哎呀脚滑了,疼~(这是一条全世界最人见人爱花见花开玉树临风英俊潇洒美丽且可爱的超时提醒哦。)" +reply_message = ["私聊请求超时"] # 群聊消息超时提示,line:310 -replys_message = "天空一声巨响,魔法少女闪亮登场,哎呀脚滑了,疼~(这是一条全世界最人见人爱花见花开玉树临风英俊潇洒美丽且可爱的超时提醒哦。)" +replys_message = ["群聊请求超时"] # 指令权限不足/无效提示 # QChatGPT/pkg/qqbot/command.py,line:57 @@ -37,5 +41,5 @@ replys_message = "天空一声巨响,魔法少女闪亮登场,哎呀脚滑 # reply = [format(e)] # QChatGPT/pkg/qqbot/cmds/mgr.py # line:266,279 -command_admin_message = "你居然想偷看我裙底?坏蛋,大坏蛋,超级大坏蛋,无敌超级大坏蛋,宇宙无敌超级大坏蛋。哼! " -command_err_message = "你又再想涩涩的事了?" +command_admin_message = "权限不足: " +command_err_message = "指令执行出错:" diff --git a/tips_custom_template.py b/tips_custom_template.py new file mode 100644 index 00000000..4cae59a9 --- /dev/null +++ b/tips_custom_template.py @@ -0,0 +1,44 @@ +import config + +# ---------------------------------------------花里胡哨参数--------------------------------------------- +# ---原config.py开始-- + +# 消息处理出错时向用户发送的提示信息,仅当hide_exce_info_to_user为True时生效 +# 设置为空字符串时,不发送提示信息 +# config.py,line:232 +# pkg/qqbot/message.py,line:19 +alter_tip_message = '出错了,请稍后再试' + +# drop策略时,超过限速均值时,丢弃的对话的提示信息,仅当rate_limitation_strategy为"drop"时生效 +# 若设置为空字符串,则不发送提示信息 +# config.py,line:265 +# pkg/qqbot/process.py,line:122 +rate_limit_drop_tip = "本分钟对话次数超过限速次数,此对话被丢弃" + +# 指令!help帮助消息 +# config.py,line:279 +# pkg/qqbot/process.py,line:122 +help_message = """【可自定义】 +此机器人通过调用OpenAI的GPT-3大型语言模型生成回复,不具有情感。 +你可以用自然语言与其交流,回复的消息中[GPT]开头的为模型生成的语言,[bot]开头的为程序提示。 +了解此项目请找QQ 1010553892 联系作者 +请不要用其生成整篇文章或大段代码,因为每次只会向模型提交少部分文字,生成大部分文字会产生偏题、前后矛盾等问题 +每次会话最后一次交互后{}分钟后会自动结束,结束后将开启新会话,如需继续前一次会话请发送 !last 重新开启 +欢迎到github.com/RockChinQ/QChatGPT 给个star +指令帮助信息请查看: https://github.com/RockChinQ/QChatGPT/wiki/%E5%8A%9F%E8%83%BD%E4%BD%BF%E7%94%A8#%E6%9C%BA%E5%99%A8%E4%BA%BA%E6%8C%87%E4%BB%A4""".format(config.session_expire_time // 60) + +# ---原config.py结束-- + +# QChatGPT/pkg/qqbot/manager.py +# 私聊消息超时提示,line:271 +reply_message = ["私聊请求超时"] +# 群聊消息超时提示,line:310 +replys_message = ["群聊请求超时"] + +# 指令权限不足/无效提示 +# QChatGPT/pkg/qqbot/command.py,line:57 +# 更改代码 +# QChatGPT/pkg/qqbot/cmds/mgr.py +# line:266,279 +command_admin_message = "权限不足: " +command_err_message = "指令执行出错:"