From c6cf1153c1e8d98815b40eb56e95c017813a8e41 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Sun, 21 May 2023 11:00:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DWindows=E4=B8=8B?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=8F=92=E4=BB=B6=E6=8A=A5=E9=94=99=E6=8B=92?= =?UTF-8?q?=E7=BB=9D=E8=AE=BF=E9=97=AE=E7=9A=84=E9=97=AE=E9=A2=98;=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9D=83=E9=99=90=E7=BB=84=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cores/qqbot/core.py | 7 ++++++- model/command/command.py | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/cores/qqbot/core.py b/cores/qqbot/core.py index 1077ceb1..660cdbeb 100644 --- a/cores/qqbot/core.py +++ b/cores/qqbot/core.py @@ -528,7 +528,12 @@ def oper_msg(message, qq_msg = message.message[0].text session_id = message.user_id role = "member" - if ("user_id" in message.sender and str(message.sender.user_id) == admin_qq) or ("tiny_id" in message.sender and str(message.sender.tiny_id) == admin_qqchan): + + if message.type == "GuildMessage": + sender_id = str(message.sender.tiny_id) + else: + sender_id = str(message.sender.user_id) + if sender_id == admin_qq or sender_id == admin_qqchan: gu.log("检测到管理员身份", gu.LEVEL_INFO, tag="GOCQ") role = "admin" diff --git a/model/command/command.py b/model/command/command.py index bc4658dd..6a315680 100644 --- a/model/command/command.py +++ b/model/command/command.py @@ -11,6 +11,7 @@ import shutil import importlib from util import general_utils as gu from model.platform.qq import QQ +import stat PLATFORM_QQCHAN = 'qqchan' PLATFORM_GOCQ = 'gocq' @@ -151,7 +152,8 @@ class Command: return False, f"你的身份组{role}没有权限删除插件", "plugin" try: # 删除文件夹 - shutil.rmtree(os.path.join(ppath, l[2])) + # shutil.rmtree(os.path.join(ppath, l[2])) + self.remove_dir(os.path.join(ppath, l[2])) if l[2] in cached_plugins: del cached_plugins[l[2]] return True, "插件卸载成功~", "plugin" @@ -204,6 +206,18 @@ class Command: if role != "admin": return False, f"你的身份组{role}没有权限开发者模式", "plugin" return True, "cached_plugins: \n" + str(cached_plugins), "plugin" + + + def remove_dir(self, file_path): + while 1: + if not os.path.exists(file_path): + break + try: + shutil.rmtree(file_path) + except PermissionError as e: + err_file_path = str(e).split("\'", 2)[1] + if os.path.exists(err_file_path): + os.chmod(err_file_path, stat.S_IWUSR) '''