simple-robot / simbot-component-mirai

simple-robot下的mirai组件
https://component-mirai.simbot.forte.love/
GNU Affero General Public License v3.0
20 stars 0 forks source link

PostMessageEvent相关事件构建失败 #18

Closed yjrguxing closed 2 years ago

yjrguxing commented 2 years ago

关键代码如下

@Scheduled(cron = "*/5 * * * * ?")
    public void taskGoodExpRemind(){
        // todo 还是需要引入实体类的 记得改实体类
        List<String> allGoodExpTime = service.getAllGoodExpTime();
        //物品的最早到期时间时间戳
        Long time;
        for(String item: allGoodExpTime){
            // 一旦物品到期时间是一个范围时间,则在最早到期时间小于特定时间时进行提醒
            if(item.contains("/")){
                  time = TimeUtil.Singleton.timeToTimeStamp(item.split("/")[0], "yyyy-MM-dd");
            }else{
                time = TimeUtil.Singleton.timeToTimeStamp(item,"yyyy-MM-dd");
            }
            if(time < System.currentTimeMillis() + ((long) Const.JX3ItemConst.REMINDTIME.getCode() * 24 * 3600 * 1000)){
                MiraiBot miraiBot = Const.MiraiBotManage.INSTANCE.getMiraiBotManage().get(Identifies.ID("3504929659"));
                //报错代码为以下两行
                miraiBot.getFriend(Identifies.ID("1241280257")).sendBlocking("物品到期定时任务启动, 方天水镜 最早将于" + TimeUtil.Singleton.timeStampToDay(time) + "天后到期");
                miraiBot.getFriend(Identifies.ID("1241280257")).sendBlocking("下次启动定时任务在5s后");
            }
        }
    }

报错信息如下

2022-04-26 20:22:55.245 ERROR 17960 --- [atcher-worker-1] love.forte.simbot.mirai.bot.3504929659   : Exception in coroutine 'Bot.3504929659'.

java.util.NoSuchElementException: net.mamoe.mirai.message.data.MessageSource$Key@601d4d7f
    at love.forte.simbot.component.mirai.event.MiraiReceivedMessageContentKt.toSimbotMessageContent(MiraiReceivedMessageContent.kt:118) ~[simbot-component-mirai-core-3.0.0.0.preview.2.0.jar:na]
    at love.forte.simbot.component.mirai.event.impl.MiraiFriendMessagePostSendEventImpl.<init>(MiraiFriendMessagePostSendEventImpl.kt:42) ~[simbot-component-mirai-core-3.0.0.0.preview.2.0.jar:na]
    at love.forte.simbot.component.mirai.internal.MiraiBotImplKt$registerEvents$1$invokeSuspend$$inlined$doHandler$34.invokeSuspend(MiraiBotImpl.kt:497) ~[simbot-component-mirai-core-3.0.0.0.preview.2.0.jar:na]
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ~[kotlin-stdlib-1.6.10.jar:1.6.10-release-923(1.6.10)]
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) ~[kotlinx-coroutines-core-jvm-1.5.2.jar:na]
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571) ~[kotlinx-coroutines-core-jvm-1.5.2.jar:na]
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) ~[kotlinx-coroutines-core-jvm-1.5.2.jar:na]
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678) ~[kotlinx-coroutines-core-jvm-1.5.2.jar:na]
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665) ~[kotlinx-coroutines-core-jvm-1.5.2.jar:na]

2022-04-26 20:22:55.417 ERROR 17960 --- [atcher-worker-1] love.forte.simbot.mirai.bot.3504929659   : Exception in coroutine 'Bot.3504929659'.

java.util.NoSuchElementException: net.mamoe.mirai.message.data.MessageSource$Key@601d4d7f
    at love.forte.simbot.component.mirai.event.MiraiReceivedMessageContentKt.toSimbotMessageContent(MiraiReceivedMessageContent.kt:118) ~[simbot-component-mirai-core-3.0.0.0.preview.2.0.jar:na]
    at love.forte.simbot.component.mirai.event.impl.MiraiFriendMessagePostSendEventImpl.<init>(MiraiFriendMessagePostSendEventImpl.kt:42) ~[simbot-component-mirai-core-3.0.0.0.preview.2.0.jar:na]
    at love.forte.simbot.component.mirai.internal.MiraiBotImplKt$registerEvents$1$invokeSuspend$$inlined$doHandler$34.invokeSuspend(MiraiBotImpl.kt:497) ~[simbot-component-mirai-core-3.0.0.0.preview.2.0.jar:na]
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ~[kotlin-stdlib-1.6.10.jar:1.6.10-release-923(1.6.10)]
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) ~[kotlinx-coroutines-core-jvm-1.5.2.jar:na]
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571) ~[kotlinx-coroutines-core-jvm-1.5.2.jar:na]
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) ~[kotlinx-coroutines-core-jvm-1.5.2.jar:na]
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678) ~[kotlinx-coroutines-core-jvm-1.5.2.jar:na]
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665) ~[kotlinx-coroutines-core-jvm-1.5.2.jar:na]