Open D0nn1 opened 1 month ago
I have the same error , with kotlin version :
@Named
class EchoAbility(
telegramClient: TelegramClient,
@Value("\${telegram.bot.creatorId}")
val creatorId: Long,
@Value("\${telegram.bot.username}")
val name: String
) : AbilityBot(telegramClient, name) {
override fun creatorId(): Long {
return creatorId
}
fun startBot(): Ability {
return Ability
.builder()
.name("start")
.info("says hello world!")
.locality(Locality.ALL)
.privacy(Privacy.PUBLIC)
.action { ctx: MessageContext ->
logger.info { "sending hello world ... ctx = $ctx" }
silent.send("[EchoAbility] Hello world!", ctx.chatId())
}
.build()
}
companion object {
private val logger = KotlinLogging.logger { }
}
}
test code
class EchoAbilityTest : AbstractChatbotTest() {
@Inject
private lateinit var echoAbility: AbilityBot
@Value("\${telegram.bot.token}")
private lateinit var botToken: String
@Test
fun waitForever() {
val botsApplication = TelegramBotsLongPollingApplication()
botsApplication.registerBot(botToken, echoAbility)
val latch = CountDownLatch(1)
latch.await()
}
}
It runs OK , but when I send a message , I also encountered the same error
Exception in thread "pool-1-thread-1" java.lang.NullPointerException: Cannot invoke "java.util.List.stream()" because "this.replies" is null
I am not sure if this is related (abilities = null)
I'm having the same issue. It seems the onRegister method from BaseAbilityBot
public void onRegister() {
registerAbilities();
initStats();
}
is not called.
Solved it by calling it explicitely in my bot's constructor and it doesn´t seem to cause any issues, Hope this helps.
public BotService() {
super(new OkHttpTelegramClient(System.getenv("BOT_TOKEN")), "");
this.onRegister();
}
I'm having the same issue. It seems the onRegister method from BaseAbilityBot
public void onRegister() { registerAbilities(); initStats(); }
is not called.
Solved it by calling it explicitely in my bot's constructor and it doesn´t seem to cause any issues, Hope this helps.
public BotService() { super(new OkHttpTelegramClient(System.getenv("BOT_TOKEN")), ""); this.onRegister(); }
It's help
Describe the bug When trying to create a Telegram bot using the Abilities framework, a NullPointerException is thrown, indicating that the
replies
list is null when trying to invoke thestream()
method.To Reproduce Steps to reproduce the behavior:
PartyBot
class extendingAbilityBot
creatorId()
method andsayHelloWorld()
AbilityTgBotApplication
class with amain
method to register the botExpected behavior The bot should register successfully and be able to respond to the
/hello
command without throwing any exceptions.Code Snippets PartyBot class:
TgBotApplication class:
Error message
Environment:
Additional context This issue seems similar to a problem reported by other users.