Skip to content

FAQ

How to filter updates in some part of BehaviourBuilder?

You may create subcontext with BehaviourBuilder.createSubContextAndDoWithUpdatesFilter and pass there updatesUpstreamFlow parameter with any operations over parent behaviour builder:

buildBehaviourWithLongPolling {
    createSubContextAndDoWithUpdatesFilter(
        updatesUpstreamFlow = filter { /* some condition */ },
        stopOnCompletion = false // disable stopping of sub context after setup
    ) {
        onCommand() //...
    }
}

Additional info

Cases

  • Filtering of chats and users:
        updatesUpstreamFlow = filter { it.sourceChat() ?.id == requiredChatId || it.sourceUser() ?.id == requiredUserId }