koishijs / koishi-plugin-adapter-onebot

OneBot 适配器
MIT License
26 stars 10 forks source link

使用session.onebot.downloadFile时提示TypeError: Cannot read properties of undefined (reading 'downloadFile') #42

Closed Cola-Ace closed 1 month ago

Cola-Ace commented 2 months ago

如题,qq方面是支持这个api的,但是koishi内调用时提示如上,adapter-onebot为最新版

Cola-Ace commented 2 months ago

另外,在调用session.bot.getForwardMsg的时候总是timeout,而通过api调试工具直接向qq发送请求则正常

shigma commented 2 months ago

onebot 没有这个 API。你是不是把 onebot 跟其他协议搞混了?

Cola-Ace commented 2 months ago

go-cqhttp支持这个,而且我看代码中也有相关的函数 PixPin_2024-07-31_02-30-39

Cola-Ace commented 2 months ago

另外,在调用session.bot.getForwardMsg的时候总是timeout,而通过api调试工具直接向qq发送请求则正常

顺便能请您看看这个问题发生的原因吗

shigma commented 2 months ago

另外,在调用session.bot.getForwardMsg的时候总是timeout,而通过api调试工具直接向qq发送请求则正常

应该是 session.onebot.getForwardMsg 对吧?

可能需要看看请求参数。

shigma commented 2 months ago

TypeError: Cannot read properties of undefined (reading 'downloadFile')

这个说明 session.onebot 可能就不存在。你是在什么情况下调用的?能看看代码吗?

Cola-Ace commented 2 months ago

TypeError: Cannot read properties of undefined (reading 'downloadFile')

这个说明 session.onebot 可能就不存在。你是在什么情况下调用的?能看看代码吗?

我用qqbot.internal.downloadFile就好了,应该是我在discord发送消息时session.onebot不存在的问题

Cola-Ace commented 2 months ago

另外,在调用session.bot.getForwardMsg的时候总是timeout,而通过api调试工具直接向qq发送请求则正常

应该是 session.onebot.getForwardMsg 对吧?

可能需要看看请求参数。

{ messageId: '-2147483038', id: '-2147483038', elements: [{ type: 'forward', attrs: { id: '7397666445403751866' }, children: []}], content: '<forward id="7397666445403751866"/>' } 我传入的参数是elements[0].attrs.id,且具体代码中我会确保该element的type为forward,所以传入的参数应该是没问题的 PixPin_2024-07-31_13-32-34 另外,我发现我传入的forward_id和报错消息中的message_id不一致([I]的是初始的forward_id)

shigma commented 2 months ago

那这个 issue 本身的问题应该算解决了。

后面提的这个问题我怎么感觉是返回了超出整型限制的大数?能看看你的代码吗?

shigma commented 2 months ago

可能相关:https://github.com/koishijs/koishi-plugin-adapter-onebot/issues/9

Cola-Ace commented 2 months ago

相关测试代码如下: PixPin_2024-08-08_16-43-06 在当前情景下,我确保session.onebot是可用的,且我传入该函数的参数的类型确定为string而不是整型

shigma commented 1 month ago

已修复。