Annotation Interface ChannelPostHandler
@Retention(RUNTIME)
@Target(METHOD)
@Repeatable(ChannelPostHandlers.class)
public @interface ChannelPostHandler
Annotation for handling incoming channel posts in a declarative manner.
 Specifically designed for filtering and handling messages posted in channels.
 
Equivalent with using
Basic command handler example for channels:
 @ChannelPostHandler(commands = "announce")
 void handleAnnounceCommand(BotContext context, Message message) {
     // Handle /announce command in channel posts
 }
 Media post example:
 @ChannelPostHandler(type = {MessageType.PHOTO, MessageType.VIDEO})
 void handleChannelMedia(BotContext context, Message message) {
     // Handle both photo and video posts in channels
 }
 Advanced example with text matching:
 @ChannelPostHandler(texts = {"news", "update"})
 void handleImportantUpdates(BotContext context, Message message) {
     // Handle text posts containing "news" or "update" with "important" prefix
 }
 Equivalent with using
BotClient.onChannelPost(FilterExecutor, UpdateHandler)- Since:
- 1.2.0
- 
Optional Element SummaryOptional ElementsModifier and TypeOptional ElementDescriptionString[]Specifies the bot commands to match in channel posts (e.g., "/announce", "/news").Class<? extends CustomFilter> Custom filter class for advanced filtering logic beyond the built-in options.intPriority order for handler registration and execution.Regular expression pattern to match against channel post text content.String[]Specifies exact text content to match in the channel post.Specifies the message types to match in channel posts (text, photo, video, etc.).
- 
Element Details- 
commandsString[] commandsSpecifies the bot commands to match in channel posts (e.g., "/announce", "/news"). Multiple commands are combined using OR logic - the handler will trigger if the channel post contains any of the specified commands.- Returns:
- array of command strings to match
 - Default:
- {}
 
- 
textsString[] textsSpecifies exact text content to match in the channel post. Multiple texts are combined using OR logic - the handler will trigger if the channel post text exactly matches any of the specified strings.- Returns:
- array of exact text strings to match
 - Default:
- {}
 
- 
regexString regexRegular expression pattern to match against channel post text content. The handler will trigger if the channel post text matches the specified regex pattern.- Returns:
- regex pattern string for channel post text matching
 - Default:
- ""
 
- 
typeMessageType[] typeSpecifies the message types to match in channel posts (text, photo, video, etc.). Multiple message types are combined using OR logic - the handler will trigger if the channel post type matches any of the specified types.- Returns:
- array of MessageTypeenum values to filter by
 - Default:
- {}
 
- 
filterClass<? extends CustomFilter> filterCustom filter class for advanced filtering logic beyond the built-in options. Use this when you need complex or application-specific filtering conditions for channel posts that cannot be expressed through the other annotation parameters.- Returns:
- class implementing CustomFilterinterface
 - Default:
- io.github.natanimn.telebof.filters.DefaultCustomFilter.class
 
- 
priorityint priorityPriority 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 channel post.- Returns:
- priority integer value (lower = earlier execution)
 - Default:
- 0
 
 
-