telebot-ts API Documentation - v1.0.0
    Preparing search index...

    Class MessageHandler<C, R>

    Handler for filtering and processing messages.

    const photoHandler = new MessageHandler(filters.PHOTO, async (update, context) => {
    console.log("Photo received!");
    });

    Type Parameters

    Hierarchy (View Summary)

    Index
    • Creates a new MessageHandler.

      Type Parameters

      • C extends CallbackContext<
            Record<string, unknown>,
            Record<string, unknown>,
            Record<string, unknown>,
        > = CallbackContext<
            Record<string, unknown>,
            Record<string, unknown>,
            Record<string, unknown>,
        >

        Type of the callback context.

      • R = unknown

        Return value type.

      Parameters

      • filters: BaseFilter | null | undefined

        The filter condition (or null/undefined for all messages).

      • callback: HandlerCallback<C, R>

        Function invoked when the filter matches.

      Returns MessageHandler<C, R>

    callback: HandlerCallback<C, R>

    The underlying callback function to invoke on match.

    filters: BaseFilter

    The message filter applied to incoming updates.

    • Evaluates the update against the configured message filter.

      Parameters

      • update: Update

        The update to test.

      Returns Promise<boolean>

      true if matched, false otherwise.

    • Populates context.matches if using a RegExp filter (or compound filter containing one) and executes callback.

      Parameters

      • update: Update

        The incoming update.

      • context: C

        Callback context instance.

      Returns Promise<R>

      Result from callback execution.