MrXiaoM / Overflow

替换 mirai 实现为 Onebot 以进行无缝迁移
https://mirai.mrxiaom.top
GNU Affero General Public License v3.0
337 stars 25 forks source link

无法获取 `GroupActive` #68

Open HatoYuze opened 4 months ago

HatoYuze commented 4 months ago

问题描述

操作

mirai-core 中获取 GroupActive

在运行代码时,发现该操作会出现意料之外的返回,抛出错误 java.net.ProtocolException: Invalid HTTP method: get

个人认为这是因为 BotUtils.kt#84 所导致的问题

更换s01.oss.sonatype.org最新版后仍存在该问题 遂提出该issue

复现

object Example : SimpleListenerHost() {
    val logger = MiraiLogger.Factory.create(Example::class)
    override fun handleException(context: CoroutineContext, exception: Throwable) {
        logger.error(exception)
    }

    @EventHandler
    suspend fun GroupMemberEvent.listener() {
        println(group.active.queryActiveRank())
    }
}

监听到群聊信息事件时会抛出错误

Overflow 版本

2.16.0-febc5da-20240401.041614-1

其他组件版本

mirai-core & mirai-console: 2.16.0

Jdk: bcprov-jdk15on-1.64

Onebot: Lagrange.Onebot_win-x64_8.0

系统日志

*first

2024-07-07 04:05:16 W/Onebot: 请求失败: [get_credentials] 请求失败: app=Lagrange.OneBot v0.0.3, message=, retJson={"status":"failed","retcode":200,"data":null,"echo":5}。如果你认为这是 Overflow 的问题,请带上 logs/onebot 中的日志来反馈。
2024-07-07 04:05:16 W/Bot.3*******2: java.lang.IllegalStateException: credentials is empty
java.lang.IllegalStateException: credentials is empty
        at top.mrxiaom.overflow.internal.utils.BotUtilsKt.httpGet(BotUtils.kt:72)
        at top.mrxiaom.overflow.internal.utils.BotUtilsKt$httpGet$1.invokeSuspend(BotUtils.kt)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:33)
        at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
        at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
        at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
        at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
        at top.mrxiaom.overflow.internal.contact.GroupWrapper$active$2.invoke(GroupWrapper.kt:96)
        at top.mrxiaom.overflow.internal.contact.GroupWrapper$active$2.invoke(GroupWrapper.kt:95)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at top.mrxiaom.overflow.internal.contact.GroupWrapper.getActive(GroupWrapper.kt:95)
        at top.mrxiaom.overflow.internal.contact.GroupWrapper.getActive(GroupWrapper.kt:40
java.net.ProtocolException: Invalid HTTP method: get
        at java.base/java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:491)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.setRequestMethod(HttpURLConnection.java:598)
        at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestMethod(HttpsURLConnectionImpl.java:343)
        at top.mrxiaom.overflow.internal.utils.BotUtilsKt$httpGet$2.invokeSuspend(BotUtils.kt:84)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
        at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

修改 BotUtils.kt#84GET

java.io.FileNotFoundException: https://qun.qq.com/cgi-bin/honorv2/honor_title_list?group_code=5*******7&request_type=2&g_tk=1********0
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:2010)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1615)
        at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:223)
        at top.mrxiaom.overflow.internal.utils.BotUtilsKt$httpGet$2.invokeSuspend(BotUtils.kt:90)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
        at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

网络日志

2024-07-07 02:10:48 D/Onebot: Send to server --> {"action":"get_credentials","params":{"domain":"qun.qq.com"},"echo":20}
2024-07-07 02:10:48 D/Onebot: Client received <-- {"status":"ok","retcode":0,"data":{"cookies":"x******************************************I_","csrf_token":1********0},"echo":20}

补充信息

HatoYuze commented 4 months ago

自己改了一下.. 发现除了get以外还有别的问题

java.io.FileNotFoundException: https://qun.qq.com/cgi-bin/honorv2/honor_title_list?group_code=5*******7&request_type=2&g_tk=1********0
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:2010)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1615)
        at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:223)
        at top.mrxiaom.overflow.internal.utils.BotUtilsKt$httpGet$2.invokeSuspend(BotUtils.kt:90)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
        at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

GroupActive的实现好像有些问题,暂且改名等待后期修复了

HatoYuze commented 4 months ago

访问脱敏前的https://qun.qq.com/cgi-bin/honorv2/honor_title_list?group_code=5*******7&request_type=2&g_tk=1********0 得到404错误结果 我怀疑是不是腾讯换接口了