mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-14 21:52:56 +08:00
修复群聊数据无法初始化
This commit is contained in:
parent
e4ca110938
commit
7b0785248c
@ -331,6 +331,10 @@ PS: **ARM平台** 请使用全量版 同时 **如果你的机器 RAM < 1G 可能
|
||||
|
||||
## 更新
|
||||
|
||||
### 2023/5/28
|
||||
|
||||
* 修复群聊数据无法初始化
|
||||
|
||||
### 2023/5/24
|
||||
|
||||
* 轮盘结算信息使用图片发送
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user