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
Answered
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 5 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.

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

its my answer

  
  
Posted 4 months ago
3K Views
2 Answers
5 months ago
4 months ago
Tags