From 323c2cecf80c4df021000483e8d7ec038a61cd34 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Thu, 11 May 2023 21:52:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/command/command.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/model/command/command.py b/model/command/command.py index c744ebdde..df4c4871f 100644 --- a/model/command/command.py +++ b/model/command/command.py @@ -44,7 +44,40 @@ class Command: if self.command_start_with(message, "nick"): return True, self.set_nick(message, platform) + if self.command_start_with(message, "plugin"): + return True, self.plugin_oper(message, role) + return False, None + + ''' + 插件指令 + ''' + def plugin_oper(message: str, role: str): + l = message.split(" ") + if len(l) < 3: + return True, "【安装插件】示例:\n安装插件: \nplugin i 插件Github地址\n卸载插件: \nplugin i 插件名", "plugin" + else: + ppath = "" + if os.path.exists("addons/plugins"): + ppath = putil.get_modules("addons/plugins") + elif os.path.exists("QQChannelChatGPT/addons/plugins"): + ppath = putil.get_modules("QQChannelChatGPT/addons/plugins") + else: + return False, "未找到插件目录", "plugin" + if l[1] == "i": + try: + Repo.clone_from(l[2],to_path=ppath,branch='master') + return False, "插件拉取成功~", "plugin" + except BaseException as e: + return False, f"拉取插件失败,原因: {str(e)}", "plugin" + elif l[1] == "d": + try: + os.remove(os.path.join(ppath, l[2])) + return False, "插件卸载成功~", "plugin" + except BaseException as e: + return False, f"卸载插件失败,原因: {str(e)}", "plugin" + + ''' nick: 存储机器人的昵称