TelegramBots icon indicating copy to clipboard operation
TelegramBots copied to clipboard

Can't listen for both MESSAGE and EDITED_MESSAGE events on default ability

Open Haarolean opened this issue 1 year ago • 1 comments

I'm having a default ability to check the messages (I need to do that for both new and edited messages) defined this way:

return Ability
                .builder()
                .name("default")
                .flag(Flag.MESSAGE, EDITED_MESSAGE)
                .locality(Locality.ALL)
                .privacy(Privacy.PUBLIC)
                .action(ctx -> {
                    checkLinks(ctx);
                })
                .build();

With this approach, checkMessageFlags in BaseAbilityBot always fails, if at least one of the flags tests false (it's always false in my case, since an update can't be both new and an edited message simultaneously).

Another approach I thought of (registering two abilities with different flags) fails as well, as we can't have more than one default ability.

Haarolean avatar Jan 10 '24 14:01 Haarolean

You can use the following WA: .flag(update -> update.hasMessage() || update.hasEditedMessage())

ekomrak avatar Apr 14 '24 07:04 ekomrak