/** * Types for route configuration and management * * @module types/route */ import type { User } from '../api/types/User.generated.js'; import type { InputFile } from '../api/types/InputFile.generated.js'; import type { WebhookInfo } from '../api/types/WebhookInfo.generated.js'; /** * Route operation mode */ export declare enum RouteMode { /** Webhook mode - receive updates via webhook */ Webhook = "webhook", /** Long polling mode - fetch updates via getUpdates */ LongPolling = "longPolling", /** Inactive mode - route is disabled */ Inactive = "inactive" } /** * Route status information */ export interface RouteStatus { /** Current operation mode */ mode: RouteMode; /** Is route active */ active: boolean; /** Webhook info (if in webhook mode) */ webhookInfo?: WebhookInfo; /** Last update ID (if in longPolling mode) */ lastUpdateId?: number; /** Bot information */ botInfo?: User; } /** * Webhook configuration for a route */ export interface WebhookConfig { /** * Full webhook URL (absolute URL) * If specified, takes precedence over path * Example: 'https://example.com/webhook/bot1' */ url?: string; /** * Webhook path (relative path, combined with webhookBaseUrl from TelegramBotClient) * Used when url is not specified * Example: '/bot1' -> combined with 'https://example.com/webhooks' -> 'https://example.com/webhooks/bot1' */ path?: string; /** Secret token for webhook validation */ secretToken?: string; /** Max simultaneous connections (1-100, default: 40) */ maxConnections?: number; /** Allowed update types */ allowedUpdates?: string[]; /** Drop pending updates when setting webhook */ dropPendingUpdates?: boolean; /** Fixed IP address for webhook */ ipAddress?: string; /** Certificate for self-signed webhook */ certificate?: InputFile; } /** * Long polling configuration */ export interface LongPollingConfig { /** Polling interval in milliseconds (default: 1000) */ interval?: number; /** Timeout for long polling request in seconds (default: 30) */ timeout?: number; /** Limit of updates to fetch (1-100, default: 100) */ limit?: number; /** Allowed update types */ allowedUpdates?: string[]; } /** * Configuration for a bot route */ export interface RouteConfig { /** Bot token */ token: string; /** Initial operation mode (default: inactive) */ mode?: RouteMode; /** Webhook configuration (for webhook mode) */ webhook?: WebhookConfig; /** Long polling configuration (for longPolling mode) */ longPolling?: LongPollingConfig; /** Auto-activate on init (default: true) */ autoActivate?: boolean; /** Cached bot info (set after init) */ botInfo?: User; /** Current route status (managed internally) */ status?: RouteStatus; } /** * Default values for webhook configuration */ export interface WebhookDefaults { /** Default secret token for all routes */ secretToken?: string; /** Default max connections (1-100) */ maxConnections?: number; /** Default allowed update types */ allowedUpdates?: string[]; /** Default drop pending updates flag */ dropPendingUpdates?: boolean; /** Default IP address */ ipAddress?: string; }