CraftcodeCrew / Getting-Started-with-Telegrams-AbilityBot

This is the code for my getting started
https://craftcodecrew.com/getting-started-with-the-telegram-abilitybot
12 stars 6 forks source link

Doubt about the code #1

Closed shikida closed 5 years ago

shikida commented 5 years ago

who calls this method?

public Reply replyToButtons() {
    Consumer<Update> action = upd -> responseHandler.replyToButtons(getChatId(upd), upd.getCallbackQuery().getData());
    return Reply.of(action, Flag.CALLBACK_QUERY);
}
djuelg commented 5 years ago

Yeah, I understand your confusion it's a little bit crazy what the AbilityBot library is doing there. Our "grandfather" class (BaseAbilityBot) is using reflection to find all public methods in the FitnessBot class that return either a Reply or an Ability.

You can find the code here: https://github.com/rubenlagus/TelegramBots/blob/da5e7a776f01ae42f9154d6285d935a58d91c749/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java#L615