From e2980305a50e05bcef602bf471adc1d27ee18c06 Mon Sep 17 00:00:00 2001 From: UnCLAS-Prommer Date: Sun, 6 Jul 2025 12:30:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=86=99=E9=94=99=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/database.py b/src/database.py index 612c4c6..f9a94d1 100644 --- a/src/database.py +++ b/src/database.py @@ -49,7 +49,7 @@ class DatabaseManager: """ def __init__(self): - os.mkdir(os.path.join(os.path.dirname(__file__), "..", "data"), exist_ok=True) # 确保数据目录存在 + os.makedirs(os.path.join(os.path.dirname(__file__), "..", "data"), exist_ok=True) # 确保数据目录存在 DATABASE_FILE = os.path.join(os.path.dirname(__file__), "..", "data", "NapcatAdapter.db") self.sqlite_url = f"sqlite:///{DATABASE_FILE}" # SQLite 数据库 URL self.engine = create_engine(self.sqlite_url, echo=False) # 创建数据库引擎 From ab9bd1c67586c8e0b9457471994abee48cbb45e3 Mon Sep 17 00:00:00 2001 From: UnCLAS-Prommer Date: Mon, 7 Jul 2025 16:49:07 +0800 Subject: [PATCH 2/2] 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(), }, )