/**
 * Subset of the Telegram Bot API types we actually consume.
 *
 * Source: https://core.telegram.org/bots/api
 *
 * Only fields the bot reads or writes are typed — leaving the rest as `unknown`
 * keeps the surface narrow and the JSON parsing strict.
 */

export interface TelegramUser {
    id: number;
    is_bot: boolean;
    first_name: string;
    last_name?: string;
    username?: string;
}

export interface TelegramChat {
    id: number;
    type: 'private' | 'group' | 'supergroup' | 'channel' | string;
    title?: string;
    username?: string;
    first_name?: string;
}

export interface TelegramMessage {
    message_id: number;
    date: number;
    chat: TelegramChat;
    from?: TelegramUser;
    text?: string;
}

export interface TelegramUpdate {
    update_id: number;
    message?: TelegramMessage;
    edited_message?: TelegramMessage;
}

export interface TelegramApiSuccess<T> {
    ok: true;
    result: T;
}

export interface TelegramApiError {
    ok: false;
    error_code: number;
    description: string;
}

export type TelegramApiResponse<T> = TelegramApiSuccess<T> | TelegramApiError;

/** Maximum bytes per Telegram message payload (the API caps text at 4096 chars). */
export const TELEGRAM_MAX_TEXT_LENGTH = 4096;
