mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-12 08:46:02 +00:00
修改自定义提示语
This commit is contained in:
@@ -9,6 +9,9 @@ import json
|
||||
|
||||
|
||||
__command_list__ = {}
|
||||
|
||||
import tips_custom
|
||||
|
||||
"""命令树
|
||||
|
||||
结构:
|
||||
@@ -262,7 +265,7 @@ def execute(context: Context) -> list:
|
||||
|
||||
# 检查权限
|
||||
if ctx.privilege < node['privilege']:
|
||||
raise CommandPrivilegeError('权限不足: {}'.format(path))
|
||||
raise CommandPrivilegeError(tips_custom.command_admin_message)
|
||||
|
||||
# 执行
|
||||
execed, reply = node['cls'].process(ctx)
|
||||
@@ -275,7 +278,7 @@ def execute(context: Context) -> list:
|
||||
path = path + '.' + ctx.crt_command
|
||||
except KeyError:
|
||||
traceback.print_exc()
|
||||
raise CommandPrivilegeError('找不到指令: {}'.format(path))
|
||||
raise CommandPrivilegeError(tips_custom.command_err_message)
|
||||
|
||||
|
||||
def register_all():
|
||||
|
||||
@@ -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 = ["[bot]err:{}".format(e)]
|
||||
reply = [format(e)]
|
||||
|
||||
return reply
|
||||
except Exception as e:
|
||||
|
||||
@@ -19,6 +19,7 @@ import pkg.utils.context
|
||||
|
||||
import pkg.plugin.host as plugin_host
|
||||
import pkg.plugin.models as plugin_models
|
||||
import tips_custom
|
||||
|
||||
|
||||
# 检查消息是否符合泛响应匹配机制
|
||||
@@ -268,7 +269,7 @@ class QQBotManager:
|
||||
if failed == self.retry:
|
||||
pkg.openai.session.get_session('person_{}'.format(event.sender.id)).release_response_lock()
|
||||
self.notify_admin("{} 请求超时".format("person_{}".format(event.sender.id)))
|
||||
reply = ["[bot]err:请求超时"]
|
||||
reply = tips_custom.reply_message
|
||||
|
||||
if reply:
|
||||
return self.send(event, reply, check_quote=False)
|
||||
@@ -308,7 +309,7 @@ class QQBotManager:
|
||||
if failed == self.retry:
|
||||
pkg.openai.session.get_session('group_{}'.format(event.group.id)).release_response_lock()
|
||||
self.notify_admin("{} 请求超时".format("group_{}".format(event.group.id)))
|
||||
replys = ["[bot]err:请求超时"]
|
||||
replys = tips_custom.replys_message
|
||||
|
||||
return replys
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import pkg.openai.session
|
||||
import pkg.plugin.host as plugin_host
|
||||
import pkg.plugin.models as plugin_models
|
||||
import pkg.qqbot.blob as blob
|
||||
import tips_custom
|
||||
|
||||
|
||||
def handle_exception(notify_admin: str = "", set_reply: str = "") -> list:
|
||||
@@ -15,7 +16,7 @@ def handle_exception(notify_admin: str = "", set_reply: str = "") -> list:
|
||||
pkg.utils.context.get_qqbot_manager().notify_admin(notify_admin)
|
||||
if hasattr(config, 'hide_exce_info_to_user') and config.hide_exce_info_to_user:
|
||||
if hasattr(config, 'alter_tip_message'):
|
||||
return [config.alter_tip_message] if config.alter_tip_message else []
|
||||
return [tips_custom.alter_tip_message] if tips_custom.alter_tip_message else []
|
||||
else:
|
||||
return ["[bot]出错了,请重试或联系管理员"]
|
||||
else:
|
||||
|
||||
@@ -27,6 +27,7 @@ import pkg.plugin.models as plugin_models
|
||||
import pkg.qqbot.ignore as ignore
|
||||
import pkg.qqbot.banlist as banlist
|
||||
import pkg.qqbot.blob as blob
|
||||
import tips_custom
|
||||
|
||||
processing = []
|
||||
|
||||
@@ -118,7 +119,7 @@ def process_message(launcher_type: str, launcher_id: int, text_message: str, mes
|
||||
if hasattr(config, "rate_limitation") and config.rate_limit_strategy == "drop":
|
||||
if ratelimit.is_reach_limit(session_name):
|
||||
logging.info("根据限速策略丢弃[{}]消息: {}".format(session_name, text_message))
|
||||
return MessageChain(["[bot]"+config.rate_limit_drop_tip]) if hasattr(config, "rate_limit_drop_tip") and config.rate_limit_drop_tip != "" else []
|
||||
return MessageChain(["[bot]"+tips_custom.rate_limit_drop_tip]) if hasattr(tips_custom, "rate_limit_drop_tip") and tips_custom.rate_limit_drop_tip != "" else []
|
||||
|
||||
before = time.time()
|
||||
# 触发插件事件
|
||||
|
||||
Reference in New Issue
Block a user