realhuhu / py-plugin

miao py-plugin
GNU General Public License v3.0
48 stars 3 forks source link

`MessageSegment.reply`消息无效 #41

Open ProblemFactory opened 1 year ago

ProblemFactory commented 1 year ago
from nonebot import Bot
from nonebot.params import CommandArg, EventMessage
from nonebot.matcher import Matcher
from nonebot.adapters.onebot.v11 import (
    Message,
    MessageSegment,
    MessageEvent,
    GroupMessageEvent,
    PrivateMessageEvent,
)

async def test(
    bot: Bot,
    event: MessageEvent,
    matcher: Matcher,
    arg: Message = CommandArg(),
    user_data: Optional[UserData] = None,
):
    await matcher.finish(MessageSegment.reply(event.message_id) + MessageSegment.at(event.sender.user_id) + MessageSegment.text('test'))

这样产生的消息没有引用效果,只有at和'test‘文本。

ProblemFactory commented 1 year ago

懂了,这个和我前面提的message_id类型的issue #40 本质上是一个问题,这里把message_id编码转成str就好了。

ProblemFactory commented 1 year ago

现在message_id都是int了,那这个咋办?

realhuhu commented 1 year ago

没事,发给云崽的时候会统一转回oicq的str

ProblemFactory commented 1 year ago

那之前为啥有问题的?

realhuhu commented 1 year ago

有的api调用途径不一样,遗漏了类型转换

ProblemFactory commented 1 year ago

我试了下 刚pull的新版本,MessageSegment.reply不行,后台log有

ApiRejection {

  code: -60,
  message: 'The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received 6.5_869_781_750_548_59e_+49'
}