From 7b0785248cf7dce697ce127df2718092a3c3b2a5 Mon Sep 17 00:00:00 2001 From: HibiKier <775757368@qq.com> Date: Sun, 28 May 2023 22:57:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BE=A4=E8=81=8A=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=97=A0=E6=B3=95=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++++ basic_plugins/hooks/task_hook.py | 27 +++++++++++---------------- utils/manager/group_manager.py | 8 +++++--- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index c348ef38..b542f596 100644 --- a/README.md +++ b/README.md @@ -331,6 +331,10 @@ PS: **ARM平台** 请使用全量版 同时 **如果你的机器 RAM < 1G 可能 ## 更新 +### 2023/5/28 + +* 修复群聊数据无法初始化 + ### 2023/5/24 * 轮盘结算信息使用图片发送 diff --git a/basic_plugins/hooks/task_hook.py b/basic_plugins/hooks/task_hook.py index 24039559..8cfbae12 100644 --- a/basic_plugins/hooks/task_hook.py +++ b/basic_plugins/hooks/task_hook.py @@ -1,7 +1,7 @@ import re from typing import Any, Dict -from nonebot.adapters.onebot.v11 import Bot, Message +from nonebot.adapters.onebot.v11 import Bot, Message, unescape from nonebot.exception import MockApiException from services.log import logger @@ -14,27 +14,22 @@ async def _(bot: Bot, api: str, data: Dict[str, Any]): task = None group_id = None try: + msg = unescape( + data["message"].strip() + if isinstance(data["message"], str) + else str(data["message"]["text"]).strip() + ) if ( ( (api == "send_msg" and data.get("message_type") == "group") or api == "send_group_msg" ) and ( - ( - r := re.search( - "^\[\[_task\|(.*)]]", - data["message"].strip() - if isinstance(data["message"], str) - else str(data["message"]["text"]).strip(), - ) - ) - or ( - r := re.search( - "^[[_task\|(.*)]]", - data["message"].strip() - if isinstance(data["message"], str) - else str(data["message"]["text"]).strip(), - ) + r := re.search( + "^\[\[_task\|(.*)]]", + data["message"].strip() + if isinstance(data["message"], str) + else str(data["message"]["text"]).strip(), ) ) and r.group(1) in group_manager.get_task_data().keys() diff --git a/utils/manager/group_manager.py b/utils/manager/group_manager.py index c2b76d99..80f37337 100644 --- a/utils/manager/group_manager.py +++ b/utils/manager/group_manager.py @@ -35,9 +35,11 @@ def init_group(func: Callable): def wrapper(*args, **kwargs): self = args[0] - group_id = list(filter(lambda x: is_number(x), args[1:]))[0] - if self is not None and group_id and not self._data.group_manager.get(group_id): - self._data.group_manager[group_id] = BaseGroup() + if arg_list := list(filter(lambda x: is_number(x), args[1:])): + group_id = str(arg_list[0]) + if self is not None and group_id and not self._data.group_manager.get(group_id): + self._data.group_manager[group_id] = BaseGroup() + self.save() return func(*args, **kwargs) return wrapper