Nambers / MiraiCP

c++ SDK of Mirai
https://eritque-arcus.tech/MiraiCP/
GNU Affero General Public License v3.0
176 stars 31 forks source link

MiraiCP::Image::refreshInfo出错 #151

Closed justghostof closed 1 year ago

justghostof commented 1 year ago

Code of Conduct

问题描述

MiraiCP::Image::refreshInfo出错 相关代码:

[](MiraiCP::GroupMessageEvent e)
                              {
            e.group.sendMessage(MiraiCP::At(e.sender.id()),"请在30秒内上传你的图片");
            try{
            auto next=e.senderNextMessage(30000);
            if(next.size()==1&& next[0].type()==3){
                auto img=next[0].getVal<MiraiCP::Image>();
                if(!img.url){
                    img.refreshInfo();  
                }
                if(img.url){
                    std::cout<<img.url.value()<<std::endl;
                }
                else{
                    e.group.sendMessage(MiraiCP::At(e.sender.id()),"图片下载失败");    
                }
            }
            else{
                e.group.sendMessage(MiraiCP::At(e.sender.id()),"请确保发送内容中有且仅有图片");
            }
            }
            catch(MiraiCP::TimeOutException){
                e.group.sendMessage(MiraiCP::At(e.sender.id()),"超时啦");
            }; }

refreshInfo中KtOperation::ktOperation调用时json如下,具体Image已隐去

"{"data":{"height":0,"imageid":"{}.jpg","key":"image","size":0,"type":5,"width":0},"type":8}"

日志

2022-11-26 22:35:56 I/stdout: Expected start of the object '{', but had 'EOF' instead at path: $
2022-11-26 22:35:56 I/stdout: JSON input: ..... imageid={}.jpg, type=5)
2022-11-26 22:35:56 I/stdout: {"data":{"height":0,"imageid":"{}.jpg","key":"image","size":0,"type":5,"width":0},"type":8}
2022-11-26 22:35:56 W/stderr: kotlinx.serialization.json.internal.JsonDecodingException: Expected start of the object '{', but had 'EOF' instead at path: $
2022-11-26 22:35:56 W/stderr: JSON input: ..... imageid={}.jpg, type=5)
2022-11-26 22:35:56 W/stderr:   at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:24)
2022-11-26 22:35:56 W/stderr:   at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:32)
2022-11-26 22:35:56 W/stderr:   at kotlinx.serialization.json.internal.AbstractJsonLexer.fail(AbstractJsonLexer.kt:528)
2022-11-26 22:35:56 W/stderr:   at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$default(AbstractJsonLexer.kt:526)
2022-11-26 22:35:56 W/stderr:   at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$kotlinx_serialization_json(AbstractJsonLexer.kt:224)
2022-11-26 22:35:56 W/stderr:   at kotlinx.serialization.json.internal.AbstractJsonLexer.unexpectedToken(AbstractJsonLexer.kt:207)
2022-11-26 22:35:56 W/stderr:   at kotlinx.serialization.json.internal.StringJsonLexer.consumeNextToken(StringJsonLexer.kt:74)
2022-11-26 22:35:56 W/stderr:   at kotlinx.serialization.json.internal.StreamingJsonDecoder.beginStructure(StreamingJsonDecoder.kt:47)
2022-11-26 22:35:56 W/stderr:   at MiraiCP-plugin-2.13.0-alpha.mirai2.jar//tech.eritquearcus.miraicp.shared.Config$ImgInfo$$serializer.deserialize(Config.kt:150)
2022-11-26 22:35:56 W/stderr:   at MiraiCP-plugin-2.13.0-alpha.mirai2.jar//tech.eritquearcus.miraicp.shared.Config$ImgInfo$$serializer.deserialize(Config.kt:150)
2022-11-26 22:35:56 W/stderr:   at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:59)
2022-11-26 22:35:56 W/stderr:   at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:38)
2022-11-26 22:35:56 W/stderr:   at kotlinx.serialization.json.Json.decodeFromString(Json.kt:100)
2022-11-26 22:35:56 W/stderr:   at MiraiCP-plugin-2.13.0-alpha.mirai2.jar//tech.eritquearcus.miraicp.shared.CPPLib.kQueryImgInfo(CPPLib.kt:306)
2022-11-26 22:35:56 W/stderr:   at MiraiCP-plugin-2.13.0-alpha.mirai2.jar//tech.eritquearcus.miraicp.shared.CPPLib$operation$1.invokeSuspend(CPPLib.kt:183)
2022-11-26 22:35:56 W/stderr:   at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
2022-11-26 22:35:56 W/stderr:   at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
2022-11-26 22:35:56 W/stderr:   at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
2022-11-26 22:35:56 W/stderr:   at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
2022-11-26 22:35:56 W/stderr:   at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
2022-11-26 22:35:56 W/stderr:   at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
2022-11-26 22:35:56 W/stderr:   at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
2022-11-26 22:35:56 W/stderr:   at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
2022-11-26 22:35:56 W/stderr:   at MiraiCP-plugin-2.13.0-alpha.mirai2.jar//tech.eritquearcus.miraicp.shared.CPPLib.operation(CPPLib.kt:151)
2022-11-26 22:35:56 W/stderr:   at MiraiCP-plugin-2.13.0-alpha.mirai2.jar//tech.eritquearcus.miraicp.shared.CPPLibMultiplatform.KOperation(CPPLibMultiplatform.kt:45)

版本

测试过v2.13.0-alpha-3和v2.13.0-alpha

组件

Loader(java)

编译器

Microsoft Visual C++ (MSVC)

系统

Windows

架构

x86-64/amd64