From ab9bd1c67586c8e0b9457471994abee48cbb45e3 Mon Sep 17 00:00:00 2001 From: UnCLAS-Prommer Date: Mon, 7 Jul 2025 16:49:07 +0800 Subject: [PATCH] fix #49 --- command_args.md | 2 +- notify_args.md | 6 +++++- pyproject.toml | 2 +- src/__init__.py | 2 +- src/config/config.py | 2 +- src/recv_handler/notice_handler.py | 6 +++--- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/command_args.md b/command_args.md index afd5f37..3c8947d 100644 --- a/command_args.md +++ b/command_args.md @@ -57,4 +57,4 @@ Seg.data: Dict[str, Any] = { } } ``` -message_id怎么搞到手全凭你本事,也请在自己的插件里写好确定是否能撤回对应的消息的功能,毕竟这玩意真的单纯根据message_id撤消息 \ No newline at end of file +其中message_id是消息的实际qq_id,于新版的mmc中可以从数据库获取(如果工作正常的话) \ No newline at end of file diff --git a/notify_args.md b/notify_args.md index 31e1151..8a94fef 100644 --- a/notify_args.md +++ b/notify_args.md @@ -7,10 +7,12 @@ Seg.type = "notify" Seg.data: Dict[str, Any] = { "sub_type": "ban", "duration": "对应的禁言时间,单位为秒", - "banned_user_info": "被禁言的用户的信息,为标准UserInfo对象" + "banned_user_info": "被禁言的用户的信息,为标准UserInfo转换成的字典" } ``` 此时`MessageBase.UserInfo`,即消息的`UserInfo`为操作者(operator)的信息 + +**注意: `banned_user_info`需要自行调用`UserInfo.from_dict()`函数转换为标准UserInfo对象** ## 群聊开启全体禁言 ```python Seg.data: Dict[str, Any] = { @@ -30,6 +32,8 @@ Seg.data: Dict[str, Any] = { **对于自然禁言解除的情况,此时`MessageBase.UserInfo`为`None`** 对于手动解除禁言的情况,此时`MessageBase.UserInfo`,即消息的`UserInfo`为操作者(operator)的信息 + +**注意: `lifted_user_info`需要自行调用`UserInfo.from_dict()`函数转换为标准UserInfo对象** ## 群聊关闭全体禁言 ```python Seg.data: Dict[str, Any] = { diff --git a/pyproject.toml b/pyproject.toml index aa72630..6f18a98 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "MaiBotNapcatAdapter" -version = "0.4.2" +version = "0.4.3" description = "A MaiBot adapter for Napcat" [tool.ruff] diff --git a/src/__init__.py b/src/__init__.py index b8e354e..0159c09 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -21,4 +21,4 @@ class CommandType(Enum): pyproject_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "pyproject.toml") toml_data = tomlkit.parse(open(pyproject_path, "r", encoding="utf-8").read()) version = toml_data["project"]["version"] -logger.info(f"版本\n\nMaiBot-Napcat-Adapter 版本: {version}\n喜欢的话点个star喵~\n") \ No newline at end of file +logger.info(f"版本\n\nMaiBot-Napcat-Adapter 版本: {version}\n喜欢的话点个star喵~\n") diff --git a/src/config/config.py b/src/config/config.py index 5143f39..f3b90bb 100644 --- a/src/config/config.py +++ b/src/config/config.py @@ -60,7 +60,7 @@ def update_config(): # 创建备份文件夹 backup_dir = "config_backup" os.makedirs(backup_dir, exist_ok=True) - + # 备份文件名 timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") old_backup_path = os.path.join(backup_dir, f"config.toml.bak.{timestamp}") diff --git a/src/recv_handler/notice_handler.py b/src/recv_handler/notice_handler.py index df46083..1e51ea4 100644 --- a/src/recv_handler/notice_handler.py +++ b/src/recv_handler/notice_handler.py @@ -300,7 +300,7 @@ class NoticeHandler: data={ "sub_type": sub_type, "duration": duration, - "banned_user_info": banned_user_info, + "banned_user_info": banned_user_info.to_dict() if banned_user_info else None, }, ) @@ -364,7 +364,7 @@ class NoticeHandler: type="notify", data={ "sub_type": sub_type, - "lifted_user_info": lifted_user_info, + "lifted_user_info": lifted_user_info.to_dict() if lifted_user_info else None, }, ) return seg_data, operator_info @@ -463,7 +463,7 @@ class NoticeHandler: type="notify", data={ "sub_type": "lift_ban", - "lifted_user_info": lifted_user_info, + "lifted_user_info": lifted_user_info.to_dict(), }, )