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

    Interface Plugin

    A telebot-ts plugin: a named, self-contained bundle of bot behavior.

    install runs synchronously while the application is being configured — wire up middleware, handlers, and lifecycle hooks there. Reserve asynchronous setup (opening connections, loading data) for onInit hooks, which run right before the bot starts serving updates.

    import type { Plugin } from "telebot-ts";

    export function analytics(endpoint: string): Plugin {
    return {
    name: "analytics",
    install(app) {
    app.use(async (context, next) => {
    track(endpoint, context.update.update_id);
    await next();
    });
    app.onShutdown(() => flushQueue());
    },
    };
    }
    interface Plugin {
        dependsOn?: readonly string[];
        name: string;
        priority?: number;
        uninstall?: (app: Application) => void;
        install(app: Application): void;
    }
    Index
    dependsOn?: readonly string[]

    Names of plugins that must be installed before this one.

    If a dependency is not installed yet, installation is deferred until it is (plugins are flushed automatically on every usePlugin call). Dependencies still missing when the application starts cause runPolling / runWebhook to throw.

    name: string

    Unique identifier of the plugin. Installing two plugins with the same name throws, so pick a namespaced name (e.g. "telebot-plugin-i18n").

    priority?: number

    Relative installation order among plugins whose dependencies are simultaneously satisfied: lower values install first. Installation order determines middleware execution order.

    0

    uninstall?: (app: Application) => void

    Optional teardown invoked by Application.removePlugin before the plugin's middleware, handlers, and hooks are deregistered. Use it to cancel timers or release resources the plugin owns outside of onShutdown hooks.

    Type Declaration

    • Synchronously wires the plugin into the application.

      Parameters

      Returns void