import type { AssistantResult, ConfigFacade } from "../../types/index.js"; /** Default Telegram Bot API base URL. */ export declare const TELEGRAM_API_BASE = "https://api.telegram.org"; /** Configuration for a Telegram bot. */ export interface TelegramConfig { token: string; apiBaseUrl?: string; } /** Callback producing an assistant reply for a channel session. */ export type TelegramReplyFn = (sessionId: string, text: string) => Promise; /** Options for the long-polling loop. */ export interface TelegramPollingOptions { intervalMs?: number; signal?: AbortSignal; reply?: TelegramReplyFn; } /** * TelegramService - Singleton para el bot de Telegram. * * Aplica el patrón Singleton: una única instancia centraliza la configuración, * el envío de mensajes y el bucle de polling. La configuración se registra una * sola vez y todas las operaciones comparten ese estado. * * @example * ```ts * TelegramService.getInstance().useInit({ token: process.env.TELEGRAM_BOT_TOKEN }); * await TelegramService.getInstance().useSendMessage(chatId, "Hello"); * ``` */ export declare class TelegramService { private static instance; /** Module-level bot configuration. */ private config; /** * Constructor privado - enforce singleton. */ private constructor(); /** * Obtiene la instancia única del TelegramService (Singleton). * * @returns La instancia única de {@link TelegramService}. */ static getInstance(): TelegramService; /** Retrieves the configured bot or throws. */ private useGetConfig; /** * Registers the Telegram bot configuration. * * @param cfg - Bot token (from BotFather) and optional API base URL. * * @example * ```ts * TelegramService.getInstance().useInit({ token: process.env.TELEGRAM_BOT_TOKEN }); * ``` */ useInit(cfg: TelegramConfig): void; /** * Sends a text message to a Telegram chat. * * @param chatId - Destination chat id. * @param text - Message body. * @returns The Telegram API response. */ useSendMessage(chatId: number, text: string): Promise; /** * Handles a single Telegram update: replies to inbound text messages. * * @param update - A Telegram update object (from `getUpdates` or a webhook). * @param reply - Reply callback. Defaults to the assistant `useReply`. * * @example * ```ts * await TelegramService.getInstance().useHandleUpdate(update); * ``` */ useHandleUpdate(update: unknown, reply?: TelegramReplyFn): Promise; /** * Starts the long-polling loop that keeps fetching and answering updates. * Runs until the provided signal aborts (or forever). * * @param options - Polling cadence, abort signal and reply callback. * * @example * ```ts * await TelegramService.getInstance().useStartPolling(); * ``` */ useStartPolling(options?: TelegramPollingOptions): Promise; } /** * Registers the Telegram bot configuration - the config-file entry point. * * One call is the whole setup: the literal is registered and handed back on * `config`, so `export default defineTelegramConfig({ … })` is enough. * * @param input - Bot token (from BotFather) and optional API base URL. * @returns The registered config as a `ConfigFacade`. * * @example * ```ts * import { defineTelegramConfig } from "katanakit-js/adapters/telegram"; * * export default defineTelegramConfig({ token: process.env.TELEGRAM_BOT_TOKEN }); * ``` */ export declare function defineTelegramConfig(input: TelegramConfig): ConfigFacade; /** * Registers the Telegram bot configuration. * * @deprecated Use {@link defineTelegramConfig}, which registers and returns * the config in one call. * * @param cfg - Bot token (from BotFather) and optional API base URL. * * @example * ```ts * useInitTelegram({ token: process.env.TELEGRAM_BOT_TOKEN }); * ``` */ export declare function useInitTelegram(cfg: TelegramConfig): void; /** * Sends a text message to a Telegram chat. * * @param chatId - Destination chat id. * @param text - Message body. * @returns The Telegram API response. */ export declare function useTelegramSendMessage(chatId: number, text: string): Promise; /** * Handles a single Telegram update: replies to inbound text messages. * * @param update - A Telegram update object (from `getUpdates` or a webhook). * @param reply - Reply callback. Defaults to the assistant `useReply`. * * @example * ```ts * await useHandleTelegramUpdate(update); * ``` */ export declare function useHandleTelegramUpdate(update: unknown, reply?: TelegramReplyFn): Promise; /** * Starts the long-polling loop that keeps fetching and answering updates. * Runs until the provided signal aborts (or forever). * * @param options - Polling cadence, abort signal and reply callback. * * @example * ```ts * useStartTelegramPolling(); * ``` */ export declare function useStartTelegramPolling(options?: TelegramPollingOptions): Promise; //# sourceMappingURL=telegram.service.d.ts.map