simple-robot / simpler-robot

Simple Robot,一个bot风格的Kotlin多平台事件调度框架,异步高效、Java友好!/ A Bot-style Kotlin Multiplatform event scheduling framework, asynchronous and high-performance, java-friendly! 🐱😼😻😸
https://simbot.forte.love
GNU Lesser General Public License v3.0
521 stars 43 forks source link

疑似使用botManager获取bot报错 #723

Closed axiangcoding closed 1 year ago

axiangcoding commented 1 year ago

版本号

3.2.0

附加版本

// https://mvnrepository.com/artifact/love.forte.simbot.component/simbot-component-qq-guild-core implementation("love.forte.simbot.component:simbot-component-qq-guild-core:3.2.0.0-alpha.10-SNAPSHOT")

涉及的编程语言

Java

项目构建工具

Gradle

涉及的组件库

KOOK

问题描述

有一个任务会触发一个事件,主动往某个频道发消息,触发器大概是

for (BotManager<?> botManager : application.getBotManagers()) {
    if (platform == BotPlatform.KOOK && botManager instanceof KookBotManager kookBotManager) {
        func.processByKOOK(kookBotManager.all().get(0).getBot(), params);
    }
    if (platform == BotPlatform.QQ_GUILD && botManager instanceof QQGuildBotManager qqGuildBotManager) {
        func.processByKOOK(qqGuildBotManager.all().get(0).getBot(), params);
    }
}

然后当触发这个事件时,simbot会报错,如下

2023-07-14T22:18:06.960+08:00 ERROR 28812 --- [   scheduling-1] o.s.s.s.TaskUtils$LoggingErrorHandler    : [: ] Unexpected error occurred in scheduled task

love.forte.simbot.qguild.QQGuildApiException: 400: Bad Request; response info: ErrInfo(code=50006, message=empty msg, data=null)
    at love.forte.simbot.qguild.api.QQGuildApiKt.checkStatus(QQGuildApi.kt:461) ~[simbot-component-qq-guild-api-jvm-3.2.0.0-alpha.10-SNAPSHOT.jar:?]
    at love.forte.simbot.qguild.api.message.MessageSendApi.doRequestRaw(MessageSendApi.kt:200) ~[simbot-component-qq-guild-api-jvm-3.2.0.0-alpha.10-SNAPSHOT.jar:?]
    at love.forte.simbot.qguild.api.message.MessageSendApi$doRequestRaw$1.invokeSuspend(MessageSendApi.kt) ~[simbot-component-qq-guild-api-jvm-3.2.0.0-alpha.10-SNAPSHOT.jar:?]
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ~[kotlin-stdlib-1.8.22.jar:1.8.22-release-407(1.8.22)]
    at io.ktor.utils.io.internal.CancellableReusableContinuation.resumeWith(CancellableReusableContinuation.kt:93) ~[ktor-io-jvm-2.3.0.jar:2.3.0]
    at io.ktor.utils.io.ByteBufferChannel.resumeReadOp(ByteBufferChannel.kt:2098) ~[ktor-io-jvm-2.3.0.jar:2.3.0]
    at io.ktor.utils.io.ByteBufferChannel.tryTerminate$ktor_io(ByteBufferChannel.kt:388) ~[ktor-io-jvm-2.3.0.jar:2.3.0]
    at io.ktor.utils.io.ByteBufferChannel.close(ByteBufferChannel.kt:133) ~[ktor-io-jvm-2.3.0.jar:2.3.0]
    at io.ktor.utils.io.CoroutinesKt$launchChannel$1.invoke(Coroutines.kt:145) ~[ktor-io-jvm-2.3.0.jar:2.3.0]
    at io.ktor.utils.io.CoroutinesKt$launchChannel$1.invoke(Coroutines.kt:144) ~[ktor-io-jvm-2.3.0.jar:2.3.0]
    at kotlinx.coroutines.InvokeOnCompletion.invoke(JobSupport.kt:1392) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
    at kotlinx.coroutines.JobSupport.notifyCompletion(JobSupport.kt:1520) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
    at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:323) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
    at kotlinx.coroutines.JobSupport.finalizeFinishingState(JobSupport.kt:240) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
    at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(JobSupport.kt:906) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
    at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:863) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
    at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(JobSupport.kt:828) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
    at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:100) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) ~[kotlin-stdlib-1.8.22.jar:1.8.22-release-407(1.8.22)]
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
    at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
    Suppressed: love.forte.simbot.qguild.APIStackException: channel.send
        at love.forte.simbot.component.qguild.internal.QGTextChannelImpl.send(QGTextChannelImpl.kt:162) ~[simbot-component-qq-guild-core-3.2.0.0-alpha.10-SNAPSHOT.jar:?]
        at love.forte.simbot.component.qguild.internal.QGTextChannelImpl$send$1.invokeSuspend(QGTextChannelImpl.kt) ~[simbot-component-qq-guild-core-3.2.0.0-alpha.10-SNAPSHOT.jar:?]
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ~[kotlin-stdlib-1.8.22.jar:1.8.22-release-407(1.8.22)]
        at io.ktor.utils.io.internal.CancellableReusableContinuation.resumeWith(CancellableReusableContinuation.kt:93) ~[ktor-io-jvm-2.3.0.jar:2.3.0]
        at io.ktor.utils.io.ByteBufferChannel.resumeReadOp(ByteBufferChannel.kt:2098) ~[ktor-io-jvm-2.3.0.jar:2.3.0]
        at io.ktor.utils.io.ByteBufferChannel.tryTerminate$ktor_io(ByteBufferChannel.kt:388) ~[ktor-io-jvm-2.3.0.jar:2.3.0]
        at io.ktor.utils.io.ByteBufferChannel.close(ByteBufferChannel.kt:133) ~[ktor-io-jvm-2.3.0.jar:2.3.0]
        at io.ktor.utils.io.CoroutinesKt$launchChannel$1.invoke(Coroutines.kt:145) ~[ktor-io-jvm-2.3.0.jar:2.3.0]
        at io.ktor.utils.io.CoroutinesKt$launchChannel$1.invoke(Coroutines.kt:144) ~[ktor-io-jvm-2.3.0.jar:2.3.0]
        at kotlinx.coroutines.InvokeOnCompletion.invoke(JobSupport.kt:1392) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
        at kotlinx.coroutines.JobSupport.notifyCompletion(JobSupport.kt:1520) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
        at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:323) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
        at kotlinx.coroutines.JobSupport.finalizeFinishingState(JobSupport.kt:240) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
        at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(JobSupport.kt:906) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
        at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:863) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
        at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(JobSupport.kt:828) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
        at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:100) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) ~[kotlin-stdlib-1.8.22.jar:1.8.22-release-407(1.8.22)]
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
        at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
        at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) ~[kotlinx-coroutines-core-jvm-1.6.4.jar:?]

诡异的是,触发事件后,根本没有处理逻辑,不清楚这个报错哪里来的

复现方式

相关日志

No response

其他补充

No response

ForteScarlet commented 1 year ago

首先是触发器中对 QQ_GUILD 中的判断,判断后依旧使用了 processByKOOK

if (platform == BotPlatform.QQ_GUILD && botManager instanceof QQGuildBotManager qqGuildBotManager) {
        func.processByKOOK(qqGuildBotManager.all().get(0).getBot(), params);
    }

从字面看来似乎在用 KOOK 的处理器处理QQ频道的Bot,可以确认下这里是否会引发问题。

其次可以开启 love.forte.simbot.qguild.apiDEBUG 日志来确认发送消息的出入参等信息,配合其他日志来确认问题所在。

个人猜测:某处向QQ频道的Channel发送了KOOK的消息对象,导致消息元素没有解析而出现 message=empty msg

axiangcoding commented 1 year ago

首先是触发器中对 QQ_GUILD 中的判断,判断后依旧使用了 processByKOOK

if (platform == BotPlatform.QQ_GUILD && botManager instanceof QQGuildBotManager qqGuildBotManager) {
        func.processByKOOK(qqGuildBotManager.all().get(0).getBot(), params);
    }

从字面看来似乎在用 KOOK 的处理器处理QQ频道的Bot,可以确认下这里是否会引发问题。

其次可以开启 love.forte.simbot.qguild.apiDEBUG 日志来确认发送消息的出入参等信息,配合其他日志来确认问题所在。

个人猜测:某处向QQ频道的Channel发送了KOOK的消息对象,导致消息元素没有解析而出现 message=empty msg

天呐,我猪b了,调用错函数了....