rubenlagus / TelegramBots

Java library to create bots using Telegram Bots API
https://telegram.me/JavaBotsApi
MIT License
4.77k stars 1.22k forks source link

Simple Ability Bot Tutorial - No post action was detected for method with name #389

Closed Wursteintopf closed 6 years ago

Wursteintopf commented 6 years ago

Hey there, I'm pretty new to programming Telegram Bots and also to programming in general. So I was following your wiki tutorial on how to build a Simple Ability Bot and I get the following error as soon as I try to start the bot:

Feb 20, 2018 11:20:50 AM org.telegram.telegrambots.logging.BotLogger info
INFORMATION: Ability - No post action was detected for method with name [hello]
Feb 20, 2018 11:20:50 AM org.telegram.telegrambots.logging.BotLogger info
INFORMATION: Ability - No post action was detected for method with name [commands]
Feb 20, 2018 11:20:50 AM org.telegram.telegrambots.logging.BotLogger info
INFORMATION: Ability - No post action was detected for method with name [backup]
Feb 20, 2018 11:20:50 AM org.telegram.telegrambots.logging.BotLogger info
INFORMATION: Ability - No post action was detected for method with name [recover]

What did I do wrong?

addo47 commented 6 years ago

Hey there! Thanks for using AbilityBot.

What you're seeing is a normal message. If you test your bot with /hello you're gonna get the anticipated reply.

Tip: Whenever you look at a errors, always check their tags (WARN, ERROR, INFO, etc..). If you inspect the log entry closely: "INFORMATION: Ability - No post action was detected for method with name [recover]"

It's just information that the postaction was not detected. What's post action? All abilities can define a .post(() -> doSomething()). It's a post action since this action is performed after the regular action is done. For example, you can let the post action to send a "Bye world!" message. If you test the bot, it would send two messages after a /hello command.

Wursteintopf commented 6 years ago

Aaaaah, I understand! So my mistake must've been somewhere else, cause /hello actually doesn't do anything. I'll have a look at it again 🤔

Wursteintopf commented 6 years ago

Well I found my mistake... As soon as I use an @Override public void onUpdateReceived(Update update) in the same project, it automatically kills all of my abillities. (Which somehow makes sense, since I override the function that obviously implements my abilities into the Bot.) Is there any other way to trigger the bot by certain keywords in messages while using an AbilityBot?

addo47 commented 6 years ago

Yes, you should use replies.

Wursteintopf commented 6 years ago

Awesome, thats excactly what I need, thanks! But I think I found a mistake: return Reply.of(upd, Flag.PHOTO) should be return Reply.of(action, Flag.PHOTO); or not?

addo47 commented 6 years ago

That is true. :)

addo47 commented 6 years ago

@Wursteintopf Please close this issue if it's done.

Wursteintopf commented 6 years ago

Yeah sure, sorry.