Skip to content

Commit

Permalink
Update set module list
Browse files Browse the repository at this point in the history
DoroWolf authored May 30, 2024
1 parent 187e7f9 commit 470b766
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions modules/core/locales/en_us.json
Original file line number Diff line number Diff line change
@@ -172,6 +172,8 @@
"core.message.set.confirm.init": "This conversation is not initialized. Are you sure you want to do it?",
"core.message.set.module.disable.success": "The following module(s) were successfully disabled for the conversation: ",
"core.message.set.module.enable.success": "The following module(s) were successfully enabled for the conversation: ",
"core.message.set.module.list": "The enabled module(s) in the conversation: ",
"core.message.set.module.list.none": "There are no enabled modules in the conversation.",
"core.message.set.option.edit.success": "The following parameter was set for the conversation: ${k} -> ${v}",
"core.message.setup.check.disable": "Check prompt disabled.",
"core.message.setup.check.enable": "Check prompt enabled.",
2 changes: 2 additions & 0 deletions modules/core/locales/zh_cn.json
Original file line number Diff line number Diff line change
@@ -172,6 +172,8 @@
"core.message.set.confirm.init": "该对话未初始化,确认进行操作吗?",
"core.message.set.module.disable.success": "成功为对话关闭了以下模块:",
"core.message.set.module.enable.success": "成功为对话打开了以下模块:",
"core.message.set.module.list": "此对话已开启的模块:",
"core.message.set.module.list.none": "此对话没有开启任何模块。",
"core.message.set.option.edit.success": "成功为对话设置了以下参数:${k} -> ${v}",
"core.message.setup.check.disable": "已关闭错字检查提示。",
"core.message.setup.check.enable": "已开启错字检查提示。",
2 changes: 2 additions & 0 deletions modules/core/locales/zh_tw.json
Original file line number Diff line number Diff line change
@@ -172,6 +172,8 @@
"core.message.set.confirm.init": "此對話未初始化,確認操作嗎?",
"core.message.set.module.disable.success": "成功為對話禁用了以下模組:",
"core.message.set.module.enable.success": "成功為對話啟用了以下模組:",
"core.message.set.module.list": "此對話已啟用的模組:",
"core.message.set.module.list.none": "此對話沒有啟用任何模組。",
"core.message.set.option.edit.success": "成功為對話設定了以下參數:${k} -> ${v}",
"core.message.setup.check.disable": "已停用指令錯誤檢查提醒。",
"core.message.setup.check.enable": "已啟用指令錯誤檢查提醒。",
17 changes: 13 additions & 4 deletions modules/core/su_utils.py
Original file line number Diff line number Diff line change
@@ -73,7 +73,8 @@ async def _(msg: Bot.MessageSession):


@set_.command('module enable <target> <modules> ...',
'module disable <target> <modules> ...')
'module disable <target> <modules> ...',
'module list <target>')
async def _(msg: Bot.MessageSession, target: str):
if not any(target.startswith(f'{target_from}|') for target_from in target_list):
await msg.finish(msg.locale.t("message.id.invalid.target", target=msg.target.target_from))
@@ -82,14 +83,22 @@ async def _(msg: Bot.MessageSession, target: str):
confirm = await msg.wait_confirm(msg.locale.t("core.message.set.confirm.init"), append_instruction=False)
if not confirm:
await msg.finish()
modules = [m for m in [msg.parsed_msg['<modules>']] + msg.parsed_msg.get('...', [])
if m in ModulesManager.return_modules_list(msg.target.target_from)]
if 'enable' in msg.parsed_msg:
modules = [m for m in [msg.parsed_msg['<modules>']] + msg.parsed_msg.get('...', [])
if m in ModulesManager.return_modules_list(msg.target.target_from)]
target_data.enable(modules)
await msg.finish(msg.locale.t("core.message.set.module.enable.success") + ", ".join(modules))
if 'disable' in msg.parsed_msg:
elif 'disable' in msg.parsed_msg:
modules = [m for m in [msg.parsed_msg['<modules>']] + msg.parsed_msg.get('...', [])
if m in ModulesManager.return_modules_list(msg.target.target_from)]
target_data.disable(modules)
await msg.finish(msg.locale.t("core.message.set.module.disable.success") + ", ".join(modules))
elif 'list' in msg.parsed_msg:
modules = sorted(target_data.enabled_modules)
if modules:
await msg.finish(msg.locale.t("core.message.set.module.list") + "\n" + " | ".join(modules))
else:
await msg.finish(msg.locale.t("core.message.set.module.list.none"))


@set_.command('option get <target> [<k>]',

0 comments on commit 470b766

Please sign in to comment.