jTelegram / jTelegramBotAPI

Java Telegram Bot API Wrapper
https://jtelegram.github.io/jTelegramBotAPI/
MIT License
20 stars 12 forks source link

Callback inside InlineResult #18

Closed aaomidi closed 6 years ago

aaomidi commented 6 years ago

Implement a callback to be called when a specific InlineResult is called it calls a specific piece of code. This would allow a more fluid "event-driven" approach to making bots rather than using Maps for "ids" of Results on the developer side.

Example:

        AnswerInlineQuery answer = AnswerInlineQuery.builder()
                .queryId(inlineQueryEvent.getQuery().getId())
                .addResult(
                        InlineResultArticle.builder()
                                .title("booper")
                                .id(UUID.randomUUID().toString())
                                .inputMessageContent(
                                        InputTextMessageContent.builder()
                                                .messageText("boop")
                                                .build()
                                )
                                .build()
                )
                .callback(() -> {
                    System.out.println("No error");
                }).errorHandler(e -> System.out.println(e))
                .chosenCallback((chosenInlineResult) -> {}))
                .build();