Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After upgrade to 7.2.x AbilityBot.onRegister must be called manually or it will fail to accept messages #1354

Open
chpasha opened this issue Apr 17, 2024 · 0 comments
Labels
bug Spring Bugs related to spring module

Comments

@chpasha
Copy link

chpasha commented Apr 17, 2024

Describe the bug
After upgrade to 7.2.x if I don't call AbilityBot.onRegister() method manually after bot creation, it will fail to receive any messages from API with following exception

Exception in thread "pool-2-thread-1" java.lang.NullPointerException: Cannot invoke "java.util.List.stream()" because "this.replies" is null
	at org.telegram.telegrambots.abilitybots.api.bot.BaseAbilityBot.filterReply(BaseAbilityBot.java:621)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
	at java.base/java.util.stream.Streams$StreamBuilderImpl.forEachRemaining(Streams.java:411)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at org.telegram.telegrambots.abilitybots.api.bot.BaseAbilityBot.consume(BaseAbilityBot.java:201)
	at org.telegram.telegrambots.abilitybots.api.bot.AbilityBot.consume(AbilityBot.java:37)

this.replies is indeed null until onRegister is called. So my question is, am I doing something wrong? Documentation says nothing about it and yet everything works fine only if I call this method manually. If it is an intention? If so, why it is not mentioned anywhere. And if it is an intention, it looks like a bad design choice, because some magic method on bot must be called additionally to its creation and registration in TelegramBotApplication

To Reproduce
Steps to reproduce the behavior:

implementation 'org.telegram:telegrambots-springboot-longpolling-starter:7.2.1'
implementation 'org.telegram:telegrambots-abilities:7.2.1'
implementation 'org.telegram:telegrambots-client:7.2.1'

class MyBot extends AbilityBot implements SpringLongPollingBot  {}


Expected behavior
Ideally, onRegister would be called automatically OR at least mentioned in the documentation and examples provided

@Chase22 Chase22 added bug Spring Bugs related to spring module labels May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Spring Bugs related to spring module
Projects
None yet
Development

No branches or pull requests

2 participants