diff --git a/zhenxun/builtin_plugins/admin/plugin_switch/__init__.py b/zhenxun/builtin_plugins/admin/plugin_switch/__init__.py index 36e57c41..aa08ae78 100644 --- a/zhenxun/builtin_plugins/admin/plugin_switch/__init__.py +++ b/zhenxun/builtin_plugins/admin/plugin_switch/__init__.py @@ -76,20 +76,34 @@ async def _( bot: Bot, session: EventSession, arparma: Arparma, - task: Query[bool] = AlconnaQuery("task.value", False), ): - image = None - if task.result: - image = await build_task(session.id3 or session.id2) - elif session.id1 in bot.config.superusers: + if session.id1 in bot.config.superusers: image = await build_plugin() - if image: await Image(image.pic2bytes()).send(reply=True) logger.info( - f"查看{'功能' if arparma.find('task') else '被动'}列表", + f"查看功能列表", arparma.header_result, session=session, ) + else: + await Text("权限不足捏...").send(reply=True) + + +@_status_matcher.assign("task") +async def _( + session: EventSession, + arparma: Arparma, +): + image = await build_task(session.id3 or session.id2) + if image: + await Image(image.pic2bytes()).send(reply=True) + logger.info( + f"查看群被动列表", + arparma.header_result, + session=session, + ) + else: + await Text("获取群被动任务失败...").send(reply=True) @_status_matcher.assign("open") diff --git a/zhenxun/plugins/group_welcome_msg.py b/zhenxun/plugins/group_welcome_msg.py index 2784f458..064987e6 100644 --- a/zhenxun/plugins/group_welcome_msg.py +++ b/zhenxun/plugins/group_welcome_msg.py @@ -47,7 +47,7 @@ async def _( file = path / "text.json" if not file.exists(): await Text("未设置群欢迎消息...").finish(reply=True) - message = json.load(open(file))["message"] + message = json.load(open(file, encoding="utf8"))["message"] message_split = re.split(r"\[image:\d+\]", message) if len(message_split) == 1: await Text(message_split[0]).finish(reply=True) diff --git a/zhenxun/utils/image_utils.py b/zhenxun/utils/image_utils.py index b44abcde..0c6a2b27 100644 --- a/zhenxun/utils/image_utils.py +++ b/zhenxun/utils/image_utils.py @@ -380,8 +380,12 @@ def get_img_hash(image_file: str | Path) -> str: 返回: str: 哈希值 """ - with open(image_file, "rb") as fp: - hash_value = imagehash.average_hash(Image.open(fp)) + hash_value = "" + try: + with open(image_file, "rb") as fp: + hash_value = imagehash.average_hash(Image.open(fp)) + except Exception as e: + logger.warning(f"获取图片Hash出错", "禁言检测", e=e) return str(hash_value)