修复群聊数据无法初始化

This commit is contained in:
HibiKier 2023-05-28 22:57:18 +08:00
parent e4ca110938
commit 7b0785248c
3 changed files with 20 additions and 19 deletions

View File

@ -331,6 +331,10 @@ PS: **ARM平台** 请使用全量版 同时 **如果你的机器 RAM < 1G 可能
## 更新
### 2023/5/28
* 修复群聊数据无法初始化
### 2023/5/24
* 轮盘结算信息使用图片发送

View File

@ -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(
"^&#91;&#91;_task\|(.*)&#93;&#93;",
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()

View File

@ -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