mirror of
https://github.com/RockChinQ/QChatGPT.git
synced 2024-11-16 11:42:44 +08:00
feat: 添加插件启用禁用指令
This commit is contained in:
parent
f96ae56bce
commit
7b56bcf7a9
|
@ -1 +1 @@
|
|||
Subproject commit 0379ac2e14395bd66a0e3c4e45413cf0261d4725
|
||||
Subproject commit 68c4ef5d240877a871044e0b340db183453799bf
|
|
@ -1,5 +1,6 @@
|
|||
from pkg.qqbot.cmds.model import command
|
||||
import pkg.utils.context
|
||||
import pkg.plugin.switch as plugin_switch
|
||||
|
||||
import os
|
||||
import threading
|
||||
|
@ -77,6 +78,21 @@ def plugin_operation(cmd, params, is_admin):
|
|||
reply = ["[bot]err:未找到插件: {}, 请使用!plugin指令查看插件列表".format(plugin_name)]
|
||||
else:
|
||||
reply = ["[bot]err:权限不足,请使用管理员账号私聊发起"]
|
||||
elif params[0] == 'on' or params[0] == 'off' :
|
||||
new_status = params[0] == 'on'
|
||||
if is_admin:
|
||||
if len(params) < 2:
|
||||
reply = ["[bot]err:未指定插件名"]
|
||||
else:
|
||||
plugin_name = params[1]
|
||||
if plugin_name in plugin_list:
|
||||
plugin_list[plugin_name]['enabled'] = new_status
|
||||
plugin_switch.dump_switch()
|
||||
reply = ["[bot]已{}插件: {}".format("启用" if new_status else "禁用", plugin_name)]
|
||||
else:
|
||||
reply = ["[bot]err:未找到插件: {}, 请使用!plugin指令查看插件列表".format(plugin_name)]
|
||||
else:
|
||||
reply = ["[bot]err:权限不足,请使用管理员账号私聊发起"]
|
||||
elif params[0].startswith("http"):
|
||||
if is_admin:
|
||||
|
||||
|
@ -101,7 +117,7 @@ def plugin_operation(cmd, params, is_admin):
|
|||
@command(
|
||||
"plugin",
|
||||
"插件相关操作",
|
||||
"!plugin\n!plugin <插件仓库地址>",
|
||||
"!plugin\n!plugin <插件仓库地址>\!plugin update\n!plugin del <插件名>\n!plugin on <插件名>\n!plugin off <插件名>",
|
||||
[],
|
||||
False
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user