From ab9d3d3d3eec408d9ff48b521f521ac6e6cc5e58 Mon Sep 17 00:00:00 2001 From: snowy Date: Fri, 17 May 2024 00:25:27 +0800 Subject: [PATCH] :bug: satori.Adapter TypeError: 'HeartbeatMetaEvent' object is not subscriptable --- liteyuki/plugins/liteyuki_statistics/stat_monitors.py | 7 ++----- liteyuki/utils/base/ly_typing.py | 6 +++--- main.py | 4 +++- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/liteyuki/plugins/liteyuki_statistics/stat_monitors.py b/liteyuki/plugins/liteyuki_statistics/stat_monitors.py index 48ae0051..63b20009 100644 --- a/liteyuki/plugins/liteyuki_statistics/stat_monitors.py +++ b/liteyuki/plugins/liteyuki_statistics/stat_monitors.py @@ -9,7 +9,7 @@ from liteyuki.utils.base.ly_typing import v11, satori from liteyuki.utils.base.ly_typing import T_Bot, T_MessageEvent from .common import MessageEventModel, msg_db -from ...utils import satori_utils +from liteyuki.utils import satori_utils require("nonebot_plugin_alconna") @@ -18,7 +18,7 @@ require("nonebot_plugin_alconna") async def general_event_monitor(bot: T_Bot, event: T_MessageEvent): if isinstance(bot, satori.Bot): return await satori_event_monitor(bot, event) - else: + elif isinstance(bot, v11.Bot): return await onebot_v11_event_monitor(bot, event) @@ -28,7 +28,6 @@ async def onebot_v11_event_monitor(bot: v11.Bot, event: v11.MessageEvent): group_id = str(event.group_id) else: group_id = "" - mem = MessageEventModel( time=int(time.time()), bot_id=bot.self_id, @@ -58,9 +57,7 @@ async def satori_event_monitor(bot: satori.Bot, event: satori.MessageEvent): adapter="satori", group_id=group_id, user_id=str(event.user.id), - message_id=str(event.message.id), - message=event.message, message_text=event.message.content, message_type=satori_utils.get_message_type(event), diff --git a/liteyuki/utils/base/ly_typing.py b/liteyuki/utils/base/ly_typing.py index c67b7d5b..c13ce309 100644 --- a/liteyuki/utils/base/ly_typing.py +++ b/liteyuki/utils/base/ly_typing.py @@ -2,7 +2,7 @@ from nonebot.adapters.onebot import v11, v12 from nonebot.adapters import satori T_Bot = v11.Bot | v12.Bot | satori.Bot -T_GroupMessageEvent = v11.GroupMessageEvent | v12.GroupMessageEvent | satori.MessageEvent -T_PrivateMessageEvent = v11.PrivateMessageEvent | v12.PrivateMessageEvent | satori.MessageEvent -T_MessageEvent = v11.MessageEvent | v12.MessageEvent | satori.MessageEvent +T_GroupMessageEvent = v11.GroupMessageEvent | v12.GroupMessageEvent +T_PrivateMessageEvent = v11.PrivateMessageEvent | v12.PrivateMessageEvent +T_MessageEvent = v11.MessageEvent | v12.MessageEvent # | satori.MessageEvent T_Message = v11.Message | v12.Message | satori.Message diff --git a/main.py b/main.py index 7265f6c4..b332f58c 100644 --- a/main.py +++ b/main.py @@ -12,7 +12,8 @@ if __name__ == "__mp_main__": static_config = load_from_yaml("config.yml") store_config.update(static_config) nonebot.init(**store_config) - if not store_config['enable_satori']: + + if not store_config.get("enable_satori", False): adapters = [v11.Adapter, v12.Adapter] else: adapters = [v11.Adapter, v12.Adapter, satori.Adapter] @@ -20,6 +21,7 @@ if __name__ == "__mp_main__": for adapter in adapters: driver.register_adapter(adapter) + try: nonebot.load_plugin("liteyuki.liteyuki_main") nonebot.load_from_toml("pyproject.toml")