Interface BotReplyButtonMatcher

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface BotReplyButtonMatcher
Strategy interface for matching a BotReplyButton annotation against an incoming bot request.

The default implementation (registered in core) performs a simple exact-text comparison between the annotation values and the incoming message text.

When core-i18n is on the classpath it registers a replacement implementation that treats annotation values as message-bundle keys and resolves them in the user's locale before comparing — so a single @BotReplyButton("btn.yes") annotation handles all configured languages automatically.

Declare a bean of this type to provide a completely custom matching strategy:

@Bean
public BotReplyButtonMatcher myMatcher() {
    return (values, request) -> {
        String text = request.getUpdate().getMessage().getText();
        return Arrays.asList(values).contains(text.toLowerCase());
    };
}
Since:
0.0.1
Author:
Islom Mirsaburov
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    matches(String[] values, BotRequest request)
    Returns true if the incoming bot request should be handled by a @BotReplyButton method annotated with the given values.
  • Method Details

    • matches

      boolean matches(String[] values, BotRequest request)
      Returns true if the incoming bot request should be handled by a @BotReplyButton method annotated with the given values.

      Implementations may assume that the update already contains a text message — the presence check is performed by the caller before this method is invoked.

      Parameters:
      values - the values declared on the @BotReplyButton annotation
      request - the current bot request; request.getUpdate().getMessage().getText() is non-null
      Returns:
      true if the handler should process this request