Skip to content

FAQ

How to filter updates in some part of BehaviourBuilder?

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

buildBehaviourWithLongPolling {
    createSubContext(
        updatesUpstreamFlow = filter { /* some condition */ }
    ) {
        onCommand() //...
    }
}

Additional info

Cases

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