Skip to content

TelegramBot启动时未初始化用户信息 #885

@Flock-YT

Description

@Flock-YT

是否会提供贡献?

版本号

simpler-robot:v4.3.0

附加版本

simbot-component-telegram:v0.0.6

涉及的编程语言

Java

项目构建工具

Maven

涉及的组件库

Telegram

问题描述

TelegramBot启动时未初始化用户信息导致从BotManagers中获取到已经注册好的Bot的ID时发生错误。

复现方式

BotManagers botManagers = application.getBotManagers();

        Sequence<Bot> botSequence = botManagers.allBots();

        Iterator<Bot> iterator = botSequence.iterator();

        while (iterator.hasNext()) {
            Bot bot = iterator.next();
            ID id = bot.getId();
            System.out.println(id);
        }

相关日志

java.lang.IllegalStateException: `userInfo` has not been initialized yet.
	at love.forte.simbot.component.telegram.core.bot.internal.TelegramBotImpl.getUserInfo(TelegramBotImpl.kt:77) ~[simbot-component-telegram-core-jvm-0.0.6.jar:na]
	at love.forte.simbot.component.telegram.core.bot.TelegramBot.getId(TelegramBot.kt:74) ~[simbot-component-telegram-core-jvm-0.0.6.jar:na]
	at me.lele.eric_tg_bot.listener.Test.onStart(Test.java:32) ~[classes/:na]
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
	at kotlin.reflect.jvm.internal.calls.CallerImpl$Method.callMethod(CallerImpl.kt:97) ~[kotlin-reflect-1.9.24.jar:1.9.24-release-822]
	at kotlin.reflect.jvm.internal.calls.CallerImpl$Method$Instance.call(CallerImpl.kt:113) ~[kotlin-reflect-1.9.24.jar:1.9.24-release-822]
	at kotlin.reflect.jvm.internal.KCallableImpl.call(KCallableImpl.kt:108) ~[kotlin-reflect-1.9.24.jar:1.9.24-release-822]
	at love.forte.simbot.quantcat.common.binder.FunctionalBindableEventListener$4.invokeSuspend$lambda$1$lambda$0(FunctionalBindableEventListener.kt:124) ~[simbot-quantcat-common-jvm-4.3.0.jar:na]
	at kotlinx.coroutines.InterruptibleKt.runInterruptibleInExpectedContext(Interruptible.kt:48) ~[kotlinx-coroutines-core-jvm-1.8.1.jar:na]
	at kotlinx.coroutines.InterruptibleKt.access$runInterruptibleInExpectedContext(Interruptible.kt:1) ~[kotlinx-coroutines-core-jvm-1.8.1.jar:na]
	at kotlinx.coroutines.InterruptibleKt$runInterruptible$2.invokeSuspend(Interruptible.kt:40) ~[kotlinx-coroutines-core-jvm-1.8.1.jar:na]
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ~[kotlin-stdlib-1.9.24.jar:1.9.24-release-822]
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104) ~[kotlinx-coroutines-core-jvm-1.8.1.jar:na]
	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111) ~[kotlinx-coroutines-core-jvm-1.8.1.jar:na]
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99) ~[kotlinx-coroutines-core-jvm-1.8.1.jar:na]
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584) ~[kotlinx-coroutines-core-jvm-1.8.1.jar:na]
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:811) ~[kotlinx-coroutines-core-jvm-1.8.1.jar:na]
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:715) ~[kotlinx-coroutines-core-jvm-1.8.1.jar:na]
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:702) ~[kotlinx-coroutines-core-jvm-1.8.1.jar:na]

其他补充

No response

Metadata

Metadata

Assignees

Labels

bug这是个BUG组件:Telegram与 Telegram 组件相关

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions