nonebot / adapter-qq

NoneBot2 QQ 适配器 / QQ adapter for nonebot2
MIT License
205 stars 18 forks source link

[QQ群] 无法在接受消息指令时获取图片信息 #103

Closed Yuelioi closed 6 months ago

Yuelioi commented 6 months ago

环境

详情

/测试 文字 (指令+文字没有问题) /测试 [图片] (指令+图片报错)

报错如下所示

02-26 18:15:36 [WARNING] nonebot | QQ | Failed to parse event Dispatch(opcode=<Opcode.DISPATCH: 0>, data={'attachments': [{'content_type': 'image/jpeg', 'filename': 'CE56D93217731BCC87C554FA8AD7A8FF.jpg', 'height': 168, 'size': 3512, 'url': 'https://gchat.qpic.cn/gchatpic_new/761708854/761708854-2990635440-CE56D93217731BCC87C554FA8AD7A8FF/0?vuin=435826135&term=0&is_origin=2&is_ntv2=1', 'width': 138}], 'author': {'id': '73070094761266F31B985FB05EC75710', 'member_openid': '73070094761266F31B985FB05EC75710'}, 'content': ' /龙图 ', 'group_id': 'A9FA4B8E24CCD4DD6D18D0FAB2414F6A', 'group_openid': 'A9FA4B8E24CCD4DD6D18D0FAB2414F6A', 'id': 'ROBOT1.0_xQB7jM.LuoOeNiKmZ2M2af85kASWKlAQTpTuQyWbnX6rZVo5MJ16MNAABO7jRGuqgl.Qvlkq1iu9tB-Qgg2ZuA!!', 'timestamp': '2024-02-26T18:15:35+08:00'}, sequence=3, type='GROUP_AT_MESSAGE_CREATE', id='GROUP_AT_MESSAGE_CREATE:xqb7jmluooenikmz2m2acce6zlwjvfsrurvcnuhurruv957wseidnfe0ixfc6s')
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/root/.vscode-server/extensions/ms-python.debugpy-2024.3.10542134-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
    cli.main()
  File "/root/.vscode-server/extensions/ms-python.debugpy-2024.3.10542134-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
    run()
  File "/root/.vscode-server/extensions/ms-python.debugpy-2024.3.10542134-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "/root/.vscode-server/extensions/ms-python.debugpy-2024.3.10542134-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/root/.vscode-server/extensions/ms-python.debugpy-2024.3.10542134-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/root/.vscode-server/extensions/ms-python.debugpy-2024.3.10542134-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "/projects/nobot2/bot.py", line 66, in <module>
    nonebot.run()
  File "/projects/nobot2/.venv/lib/python3.10/site-packages/nonebot/__init__.py", line 333, in run
    get_driver().run(*args, **kwargs)
  File "/projects/nobot2/.venv/lib/python3.10/site-packages/nonebot/drivers/none.py", line 56, in run
    loop.run_until_complete(self._serve())
  File "/usr/lib/python3.10/asyncio/base_events.py", line 636, in run_until_complete
    self.run_forever()
  File "/usr/lib/python3.10/asyncio/base_events.py", line 603, in run_forever
    self._run_once()
  File "/usr/lib/python3.10/asyncio/base_events.py", line 1909, in _run_once
    handle._run()
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/projects/nobot2/.venv/lib/python3.10/site-packages/nonebot/adapters/qq/adapter.py", line 181, in _forward_ws
    await self._loop(bot, ws)
> File "/projects/nobot2/.venv/lib/python3.10/site-packages/nonebot/adapters/qq/adapter.py", line 346, in _loop
    event = self.payload_to_event(payload)
  File "/projects/nobot2/.venv/lib/python3.10/site-packages/nonebot/adapters/qq/adapter.py", line 410, in payload_to_event
    return type_validate_python(EventClass, payload.data)
  File "/projects/nobot2/.venv/lib/python3.10/site-packages/nonebot/compat.py", line 202, in type_validate_python
    return TypeAdapter(type_).validate_python(data)
  File "/projects/nobot2/.venv/lib/python3.10/site-packages/pydantic/type_adapter.py", line 256, in validate_python
    return self.validator.validate_python(__object, strict=strict, from_attributes=from_attributes, context=context)
pydantic_core._pydantic_core.ValidationError: 3 validation errors for GroupAtMessageCreateEvent
attachments.0.height
  Input should be a valid string [type=string_type, input_value=168, input_type=int]
    For further information visit https://errors.pydantic.dev/2.6/v/string_type
attachments.0.width
  Input should be a valid string [type=string_type, input_value=138, input_type=int]
    For further information visit https://errors.pydantic.dev/2.6/v/string_type
attachments.0.size
  Input should be a valid string [type=string_type, input_value=3512, input_type=int]
    For further information visit https://errors.pydantic.dev/2.6/v/string_type