fix: 修复多 NapCat 实例连接时 ctx.bot 指向错误的问题#8
Closed
Jerryplusy wants to merge 1 commit intodevfrom
Hidden character warning
The head ref may contain hidden characters: "fix-\u4fee\u590d\u8fde\u63a5\u591a\u4e2aNapCat\u793a\u4f8b\u65f6\u53d1\u9001\u4fe1\u606f\u95ee\u9898"
Closed
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Owner
|
如果是需要传入 bot 的操作方法,比如 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
当连接多个 NapCat 实例时,插件中通过
ctx.bot调用发送消息等接口时,会错误地使用第一个连接的 bot 实例,而不是收到消息的那个 bot复现
package.json中的napcat数组,连接两个NapCat实例ctx.bot.sendGroupMsg()或其他接口操作报错:
[17:07:24] ERROR [mioki] unhandledRejection, 出错了: Error: API 错误: EventChecker Failed: NTEvent serviceAndMethod:NodeIKernelMsgService/sendMsg ListenerName:NodeIKernelMsgListener/onMsgInfoListUpdate EventRet: { "result": 110, "errMsg": "发送失败,你已被移出该群,请重新加群。" }修复
currentBotHolder记录当前处理事件的 botctx.bot和ctx.self_id改为getter,动态返回正确的 bot