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
event.dict()
KeyError: 'type'
描述问题:
使用 event.dict() 方法报错
如何复现?
编写测试插件
from nonebot.typing import T_State from nonebot.plugin import on_message from nonebot.matcher import Matcher from nonebot.adapters.cqhttp.event import Event from nonebot.adapters.cqhttp.bot import Bot from nonebot.message import run_preprocessor test = on_message() @run_preprocessor async def handle_run_preprocessor(matcher: Matcher, bot: Bot, event: Event, state: T_State): print(event.dict())
期望的结果
正常输出
环境信息:
协议端信息:
截图或日志
Traceback (most recent call last): File "C:\Users\ailitonia\PycharmProjects\nonebot2_miya\venv\lib\site-packages\nonebot\message.py", line 126, in _check_matcher await _run_matcher(Matcher, bot, event, state) > File "C:\Users\ailitonia\PycharmProjects\nonebot2_miya\venv\lib\site-packages\nonebot\message.py", line 139, in _run_matcher await asyncio.gather(*coros) File "C:\Users\ailitonia\PycharmProjects\nonebot2_miya\omega_miya\utils\test.py", line 24, in handle_run_preprocessor print('event dict', event.dict()) File "pydantic\main.py", line 510, in pydantic.main.BaseModel.dict return dict( File "pydantic\main.py", line 875, in _iter v = self._get_value( File "pydantic\main.py", line 816, in pydantic.main.BaseModel._get_value return v.__class__(*seq_args) if is_namedtuple(v.__class__) else v.__class__(seq_args) File "C:\Users\ailitonia\PycharmProjects\nonebot2_miya\venv\lib\site-packages\nonebot\adapters\_base.py", line 330, in __init__ self.extend(self._construct(message)) File "C:\Users\ailitonia\PycharmProjects\nonebot2_miya\venv\lib\site-packages\nonebot\adapters\_base.py", line 400, in extend for segment in obj: File "C:\Users\ailitonia\PycharmProjects\nonebot2_miya\venv\lib\site-packages\nonebot\adapters\cqhttp\message.py", line 265, in _construct yield MessageSegment(seg["type"], seg.get("data") or {}) File "C:\Users\ailitonia\PycharmProjects\nonebot2_miya\venv\lib\site-packages\nonebot\adapters\_base.py", line 278, in __getitem__ return self.data[key] KeyError: 'type'
其他
nonebot2/nonebot/adapters/_base.py
Lines 287 to 288 in 916d620
Lines 277 to 278 in 832875e
cqhttp-adapter 似乎没有根据 MessageSegment 基类更新自己的解析方法
(或者 MessageSegment 基类魔法方法更新也需要考虑 adapter 兼容?)
The text was updated successfully, but these errors were encountered:
已经在3564228 和 8e97a84 中修复, 将会在下个版本发布
Sorry, something went wrong.
No branches or pull requests
描述问题:
使用 event.dict() 方法报错
如何复现?
编写测试插件
期望的结果
正常输出
环境信息:
协议端信息:
截图或日志
其他
nonebot2/nonebot/adapters/_base.py
Lines 287 to 288 in 916d620
nonebot2/nonebot/adapters/_base.py
Lines 277 to 278 in 832875e
cqhttp-adapter 似乎没有根据 MessageSegment 基类更新自己的解析方法
(或者 MessageSegment 基类魔法方法更新也需要考虑 adapter 兼容?)
The text was updated successfully, but these errors were encountered: