Module

x/grammy/mod.ts>Composer#branch

The Telegram Bot Framework.
Very Popular
Go to Latest
method Composer.prototype.branch
import { Composer } from "https://dotland.deno.dev/x/grammy@v1.31.1/mod.ts";

This is an advanced method of grammY.

Allows you to branch between two cases for a given context object.

This method takes a predicate function that is tested once per context object. If it returns true, the first supplied middleware is executed. If it returns false, the second supplied middleware is executed. Note that the predicate may be asynchronous, i.e. it can return a Promise of a boolean.

Parameters

predicate: (ctx: C) => MaybePromise<boolean>

The predicate to check

trueMiddleware: MaybeArray<Middleware<C>>

The middleware for the true case

falseMiddleware: MaybeArray<Middleware<C>>

The middleware for the false case