We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KeyError: 'file_id'
在 Telegram 适配器下收到 video/animation/voice/audio/document 消息段,使用 UniMessage 解析时出现错误: KeyError: 'file_id'
可能相关的代码: nonebot/adapter-telegram - message.py
插件
from nonebot import on_message, require require("nonebot_plugin_alconna") from nonebot_plugin_alconna import UniMsg @on_message().handle() async def _(msg: UniMsg): ...
在 Telegram 中向 Bot 发送任意上述类型文件,例如 GIF 图片。
正常解析上述消息段
11-23 20:20:53 [DEBUG] nonebot | Telegram | {'message_id': ***, 'date': ***, 'chat': {'id': ***, 'type': 'supergroup', 'title': '***'}, 'message': [{'type': 'animation', 'data': {'file': 'Cg***gQ', 'thumbnail': 'AAM***2BA'}}], 'original_message': [{'type': 'animation', 'data': {'file': 'Cg***gQ', 'thumbnail': 'AA***BA'}}], 'from_': {'id': ***, 'is_bot': False, 'first_name': '***', 'username': '***', 'language_code': 'zh-hans'}} 11-23 20:20:53 [SUCCESS] nonebot | Telegram *** | [message.group]: Message *** from ***@[Chat ***]: [animation:Cg***gQ, AA***BA] 11-23 20:20:53 [DEBUG] nonebot | Checking for matchers in priority 1... 11-23 20:20:53 [INFO] nonebot | Event will be handled by Matcher(type='message', module=src.plugins.test, lineno=7) 11-23 20:20:53 [DEBUG] nonebot | Running Matcher(type='message', module=src.plugins.test, lineno=7) 11-23 20:20:53 [DEBUG] nonebot | Running handler Dependent(call=_) 11-23 20:20:53 [INFO] nonebot | Matcher(type='message', module=src.plugins.test, lineno=7) running complete 11-23 20:20:53 [ERROR] nonebot | Running Matcher(type='message', module=src.plugins.test, lineno=7) failed. + Exception Group Traceback (most recent call last): | File "<string>", line 15, in <module> | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot\__init__.py", line 337, in run | get_driver().run(*args, **kwargs) | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot\drivers\fastapi.py", line 188, in run | uvicorn.run( | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\uvicorn\main.py", line 579, in run | server.run() | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\uvicorn\server.py", line 65, in run | return asyncio.run(self.serve(sockets=sockets)) | File "C:\Users\***\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\asyncio\runners.py", line 194, in run | return runner.run(main) | File "C:\Users\***\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\asyncio\runners.py", line 118, in run | return self._loop.run_until_complete(task) | File "C:\Users\***\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\asyncio\base_events.py", line 674, in run_until_complete | self.run_forever() | File "C:\Users\***\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\asyncio\windows_events.py", line 322, in run_forever | super().run_forever() | File "C:\Users\***\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\asyncio\base_events.py", line 641, in run_forever | self._run_once() | File "C:\Users\***\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\asyncio\base_events.py", line 1986, in _run_once | handle._run() | File "C:\Users\***\AppData\Roaming\uv\python\cpython-3.12.7-windows-x86_64-none\Lib\asyncio\events.py", line 88, in _run | self._context.run(self._callback, *self._args) | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot\utils.py", line 254, in run_coro_with_shield | return await coro | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot\message.py", line 506, in check_and_run_matcher | await _run_matcher( | > File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot\message.py", line 458, in _run_matcher | await matcher.run(bot, event, state, stack, dependency_cache) | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot\internal\matcher\matcher.py", line 891, in run | with catch( | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\exceptiongroup\_catch.py", line 39, in __exit__ | raise unhandled from exc.__cause__ | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot\internal\matcher\matcher.py", line 900, in run | await self.simple_run(bot, event, state, stack, dependency_cache) | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot\internal\matcher\matcher.py", line 822, in simple_run | with catch({StopPropagation: _handle_stop_propagation}): | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\exceptiongroup\_catch.py", line 39, in __exit__ | raise unhandled from exc.__cause__ | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot\internal\matcher\matcher.py", line 836, in simple_run | with catch({SkippedException: _handle_skipped}): | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\exceptiongroup\_catch.py", line 39, in __exit__ | raise unhandled from exc.__cause__ | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot\internal\matcher\matcher.py", line 837, in simple_run | await handler( | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot\dependencies\__init__.py", line 104, in __call__ | with catch({SkippedException: _handle_skipped}): | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\exceptiongroup\_catch.py", line 39, in __exit__ | raise unhandled from exc.__cause__ | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot\dependencies\__init__.py", line 109, in __call__ | values = await self.solve(**kwargs) | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot\dependencies\__init__.py", line 219, in solve | async with anyio.create_task_group() as tg: | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 763, in __aexit__ | raise BaseExceptionGroup( | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception) +-+---------------- 1 ---------------- | Traceback (most recent call last): | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot\utils.py", line 254, in run_coro_with_shield | return await coro | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot\dependencies\__init__.py", line 216, in _solve_field | value = await self._solve_field(field, params) | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot\dependencies\__init__.py", line 199, in _solve_field | value = await param._solve(**params) | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot\internal\params.py", line 309, in _solve | result = await target | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot_plugin_alconna\uniseg\params.py", line 15, in _uni_msg | return await UniMessage.generate(event=event, bot=bot) | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot_plugin_alconna\uniseg\message.py", line 1233, in generate | result = UniMessage(fn.generate(message)) | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot_plugin_alconna\uniseg\builder.py", line 73, in generate | seg = self.convert(ms) | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot_plugin_alconna\uniseg\builder.py", line 49, in convert | res = self._mapping[seg_type](seg) | File "D:\SourceCode\Python\nonebot\test\.venv\Lib\site-packages\nonebot_plugin_alconna\uniseg\adapters\telegram\builder.py", line 37, in video | return Video(id=seg.data["file_id"]) | KeyError: 'file_id' +------------------------------------ 11-23 20:20:53 [DEBUG] nonebot | Stop event propagation 11-23 20:20:53 [DEBUG] nonebot | Checking for matchers completed
The text was updated successfully, but these errors were encountered:
你先降级tg适配器版本看看,tg适配器现在这个版本写的有点问题感觉
Sorry, something went wrong.
0eb61d1
🐛 fix telegram file build
bc5fbbb
resolve #79
No branches or pull requests
请确认:
Bug
问题
在 Telegram 适配器下收到 video/animation/voice/audio/document 消息段,使用 UniMessage 解析时出现错误:
KeyError: 'file_id'
可能相关的代码: nonebot/adapter-telegram - message.py
如何复现
插件
在 Telegram 中向 Bot 发送任意上述类型文件,例如 GIF 图片。
预期行为
正常解析上述消息段
使用环境:
日志/截图
日志
The text was updated successfully, but these errors were encountered: