Open chpasha opened 5 months ago
@chpasha have you try adding this to your bot?
@AfterBotRegistration
@Override
public void onRegister() {
super.onRegister();
}
That should ensure that, after registering the bot in spring, the onRegister method is autocalled.
Hi, thanks. I used the @PostConstruct annotation which might be not the 100% right one, since post construction doesn't mean, the bot is already registered, but because the default implementation creates some stuff and doesn't seem to depend on being really registered, that did the trick. But like I wrote before, I found such design decision questionable, that some method has to be called before bot is usable. Is there any reason why you can't call onRegister on public method of the bot, when registerBot is called?
I don't think abilities was built with spring boot in mind. Hence it requires some extra workarounds to make it work.
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
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:
Expected behavior Ideally, onRegister would be called automatically OR at least mentioned in the documentation and examples provided