ieew / nonebot_adapter_mirai2

nonebot2 的三方 adapter,用以为 nonebot2 提供 MiraiApiHttp2 协议支持
https://ieew.github.io/nonebot_adapter_mirai2/
GNU Affero General Public License v3.0
20 stars 6 forks source link

quote消息类型的一点疑问 #22

Closed RainChain-Zero closed 2 years ago

RainChain-Zero commented 2 years ago

尝试使用以下代码构造回复消息时提示错误信息

await test.finish(MessageSegment.quote(event.source.id,0,这里是sender_id,bot.self_id,MessageChain("test")))

Error

nonebot.exception.ActionFailed: mirai V2 | {'code': 500, 'msg': 'message is empty'}

附完整log 图片 图片

adapter V0.0.10 mah V2.4

请问是我的使用方法存在问题吗,十分感谢!

ieew commented 2 years ago

每条消息都有专门的消息 id ,如果想要回复消息,你需要将消息 id 传入参数 quote 。就像这样:

@message.handle()
async def _(bot: Bot, event: GroupMessage):
    await message.send(消息内容, quote=消息id)

Q:为什么要这样设计? A:因为 mirai_api_http 就是这样设计的

RainChain-Zero commented 2 years ago

每条消息都有专门的消息 id ,如果想要回复消息,你需要将消息 id 传入参数 quote 。就像这样:

@message.handle()
async def _(bot: Bot, event: GroupMessage):
    await message.send(消息内容, quote=消息id)

Q:为什么要这样设计? A:因为 mirai_api_http 就是这样设计的

已经成功,感谢解答!