/** * Telegram channel adapter: Bot API long-polling intake, message * normalization into `dsh-connect`'s `InboundMessage`, and replies via * sendMessage / editMessageText with HTML parse mode. Interactive choice * prompts render as inline-keyboard buttons handled through callback queries. * * @module dsh-connect/channels/telegram/adapter */ import type { ChannelAdapter, ChoiceOption, ChoicePrompt, ChoiceResult, InboundMessage, OutboundTarget, SummaryCard } from "../../types.js"; import type { Language } from "../../i18n.js"; import { type TelegramMessage } from "./client.js"; export interface TelegramConfig { botToken?: string; language?: Language; /** Group messages require the bot to be @-mentioned in the text (default true). */ requireMention?: boolean; /** Polling timeout (seconds). */ pollingTimeoutSeconds?: number; /** HTTP base URL override (local Bot API server). */ baseUrl?: string; } /** Encode chatId + messageId into the opaque message id the core passes around. */ export declare function encodeMessageRef(chatId: string, messageId: number): string; /** Split an opaque message ref back into chatId + messageId. */ export declare function decodeMessageRef(ref: string): { chatId: string; messageId: number; }; /** Escape text for Telegram HTML parse mode (only `& < >` need escaping). */ export declare function escapeHtml(text: string): string; /** Convert plain markdown (bold/italic/inline code/code blocks/headings/links) to Telegram HTML. */ export declare function markdownToTelegramHtml(markdown: string): string; /** Build the inline-keyboard reply_markup for a choice prompt. */ export declare function buildInlineKeyboard(options: readonly ChoiceOption[], columnsPerRow: number): unknown; export declare class TelegramAdapter implements ChannelAdapter { private readonly logger?; readonly id = "telegram"; private readonly client; private readonly t; private readonly requireMention; private readonly pendingChoices; private handler?; private pollPromise?; private stopped; /** The bot's own user id (from getMe) — used for precise mention/reply checks. */ private botId?; /** The bot's username (from getMe) — used to verify @-mentions. */ private botUsername?; constructor(config: TelegramConfig, logger?: { warn?: (...args: unknown[]) => void; } | undefined); onInbound(handler: (msg: InboundMessage) => void | Promise): void; start(): Promise; stop(): Promise; private handleUpdate; private handleCallbackQuery; /** Normalize a Telegram message into dsh-connect's InboundMessage; returns undefined when ignored. */ private normalizeMessage; sendText(target: OutboundTarget, text: string): Promise; sendCard(target: OutboundTarget, card: SummaryCard): Promise; sendFile(target: OutboundTarget, filePath: string, options?: { filename?: string; }): Promise; streamText(target: OutboundTarget, chunks: AsyncIterable): Promise; promptChoice(target: OutboundTarget, prompt: ChoicePrompt, updateMessageId?: string, _signal?: AbortSignal, onPresented?: (messageId: string) => void): Promise; closeMenu(messageId: string, summary: string): Promise; } /** True when the message mentions this bot: a reply to it, or an @-mention of its username. */ export declare function isBotMentioned(message: TelegramMessage, text: string, botUsername?: string, botId?: number): boolean; //# sourceMappingURL=adapter.d.ts.map