Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a default ability with with 'GROUP' locality renders all commands unavailable #1296

Open
Haarolean opened this issue Jan 10, 2024 · 2 comments
Labels

Comments

@Haarolean
Copy link

Hi, not sure what this repo state is in, considering the sheer amount of open & unanswered issues and PRs, but I'll try anyway:

The problem is that adding an ability as such:

        return Ability
                .builder()
                .name("default")
                .flag(TEXT)
                .locality(Locality.GROUP)
                .privacy(Privacy.PUBLIC)
                .action(this::checkLinks)
                .build();

makes all the other default commands/abilities inaccessible. The bot just replies with "Sorry, group-only feature.", since it's, well, a default ability. I have to use this particular set of options (locality, privacy) to check message contents. There's no way to further chain the event or make the other abilities in the list usable.

I propose to allow processing of the update further down the chain (replace Consumer in Ability with Function<MessageContext, Boolean and proceed to other abilities)

@Haarolean
Copy link
Author

Haarolean commented Jan 10, 2024

Ah, I figured that since then I've changed the command prefix. With a proper prefix the commands work, buut if you type anything that doesn't start with a command prefix you get the same message in private messages, despite the ability was designed fro group messages. So, it seems, like there should be (?) a default ability per each privacy level?

@Haarolean
Copy link
Author

To solve that, currently a hack like this could be implemented:

  1. Replacing ability's locality from GROUP to ALL
  2. In action we have to check if it's non-group message and stop further processing the update:
.action(ctx -> {
                    if (!shouldProceed(ctx)) return;
                    yourAction();
                })
private boolean shouldProceed(MessageContext ctx) {
        var update = ctx.update();
        return !isUserMessage(update);
    }

@rubenlagus rubenlagus added Feature Request Abilities Bugs related to abilities module labels Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants