Annotation Interface ChosenInlineHandler


@Retention(RUNTIME) @Target(METHOD) @Repeatable(ChosenInlineHandlers.class) public @interface ChosenInlineHandler
Annotation for handling chosen inline result events in a declarative manner. Designed specifically for handling events when a user selects a result from an inline query, providing feedback about which result was chosen and the original query.

Basic chosen inline result handler example:


 @ChosenInlineHandler
 void handleChosenResult(BotContext context, ChosenInlineResult result) {
     // Handle when a user selects an inline result
 }
 

Specific result ID handler example:


 @ChosenInlineHandler(resultId = "news_article_123")
 void handleNewsArticleSelection(BotContext context, ChosenInlineResult result) {
     // Handle when a specific news article result is chosen
 }
 

Query-based handler example:


 @ChosenInlineHandler(query = "weather")
 void handleWeatherQuerySelection(BotContext context, ChosenInlineResult result) {
     // Handle when any result from a "weather" query is chosen
 }
 


Equivalent with using BotClient.onChosenInlineResult(FilterExecutor, UpdateHandler)
Since:
1.2.0
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Class<? extends CustomFilter>
    Custom filter class for advanced filtering of chosen inline result events.
    int
    Priority order for handler registration and execution.
    Specifies the original inline query text to match.
    Specifies the inline result IDs to match.
  • Element Details

    • resultId

      String[] resultId
      Specifies the inline result IDs to match. Multiple result IDs are combined using OR logic - the handler will trigger if the chosen result ID matches any of the specified values. Useful for tracking specific content selections or implementing analytics.
      Returns:
      array of result ID strings to match
      Default:
      {}
    • query

      String[] query
      Specifies the original inline query text to match. Multiple query strings are combined using OR logic - the handler will trigger if the original query matches any of the specified strings. Useful for categorizing chosen results by search intent.
      Returns:
      array of query strings to match
      Default:
      {}
    • filter

      Class<? extends CustomFilter> filter
      Custom filter class for advanced filtering of chosen inline result events. Use this to implement custom logic for determining which chosen results should trigger this handler, such as filtering by user characteristics, location, timing, or other application-specific criteria.
      Returns:
      class implementing CustomFilter interface
      Default:
      io.github.natanimn.telebof.filters.DefaultCustomFilter.class
    • priority

      int priority
      Priority order for handler registration and execution. Handlers with lower priority numbers are registered and executed before those with higher numbers. This allows controlling the order of handler processing when multiple handlers could match the same chosen result event.
      Returns:
      priority integer value (lower = earlier execution)
      Default:
      0