Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escape special characters +-&|!(){}[]^"~*?:\ - e.g. \+ \* \!
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
Regex for BDK v2.14.3 to register all commands using @Slash

Our team was using v2.3.1 where the following code snippet for spring boot application registered all the commands starting with / and having any number of arguments

@Slash(value = "/(.*)", mentionBot = false)
public void handleComnmand(CommandContext commandContext) {
// Some logic

But after upgrading to v2.14.3 it does not pick up all the commands, apprarently because of the requirement to have the arguments as method parameters.

We have a requirement to upgrade to v2.14.3 or later and want to be able to register all the commands with a single regex/method.

Please suggest on how to proceed with this

Posted 8 months ago
Votes Newest

Answers 2

This change was deliberate to support a proper structure for command arguments that could be parameterised and typed. The BDK never officially supported regular expressions so it was by chance that this worked for you in the versions prior. If you would like to use custom matchers, you can choose to extend CommandActivity.

public class HelloCommand extends CommandActivity<CommandContext> {
    private MessageService messageService;
    protected ActivityMatcher<CommandContext> matcher() {
        return m -> m.getTextContent().startsWith("/hello");
    protected void onActivity(CommandContext context) {
        String arg = context.getTextContent().substring(7);
        messageService.send(context.getStreamId(), "Hello! " + arg);
    protected ActivityInfo info() {
        return new ActivityInfo()
            .name("Hello Command")
            .description("Says hello to people")
Posted 8 months ago
Yong Sheng Tan
39 × 2 Administrator

its my answer

Posted 7 months ago
2 Answers
8 months ago
7 months ago