Files
dsh-telegram-channel/lib/client.d.ts
T
owoandCursor a83af2f33c Simplify install with one-click scripts; honor HTTP(S)_PROXY for Telegram.
Add install.ps1/install.sh, shrink README to script-first flow, register bot commands, and route API calls through undici EnvHttpProxyAgent when a proxy is set (v0.2.2).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-14 17:46:01 +08:00

70 lines
2.2 KiB
TypeScript

export interface TelegramUser {
id: number;
is_bot?: boolean;
first_name?: string;
username?: string;
}
export interface TelegramChat {
id: number;
type: string;
title?: string;
username?: string;
}
export interface TelegramMessage {
message_id: number;
date: number;
chat: TelegramChat;
from?: TelegramUser;
text?: string;
}
export interface TelegramCallbackQuery {
id: string;
from: TelegramUser;
message?: TelegramMessage;
data?: string;
}
export interface TelegramUpdate {
update_id: number;
message?: TelegramMessage;
callback_query?: TelegramCallbackQuery;
}
export interface InlineKeyboardButton {
text: string;
callback_data: string;
}
export interface InlineKeyboardMarkup {
inline_keyboard: InlineKeyboardButton[][];
}
export interface TelegramBotCommand {
command: string;
description: string;
}
export interface TelegramClientOptions {
fetch?: typeof fetch;
baseUrl?: string;
pollingTimeoutSec?: number;
}
export interface TelegramClientLike {
getMe(): Promise<TelegramUser>;
getUpdates(offset?: number): Promise<TelegramUpdate[]>;
sendMessage(chatId: number, text: string, parseMode?: string, replyMarkup?: InlineKeyboardMarkup): Promise<TelegramMessage>;
sendChatAction(chatId: number, action: string): Promise<boolean>;
answerCallbackQuery(callbackQueryId: string, text?: string): Promise<boolean>;
setMyCommands(commands: TelegramBotCommand[]): Promise<boolean>;
}
export declare class TelegramClient implements TelegramClientLike {
private readonly token;
private readonly fetchImpl;
private readonly baseUrl;
private readonly pollingTimeoutSec;
constructor(token: string, options?: TelegramClientOptions);
private redact;
private call;
getMe(): Promise<TelegramUser>;
getUpdates(offset?: number): Promise<TelegramUpdate[]>;
sendMessage(chatId: number, text: string, parseMode?: string, replyMarkup?: InlineKeyboardMarkup): Promise<TelegramMessage>;
sendChatAction(chatId: number, action: string): Promise<boolean>;
answerCallbackQuery(callbackQueryId: string, text?: string): Promise<boolean>;
setMyCommands(commands: TelegramBotCommand[]): Promise<boolean>;
}