mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-18 03:34:20 +00:00
feat: 添加插件启用禁用指令
This commit is contained in:
+1
-1
Submodule QChatGPT.wiki updated: 0379ac2e14...68c4ef5d24
@@ -1,5 +1,6 @@
|
|||||||
from pkg.qqbot.cmds.model import command
|
from pkg.qqbot.cmds.model import command
|
||||||
import pkg.utils.context
|
import pkg.utils.context
|
||||||
|
import pkg.plugin.switch as plugin_switch
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
@@ -77,6 +78,21 @@ def plugin_operation(cmd, params, is_admin):
|
|||||||
reply = ["[bot]err:未找到插件: {}, 请使用!plugin指令查看插件列表".format(plugin_name)]
|
reply = ["[bot]err:未找到插件: {}, 请使用!plugin指令查看插件列表".format(plugin_name)]
|
||||||
else:
|
else:
|
||||||
reply = ["[bot]err:权限不足,请使用管理员账号私聊发起"]
|
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"):
|
elif params[0].startswith("http"):
|
||||||
if is_admin:
|
if is_admin:
|
||||||
|
|
||||||
@@ -101,7 +117,7 @@ def plugin_operation(cmd, params, is_admin):
|
|||||||
@command(
|
@command(
|
||||||
"plugin",
|
"plugin",
|
||||||
"插件相关操作",
|
"插件相关操作",
|
||||||
"!plugin\n!plugin <插件仓库地址>",
|
"!plugin\n!plugin <插件仓库地址>\!plugin update\n!plugin del <插件名>\n!plugin on <插件名>\n!plugin off <插件名>",
|
||||||
[],
|
[],
|
||||||
False
|
False
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user