nonebot / adapter-satori

NoneBot2 Satori 适配器 / Satori Protocol adapter for nonebot2
MIT License
85 stars 5 forks source link

[Bug]: 接收其他适配器事件时出现异常日志 #34

Closed wyf7685 closed 2 hours ago

wyf7685 commented 2 hours ago

确认项

操作系统

Windows

Python 版本

3.12.7

NoneBot 版本

2.3.3

适配器

0.13.0rc3

协议端

未对接 Satori 服务端,仅连接 Matcha

描述问题

安装 Satori 适配器和 nonebot_plugin_chatrecorder,接收其他适配器事件时出现异常日志

10-17 17:12:18 [WARNING] nonebot | Satori | received event without `self_id` and `platform`, this may be caused by Satori Server used protocol version 1.2.
10-17 17:12:18 [WARNING] nonebot | Satori | received event without login, this may be caused by a bug of Satori Server.

复现步骤

  1. 安装 Satori 适配器和 OneBot V11 适配器
  2. 安装插件 nonebot_plugin_chatrecorder
  3. 使用 Matcha 连接至 nonebot
  4. 在协议端发送任意事件 (如心跳包) 时出现 Satori 适配器的 WARNING 日志

期望的结果

避免输出上述刷屏 WARNING 日志

截图或日志

10-17 17:12:15 [SUCCESS] nonebot | NoneBot is initializing...
10-17 17:12:15 [INFO] nonebot | Current Env: dev
10-17 17:12:15 [DEBUG] nonebot | Loaded Config: {'driver': '~fastapi+~httpx+~websockets', 'host': IPv4Address('0.0.0.0'), 'port': 8090, 'log_level': 'TRACE', 'api_timeout': 30.0, 'superusers': set(), 'nickname': set(), 'command_start': {'/'}, 'command_sep': {'.'}, 'session_expire_timeout': datetime.timedelta(seconds=120), 'environment': 'dev', 'localstore_cache_dir': './data/datastore/cache', 'localstore_config_dir': './data/datastore/config', 'localstore_data_dir': './data/datastore/data'}
10-17 17:12:15 [TRACE] nonebot | Detected driver <class 'nonebot.drivers.fastapi.Driver'> with mixins [<class 'nonebot.drivers.httpx.Mixin'>, <class 'nonebot.drivers.websockets.Mixin'>].
10-17 17:12:15 [DEBUG] nonebot | Succeeded to load adapter "OneBot V11"
10-17 17:12:16 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_localstore"
10-17 17:12:16 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_orm"
10-17 17:12:16 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_session"
10-17 17:12:16 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_session_orm"
10-17 17:12:16 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_chatrecorder"
10-17 17:12:16 [SUCCESS] nonebot | Running NoneBot...
10-17 17:12:16 [DEBUG] nonebot | Loaded adapters: OneBot V11
10-17 17:12:16 [INFO] uvicorn | Started server process [8448]
10-17 17:12:16 [INFO] uvicorn | Waiting for application startup.
10-17 17:12:16 [DEBUG] alembic | Context impl SQLiteImpl.
10-17 17:12:16 [DEBUG] alembic | Will assume non-transactional DDL.
10-17 17:12:16 [INFO] nonebot_plugin_orm | 没有检测到新的升级操作
10-17 17:12:16 [INFO] uvicorn | Application startup complete.
10-17 17:12:16 [INFO] uvicorn | Uvicorn running on http://0.0.0.0:8090 (Press CTRL+C to quit)
10-17 17:12:18 [INFO] uvicorn | ('127.0.0.1', 10210) - "WebSocket /onebot/v11/ws" [accepted]
10-17 17:12:18 [INFO] nonebot | OneBot V11 | Bot 2590252216 connected
10-17 17:12:18 [INFO] websockets | connection open
10-17 17:12:18 [DEBUG] nonebot | Running PostProcessors...
10-17 17:12:18 [WARNING] nonebot | Satori | received event without `self_id` and `platform`, this may be caused by Satori Server used protocol version 1.2.
10-17 17:12:18 [WARNING] nonebot | Satori | received event without login, this may be caused by a bug of Satori Server.
10-17 17:12:18 [TRACE] nonebot | Dependent(call=record_recv_msg) skipped due to TypeMisMatch(param=event, type=MessageEvent, value=LifecycleMetaEvent(time=1729156339, self_id=2590252216, post_type='meta_event', meta_event_type='lifecycle', sub_type='connect')>
10-17 17:12:18 [TRACE] nonebot | Dependent(call=record_recv_msg) skipped due to TypeMisMatch(param=bot, type=Bot, value=Bot(type='OneBot V11', self_id='2590252216')>
10-17 17:12:18 [TRACE] nonebot | Dependent(call=record_recv_msg) skipped due to TypeMisMatch(param=bot, type=Bot, value=Bot(type='OneBot V11', self_id='2590252216')>
10-17 17:12:22 [DEBUG] nonebot | Running PostProcessors...
10-17 17:12:22 [WARNING] nonebot | Satori | received event without `self_id` and `platform`, this may be caused by Satori Server used protocol version 1.2.
10-17 17:12:22 [WARNING] nonebot | Satori | received event without login, this may be caused by a bug of Satori Server.
10-17 17:12:22 [TRACE] nonebot | Dependent(call=record_recv_msg) skipped due to TypeMisMatch(param=event, type=MessageEvent, value=HeartbeatMetaEvent(time=1729156342, self_id=2590252216, post_type='meta_event', meta_event_type='heartbeat', status=Status(online=True, good=True), interval=3)>
10-17 17:12:22 [TRACE] nonebot | Dependent(call=record_recv_msg) skipped due to TypeMisMatch(param=bot, type=Bot, value=Bot(type='OneBot V11', self_id='2590252216')>
10-17 17:12:22 [TRACE] nonebot | Dependent(call=record_recv_msg) skipped due to TypeMisMatch(param=bot, type=Bot, value=Bot(type='OneBot V11', self_id='2590252216')>
10-17 17:12:23 [WARNING] nonebot | OneBot V11 | WebSocket for Bot 2590252216 closed by peer
10-17 17:12:23 [INFO] websockets | connection closed
10-17 17:12:24 [INFO] uvicorn | Shutting down
10-17 17:12:24 [INFO] uvicorn | Waiting for application shutdown.
10-17 17:12:24 [INFO] uvicorn | Application shutdown complete.
10-17 17:12:24 [INFO] uvicorn | Finished server process [8448]

Nonebot 配置项

No response

RF-Tar-Railt commented 2 hours ago

?你satori adapter都没加载为什么会有log

只有一种可能,chatrecord尝试用satori的事件模型来解析数据

wyf7685 commented 2 hours ago
dependencies = [
  "nonebot2[fastapi,httpx,websockets]>=2.3.3",
  "nonebot-adapter-onebot>=2.4.4",
  "nonebot-adapter-satori>=0.13.0rc3",
  "nonebot-plugin-chatrecorder>=0.6.2",
  "nonebot-plugin-orm[default]>=0.7.6",
]

虚拟环境里装了两个适配器

chatrecorder 在加载的时候会尝试加载所有存在的适配器,然后注册 hook

RF-Tar-Railt commented 2 hours ago

找plugin-chatrecorder作者去