simple-robot / simbot-component-kook

一个 Kotlin 多平台的 KOOK(开黑啦) Bot SDK 实现库,一个 Simple Robot 组件库,Java 友好、异步高效~ ❤️‍🔥❤️‍🔥😘
https://simbot.forte.love/component-kook.html
GNU Lesser General Public License v3.0
19 stars 1 forks source link

发送含图片的消息时报错 #164

Closed NoMathExpectation closed 2 months ago

NoMathExpectation commented 2 months ago

是否会提供贡献?

版本信息

// simbot
    val simbotVersion = "4.4.0"
    implementation("love.forte.simbot:simbot-core:$simbotVersion")
    compileOnly("love.forte.simbot.common:simbot-common-annotations:$simbotVersion")
    implementation("love.forte.simbot.component:simbot-component-onebot-v11-core:1.1.0")
    implementation("love.forte.simbot.component:simbot-component-kook-core:4.0.0-beta4")

涉及的编程语言

Kotlin

项目构建工具

Gradle

内容描述

上传图片时使用uri解析为离线图片,发送时报错:

io.ktor.http.BadContentTypeFormatException: Bad Content-Type format: form-data
        at io.ktor.http.ContentType$Companion.parse(ContentTypes.kt:123) ~[ktor-http-jvm-2.3.12.jar:2.3.12]
        at io.ktor.http.HttpMessagePropertiesKt.contentType(HttpMessageProperties.kt:49) ~[ktor-http-jvm-2.3.12.jar:2.3.12]
        at io.ktor.client.plugins.DefaultTransformKt$defaultTransformers$1.invokeSuspend(DefaultTransform.kt:33) ~[ktor-client-core-jvm-2.3.12.jar:2.3.12]
        at io.ktor.client.plugins.DefaultTransformKt$defaultTransformers$1.invoke(DefaultTransform.kt) ~[ktor-client-core-jvm-2.3.12.jar:2.3.12]
        at io.ktor.client.plugins.DefaultTransformKt$defaultTransformers$1.invoke(DefaultTransform.kt) ~[ktor-client-core-jvm-2.3.12.jar:2.3.12]
        at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:131) ~[ktor-utils-jvm-2.3.12.jar:2.3.12]
        at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:89) ~[ktor-utils-jvm-2.3.12.jar:2.3.12]
        at io.ktor.util.pipeline.SuspendFunctionGun.proceedWith(SuspendFunctionGun.kt:99) ~[ktor-utils-jvm-2.3.12.jar:2.3.12]
        at io.ktor.client.plugins.HttpCallValidator$Companion$install$1.invokeSuspend(HttpCallValidator.kt:130) ~[ktor-client-core-jvm-2.3.12.jar:2.3.12]
        at io.ktor.client.plugins.HttpCallValidator$Companion$install$1.invoke(HttpCallValidator.kt) ~[ktor-client-core-jvm-2.3.12.jar:2.3.12]
        at io.ktor.client.plugins.HttpCallValidator$Companion$install$1.invoke(HttpCallValidator.kt) ~[ktor-client-core-jvm-2.3.12.jar:2.3.12]
        at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:131) ~[ktor-utils-jvm-2.3.12.jar:2.3.12]
        at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:89) ~[ktor-utils-jvm-2.3.12.jar:2.3.12]
        at io.ktor.client.plugins.HttpRequestLifecycle$Plugin$install$1.invokeSuspend(HttpRequestLifecycle.kt:38) ~[ktor-client-core-jvm-2.3.12.jar:2.3.12]
        at io.ktor.client.plugins.HttpRequestLifecycle$Plugin$install$1.invoke(HttpRequestLifecycle.kt) ~[ktor-client-core-jvm-2.3.12.jar:2.3.12]
        at io.ktor.client.plugins.HttpRequestLifecycle$Plugin$install$1.invoke(HttpRequestLifecycle.kt) ~[ktor-client-core-jvm-2.3.12.jar:2.3.12]
        at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:131) ~[ktor-utils-jvm-2.3.12.jar:2.3.12]
        at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:89) ~[ktor-utils-jvm-2.3.12.jar:2.3.12]
        at io.ktor.util.pipeline.SuspendFunctionGun.execute$ktor_utils(SuspendFunctionGun.kt:109) ~[ktor-utils-jvm-2.3.12.jar:2.3.12]
        at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:77) ~[ktor-utils-jvm-2.3.12.jar:2.3.12]
        at io.ktor.client.HttpClient.execute$ktor_client_core(HttpClient.kt:191) ~[ktor-client-core-jvm-2.3.12.jar:2.3.12]
        at io.ktor.client.statement.HttpStatement.executeUnsafe(HttpStatement.kt:108) ~[ktor-client-core-jvm-2.3.12.jar:2.3.12]
        at io.ktor.client.statement.HttpStatement.execute(HttpStatement.kt:47) ~[ktor-client-core-jvm-2.3.12.jar:2.3.12]
        at io.ktor.client.statement.HttpStatement.execute(HttpStatement.kt:62) ~[ktor-client-core-jvm-2.3.12.jar:2.3.12]
        at love.forte.simbot.kook.api.ApiRequests__ApiRequestsKt.request(ApiRequests.kt:255) ~[simbot-component-kook-api-jvm-4.0.0-beta4.jar:?]
        at love.forte.simbot.kook.api.ApiRequests.request(Unknown Source) ~[simbot-component-kook-api-jvm-4.0.0-beta4.jar:?]
        at love.forte.simbot.kook.api.ApiRequests__ApiRequestsKt.requestResult(ApiRequests.kt:94) ~[simbot-component-kook-api-jvm-4.0.0-beta4.jar:?]
        at love.forte.simbot.kook.api.ApiRequests.requestResult(Unknown Source) ~[simbot-component-kook-api-jvm-4.0.0-beta4.jar:?]
        at love.forte.simbot.kook.api.ApiRequests__ApiRequestsKt.requestData(ApiRequests.kt:124) ~[simbot-component-kook-api-jvm-4.0.0-beta4.jar:?]
        at love.forte.simbot.kook.api.ApiRequests.requestData(Unknown Source) ~[simbot-component-kook-api-jvm-4.0.0-beta4.jar:?]
        at love.forte.simbot.kook.stdlib.BotRequests__BotRequestsKt.requestDataBy(BotRequests.kt:63) ~[simbot-component-kook-stdlib-jvm-4.0.0-beta4.jar:?]
        at love.forte.simbot.kook.stdlib.BotRequests.requestDataBy(BotRequests.kt:1) ~[simbot-component-kook-stdlib-jvm-4.0.0-beta4.jar:?]
        at love.forte.simbot.component.kook.util.KookBotRequests.requestData(BotRequests.kt:51) ~[simbot-component-kook-core-jvm-4.0.0-beta4.jar:?]
        at love.forte.simbot.component.kook.util.KookBotRequests.requestDataBy(BotRequests.kt:89) ~[simbot-component-kook-core-jvm-4.0.0-beta4.jar:?]
        at love.forte.simbot.component.kook.message.KookMessagesTransformerKt.send0$lambda$8$process(KookMessagesTransformer.kt:549) ~[simbot-component-kook-core-jvm-4.0.0-beta4.jar:?]
        at love.forte.simbot.component.kook.message.KookMessagesTransformerKt.send0(KookMessagesTransformer.kt:228) ~[simbot-component-kook-core-jvm-4.0.0-beta4.jar:?]
        at love.forte.simbot.component.kook.message.KookMessagesTransformerKt.sendToChannel(KookMessagesTransformer.kt:90) ~[simbot-component-kook-core-jvm-4.0.0-beta4.jar:?]
        at love.forte.simbot.component.kook.message.KookMessagesTransformerKt.sendToChannel$default(KookMessagesTransformer.kt:83) ~[simbot-component-kook-core-jvm-4.0.0-beta4.jar:?]
        at love.forte.simbot.component.kook.internal.KookChatChannelImpl.send$simbot_component_kook_core(KookChatChannelImpl.kt:76) ~[simbot-component-kook-core-jvm-4.0.0-beta4.jar:?]
        at love.forte.simbot.component.kook.internal.KookChatChannelImpl.send(KookChatChannelImpl.kt:64) ~[simbot-component-kook-core-jvm-4.0.0-beta4.jar:?]
        at love.forte.simbot.component.kook.KookChatChannel.send$default(KookChatChannel.kt:106) ~[simbot-component-kook-core-jvm-4.0.0-beta4.jar:?]
        at love.forte.simbot.component.kook.KookChatChannel.send$suspendImpl(KookChatChannel.kt:139) ~[simbot-component-kook-core-jvm-4.0.0-beta4.jar:?]
        at love.forte.simbot.component.kook.KookChatChannel.send(KookChatChannel.kt) ~[simbot-component-kook-core-jvm-4.0.0-beta4.jar:?]
        at NoMathExpectation.NMEBoot.command.source.KookChannelCommandSource$Event.sendRaw(KookCommandSource.kt:59) ~[NMEBoot2-2.0.jar:?]
        at NoMathExpectation.NMEBoot.command.source.CommandSource$DefaultImpls.send(CommandSource.kt:36) ~[NMEBoot2-2.0.jar:?]
        at NoMathExpectation.NMEBoot.command.source.KookCommandSource$DefaultImpls.send(KookCommandSource.kt:14) ~[NMEBoot2-2.0.jar:?]
        at NoMathExpectation.NMEBoot.command.source.KookChannelCommandSource$DefaultImpls.send(KookCommandSource.kt:25) ~[NMEBoot2-2.0.jar:?]
        at NoMathExpectation.NMEBoot.command.source.KookChannelCommandSource$Event.send(KookCommandSource.kt:34) ~[NMEBoot2-2.0.jar:?]
        at NoMathExpectation.NMEBoot.command.impl.command.ChartKt$commandChart$2$1$4.invokeSuspend(Chart.kt:66) ~[NMEBoot2-2.0.jar:?]
        at NoMathExpectation.NMEBoot.command.impl.command.ChartKt$commandChart$2$1$4.invoke(Chart.kt) ~[NMEBoot2-2.0.jar:?]
        at NoMathExpectation.NMEBoot.command.impl.command.ChartKt$commandChart$2$1$4.invoke(Chart.kt) ~[NMEBoot2-2.0.jar:?]
        at NoMathExpectation.NMEBoot.command.parser.node.ExecuteCommandNode.execute(ExecuteCommandNode.kt:13) ~[NMEBoot2-2.0.jar:?]
        at NoMathExpectation.NMEBoot.command.parser.node.ArgumentCollectCommandNode.execute(ArgumentCollectCommandNode.kt:25) ~[NMEBoot2-2.0.jar:?]
        at NoMathExpectation.NMEBoot.command.parser.node.ForwardCommandNode.execute(ForwardCommandNode.kt:10) ~[NMEBoot2-2.0.jar:?]
        at NoMathExpectation.NMEBoot.command.parser.node.LiteralSelectionCommandNode.execute(LiteralSelectionCommandNode.kt:22) ~[NMEBoot2-2.0.jar:?]
        at NoMathExpectation.NMEBoot.command.parser.node.SelectionCommandNode.execute(SelectionCommandNode.kt:13) ~[NMEBoot2-2.0.jar:?]
        at NoMathExpectation.NMEBoot.command.parser.node.ConditionCommandNode.execute(ConditionCommandNode.kt:17) ~[NMEBoot2-2.0.jar:?]
        at NoMathExpectation.NMEBoot.command.parser.node.ConditionCommandNode$execute$1.invokeSuspend(ConditionCommandNode.kt) ~[NMEBoot2-2.0.jar:?]
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) [kotlin-stdlib-2.0.0.jar:2.0.0-release-341]
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104) [kotlinx-coroutines-core-jvm-1.8.1.jar:?]
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584) [kotlinx-coroutines-core-jvm-1.8.1.jar:?]
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:811) [kotlinx-coroutines-core-jvm-1.8.1.jar:?]
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:715) [kotlinx-coroutines-core-jvm-1.8.1.jar:?]
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:702) [kotlinx-coroutines-core-jvm-1.8.1.jar:?]

构建的方法如下:

buildMessages {
        +URI(level.image).toOfflineImage()

        +"剩下的几段含换行的文字"
}