🐛 satori.Adapter TypeError: 'HeartbeatMetaEvent' object is not subscriptable

This commit is contained in:
远野千束 2024-05-17 00:25:27 +08:00
parent 06a109d2b5
commit ab9d3d3d3e
3 changed files with 8 additions and 9 deletions

View File

@ -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 liteyuki.utils.base.ly_typing import T_Bot, T_MessageEvent
from .common import MessageEventModel, msg_db from .common import MessageEventModel, msg_db
from ...utils import satori_utils from liteyuki.utils import satori_utils
require("nonebot_plugin_alconna") require("nonebot_plugin_alconna")
@ -18,7 +18,7 @@ require("nonebot_plugin_alconna")
async def general_event_monitor(bot: T_Bot, event: T_MessageEvent): async def general_event_monitor(bot: T_Bot, event: T_MessageEvent):
if isinstance(bot, satori.Bot): if isinstance(bot, satori.Bot):
return await satori_event_monitor(bot, event) return await satori_event_monitor(bot, event)
else: elif isinstance(bot, v11.Bot):
return await onebot_v11_event_monitor(bot, event) 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) group_id = str(event.group_id)
else: else:
group_id = "" group_id = ""
mem = MessageEventModel( mem = MessageEventModel(
time=int(time.time()), time=int(time.time()),
bot_id=bot.self_id, bot_id=bot.self_id,
@ -58,9 +57,7 @@ async def satori_event_monitor(bot: satori.Bot, event: satori.MessageEvent):
adapter="satori", adapter="satori",
group_id=group_id, group_id=group_id,
user_id=str(event.user.id), user_id=str(event.user.id),
message_id=str(event.message.id), message_id=str(event.message.id),
message=event.message, message=event.message,
message_text=event.message.content, message_text=event.message.content,
message_type=satori_utils.get_message_type(event), message_type=satori_utils.get_message_type(event),

View File

@ -2,7 +2,7 @@ from nonebot.adapters.onebot import v11, v12
from nonebot.adapters import satori from nonebot.adapters import satori
T_Bot = v11.Bot | v12.Bot | satori.Bot T_Bot = v11.Bot | v12.Bot | satori.Bot
T_GroupMessageEvent = v11.GroupMessageEvent | v12.GroupMessageEvent | satori.MessageEvent T_GroupMessageEvent = v11.GroupMessageEvent | v12.GroupMessageEvent
T_PrivateMessageEvent = v11.PrivateMessageEvent | v12.PrivateMessageEvent | satori.MessageEvent T_PrivateMessageEvent = v11.PrivateMessageEvent | v12.PrivateMessageEvent
T_MessageEvent = v11.MessageEvent | v12.MessageEvent | satori.MessageEvent T_MessageEvent = v11.MessageEvent | v12.MessageEvent # | satori.MessageEvent
T_Message = v11.Message | v12.Message | satori.Message T_Message = v11.Message | v12.Message | satori.Message

View File

@ -12,7 +12,8 @@ if __name__ == "__mp_main__":
static_config = load_from_yaml("config.yml") static_config = load_from_yaml("config.yml")
store_config.update(static_config) store_config.update(static_config)
nonebot.init(**store_config) nonebot.init(**store_config)
if not store_config['enable_satori']:
if not store_config.get("enable_satori", False):
adapters = [v11.Adapter, v12.Adapter] adapters = [v11.Adapter, v12.Adapter]
else: else:
adapters = [v11.Adapter, v12.Adapter, satori.Adapter] adapters = [v11.Adapter, v12.Adapter, satori.Adapter]
@ -20,6 +21,7 @@ if __name__ == "__mp_main__":
for adapter in adapters: for adapter in adapters:
driver.register_adapter(adapter) driver.register_adapter(adapter)
try: try:
nonebot.load_plugin("liteyuki.liteyuki_main") nonebot.load_plugin("liteyuki.liteyuki_main")
nonebot.load_from_toml("pyproject.toml") nonebot.load_from_toml("pyproject.toml")