Skip to content
New issue

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

Fix: QQ MessageReference cannot be sent #147

Merged
merged 1 commit into from
Jan 27, 2025
Merged

Conversation

ssttkkl
Copy link
Contributor

@ssttkkl ssttkkl commented Jan 23, 2025

Fix #146

@ssttkkl
Copy link
Contributor Author

ssttkkl commented Jan 23, 2025

自测无问题
群聊表现为艾特用户:
image

私聊表现为忽略
image

@yanyongyu yanyongyu added the bug Something isn't working label Jan 23, 2025
@yanyongyu
Copy link
Member

你应该修改

async def post_c2c_messages(
self,
*,
openid: str,
msg_type: Literal[0, 1, 2, 3, 4, 7],
content: Optional[str] = None,
markdown: Optional[MessageMarkdown] = None,
keyboard: Optional[MessageKeyboard] = None,
media: Optional[Media] = None,
ark: Optional[MessageArk] = None,
embed: Optional[MessageEmbed] = None,
image: None = None,
message_reference: None = None,
event_id: Optional[str] = None,
msg_id: Optional[str] = None,
msg_seq: Optional[int] = None,
timestamp: Optional[Union[int, datetime]] = None,
) -> PostC2CMessagesReturn:

由于QQ并没有支持,所以目前仅允许是 None

@ssttkkl
Copy link
Contributor Author

ssttkkl commented Jan 23, 2025

由于QQ并没有支持,所以目前仅允许是 None

那应该怎么改,是不是应该改成在调api的时候就不把message_reference传到请求体比较合理

https://github.com/nonebot/adapter-qq/blob/60e18499f2417b19e9b0cce1a10e151290130e8d/nonebot/adapters/qq/bot.py#L1002C9-L1015C10

post_c2c_messages和post_group_messages是不是也可以和post_messages一样,直接调_parse_send_message来构造请求体

@yanyongyu
Copy link
Member

直接把几个接口的 msg ref 处理部分加个 if 就行。可以参考上面的

"message_reference": message_reference,

@ssttkkl
Copy link
Contributor Author

ssttkkl commented Jan 27, 2025

改了一下,再看看

@yanyongyu yanyongyu changed the title Fix: MessageReference cannot be sent Fix: QQ MessageReference cannot be sent Jan 27, 2025
@yanyongyu yanyongyu merged commit 86385c8 into nonebot:master Jan 27, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

Bug: 无法发送 MessageReference 消息段,JSON 序列化错误
2 participants