// Public TypeScript surface for @xbibzlibrary/telebibz. import type { ApiMethods, Opts } from './types/telegram-bot-api/methods.js'; import type { InputRichBlock, InputRichBlockButtons, InputRichMessage, InputRichMessageMedia, RichMessageButton, RichTextButton } from './types/telegram-bot-api/rich.js'; export * as TelegramTypes from './types/telegram-bot-api/mod.js'; export type * from './types/telegram-bot-api/rich.js'; export type TelegramFileInput = string | File; export type TelegramMethodName = keyof ApiMethods; export type TelegramApiMethods = ApiMethods; export type TelegramApiPayloads = Opts; export type TelegramMethodArguments = Parameters[M]>; export type TelegramMethodPayload = Opts[M]; export type TelegramMethodResult = ReturnType[M]>; export const TELEGRAM_API_METHODS: readonly TelegramMethodName[]; export interface ApiClient { readonly token: string; config: { use(transformer: (prev: (method: string, payload?: any) => Promise, method: string, payload?: any) => any): ApiClient['config'] }; callApi(method: M, ...args: TelegramMethodArguments): Promise>; raw(method: M, ...args: TelegramMethodArguments): Promise>; sendRichMessage(payload: TelegramMethodPayload<'sendRichMessage'>): Promise>; sendLivePhoto(payload: TelegramMethodPayload<'sendLivePhoto'>): Promise>; sendMessageDraft(payload: TelegramMethodPayload<'sendMessageDraft'>): Promise>; sendRichMessageDraft(payload: TelegramMethodPayload<'sendRichMessageDraft'>): Promise>; answerGuestQuery(payload: TelegramMethodPayload<'answerGuestQuery'>): Promise>; editEphemeralMessageText(payload: TelegramMethodPayload<'editEphemeralMessageText'>): Promise>; editEphemeralMessageMedia(payload: TelegramMethodPayload<'editEphemeralMessageMedia'>): Promise>; editEphemeralMessageCaption(payload: TelegramMethodPayload<'editEphemeralMessageCaption'>): Promise>; editEphemeralMessageReplyMarkup(payload: TelegramMethodPayload<'editEphemeralMessageReplyMarkup'>): Promise>; deleteEphemeralMessage(payload: TelegramMethodPayload<'deleteEphemeralMessage'>): Promise>; [method: string]: any; } export type Handler = (ctx: Context, next?: () => Promise) => unknown; export type WizardMode = 'send' | 'edit' | 'delete'; export type WizardButton = string | { text: string; value?: unknown }; export type Color = 'danger' | 'success' | 'primary'; export interface WizardStep { key: string; ask: string | ((ctx: Context) => string | Promise); parse?: (text: unknown, ctx: Context) => unknown | Promise; validate?: (value: unknown, ctx: Context) => string | null | Promise; opts?: Record; buttons?: Array; inline?: boolean; onlyButtons?: boolean | string; mode?: WizardMode; oneTime?: boolean; } export interface WizardDef { steps: WizardStep[]; done: (answers: Record, ctx: Context) => unknown; cancelWords?: string[]; onCancel?: (ctx: Context) => unknown; mode?: WizardMode; cleanup?: boolean; removeKeyboard?: boolean; } export interface SessionOptions { initial?: () => Record; getKey?: (ctx: Context) => string | undefined; storage?: { read(key: string): unknown | Promise; write(key: string, value: Record): unknown | Promise; delete(key: string): unknown | Promise; } | Map>; } export interface TeleBibzOptions { allowedUpdates?: string[]; /** Maximum active updates per bot process. Default: 256. Updates sharing a session key are serialized. */ maxConcurrentUpdates?: number; onError?: (err: unknown, ctx?: Context) => unknown; silent?: boolean; dropPending?: boolean; session?: SessionOptions; transport?: (method: string, payload?: Record) => Promise; apiRoot?: string; proxy?: string; timeoutMs?: number; headers?: Record; } export class Context { constructor(update: any, api: any, me?: any); update: any; api: ApiClient; me?: any; msg?: any; chat?: any; from?: any; chatId?: number | string; msgId?: number; guestQueryId?: string; session: Record; match?: string; reply(text: string, extra?: object): Promise; replyWithRichMessage(content: InputRichMessage, extra?: object): Promise; replyWithLivePhoto(livePhoto: TelegramFileInput, photo: TelegramFileInput, extra?: object): Promise; replyEphemeral(text: string, receiverUserId: number, extra?: object): Promise; sendMessageDraft(draftId: number, text: string, extra?: object): Promise; sendRichMessageDraft(draftId: number, content: TelegramMethodPayload<'sendRichMessageDraft'>['rich_message'], extra?: object): Promise; replyWithHTML(text: string, extra?: object): Promise; replyWithMarkdown(text: string, extra?: object): Promise; replyWithPhoto(photo: any, extra?: object): Promise; replyWithVideo(video: any, extra?: object): Promise; replyWithAudio(audio: any, extra?: object): Promise; replyWithDocument(document: any, extra?: object): Promise; replyWithAnimation(animation: any, extra?: object): Promise; replyWithVoice(voice: any, extra?: object): Promise; replyWithVideoNote(videoNote: any, extra?: object): Promise; replyWithSticker(sticker: any, extra?: object): Promise; replyWithMediaGroup(media: any[], extra?: object): Promise; replyWithLocation(latitude: number, longitude: number, extra?: object): Promise; replyWithVenue(latitude: number, longitude: number, title: string, address: string, extra?: object): Promise; replyWithContact(phone: string, firstName: string, extra?: object): Promise; replyWithPoll(question: string, options: any[], extra?: object): Promise; replyWithDice(emoji?: string, extra?: object): Promise; replyWithInvoice(title: string, description: string, payload: string, currency: string, prices: any[], extra?: object): Promise; replyWithChatAction(action?: string, extra?: object): Promise; forwardMessage(to: number | string, from?: number | string, messageId?: number, extra?: object): Promise; copyMessage(to: number | string, from?: number | string, messageId?: number, extra?: object): Promise; editMessageText(text: string, extra?: object): Promise; editRichMessage(content: InputRichMessage, extra?: object): Promise; editEphemeralMessageText(receiverUserId: number, ephemeralMessageId: number, text: string, extra?: object): Promise; editEphemeralRichMessage(receiverUserId: number, ephemeralMessageId: number, content: InputRichMessage, extra?: object): Promise; editEphemeralMessageMedia(receiverUserId: number, ephemeralMessageId: number, media: any, extra?: object): Promise; editEphemeralMessageCaption(receiverUserId: number, ephemeralMessageId: number, extra?: object): Promise; editEphemeralMessageReplyMarkup(receiverUserId: number, ephemeralMessageId: number, extra?: object): Promise; deleteEphemeralMessage(receiverUserId: number, ephemeralMessageId: number): Promise; editMessageCaption(extra?: object): Promise; editMessageMedia(media: any, extra?: object): Promise; editMessageReplyMarkup(extra?: object): Promise; deleteMessage(chatId?: number | string, messageId?: number): Promise; deleteMessages(ids: number[]): Promise; react(emoji?: string, extra?: object): Promise; answerCallbackQuery(extra?: object | string): Promise; answerInlineQuery(results: any[], extra?: object): Promise; answerGuestQuery(result: any): Promise; getFile(): Promise; downloadFile(dest: string): Promise; [key: string]: any; } export class Composer { use(...middleware: any[]): this; on(filter: string | string[], ...middleware: Handler[]): this; hears(match: string | RegExp, ...middleware: Handler[]): this; command(names: string | string[], ...middleware: Handler[]): this; callbackQuery(triggers: string | RegExp | Array, ...middleware: Handler[]): this; filter(predicate: (ctx: Context) => unknown, ...middleware: Array): Composer; drop(predicate: (ctx: Context) => unknown, ...middleware: Array): Composer; branch(predicate: (ctx: Context) => unknown, yes: any, no: any): this; route(router: string | ((ctx: Context) => unknown), routes: Record): this; lazy(factory: (ctx: Context) => any): this; fork(...middleware: Handler[]): this; errorBoundary(handler: (err: BotError, next: () => Promise) => unknown, ...middleware: Handler[]): Composer; middleware(): Handler; run(ctx: Context, next?: () => Promise): Promise; } export class BotError extends Error { error: unknown; ctx: Context; } export class TeleBibz { constructor(token: string, opts?: TeleBibzOptions); api: ApiClient; botInfo?: any; use(...middleware: Array): this; cmd(names: string | string[], ...middleware: Handler[]): this; hears(match: string | RegExp, ...middleware: Handler[]): this; action(triggers: string | RegExp | Array, ...middleware: Handler[]): this; on(filter: string | string[], ...middleware: Handler[]): this; inlineQuery(trigger: string | RegExp, ...middleware: Handler[]): this; branch(predicate: (ctx: Context) => unknown, yes: Handler | Composer, no: Handler | Composer): this; filter(predicate: (ctx: Context) => unknown, ...middleware: Array): this; drop(predicate: (ctx: Context) => unknown, ...middleware: Array): this; route(router: string | ((ctx: Context) => unknown), routes: Record): this; lazy(factory: (ctx: Context) => Handler | Handler[] | Composer | Promise): this; fork(...middleware: Array): this; start(replies: string | Handler): this; wizard(id: string, def: WizardDef, bindCommand?: boolean): this; wizardStart(ctx: Context, id: string): Promise; wizardActive(ctx: Context): boolean; wizardCancel(ctx: Context): Promise; wizardEdit(ctx: Context, text: string, extra?: object): Promise; wizardDelete(ctx: Context): Promise; broadcast(ids: Array, message: any, opts?: { delay?: number }): Promise<{ terkirim: number; gagal: number; errors: Array<{ chatId: any; pesan: string }> }>; init(): Promise; launch(opts?: Record): Promise; handleUpdate(update: any): Promise; webhook(opts?: { secretToken?: string; maxBodyBytes?: number }): (req: any, res: any) => Promise; stop(): void; readonly runPromise?: Promise; } export { TeleBibz as Bot }; export function session(opts?: SessionOptions): Handler; export function btn(text: string, callbackData: string | number, style?: Color, iconId?: string): any; export function url(text: string, link: string, style?: Color, iconId?: string): any; export function webApp(text: string, link: string, iconId?: string): any; export function copy(text: string, value: string, iconId?: string): any; export function kb(rows: any[][]): { reply_markup: { inline_keyboard: any[][] } }; export namespace kb { function markup(rows: any[][]): { inline_keyboard: any[][] }; function confirm(yesData: string, noData: string, labelYes?: string, labelNo?: string): any; } export class InlineKeyboard { constructor(rows?: any[][]); text(text: string, data: string, style?: Color, iconId?: string): this; url(text: string, link: string, style?: Color, iconId?: string): this; webApp(text: string, link: string, iconId?: string): this; copy(text: string, value: string, iconId?: string): this; row(): this; build(): { reply_markup: { inline_keyboard: any[][] } }; } export class Keyboard { text(text: string): this; requestContact(text: string): this; requestLocation(text: string): this; row(): this; resized(value?: boolean): this; oneTime(value?: boolean): this; build(): any; } export class Menu extends Composer { constructor(id: string); text(label: string, handler?: Handler): this; url(label: string, link: string, opts?: object): this; webApp(label: string, link: string): this; submenu(label: string, targetId: string): this; back(label?: string, parentId?: string): this; row(): this; render(ctx: Context): Promise; } export class MenuContainer extends Composer { create(id: string): Menu; get(id: string): Menu | undefined; } export class File { constructor(src: any, filename?: string, type?: string); src: any; filename: string; type?: string; data(): Promise; } export class InputFile extends File {} export const InputMediaBuilder: { photo(media: any, extra?: object): any; video(media: any, extra?: object): any; livePhoto(media: any, photo: any, extra?: object): any; document(media: any, extra?: object): any; audio(media: any, extra?: object): any; animation(media: any, extra?: object): any; }; export const InputPaidMediaBuilder: { photo(media: any, extra?: object): any; video(media: any, extra?: object): any; livePhoto(media: any, photo: any, extra?: object): any; }; export class RichMessageBuilder { html(value: string): this; markdown(value: string): this; blocks(value?: InputRichBlock[]): this; add(...blocks: InputRichBlock[]): this; media(items: InputRichMessageMedia[]): this; rtl(value?: boolean): this; skipEntityDetection(value?: boolean): this; build(): InputRichMessage; buildDraft(): TelegramMethodPayload<'sendRichMessageDraft'>['rich_message']; } export const rich: { html(html: string, options?: Partial>): InputRichMessage; markdown(markdown: string, options?: Partial>): InputRichMessage; blocks(blocks: InputRichBlock[], options?: Partial>): InputRichMessage; draftHtml(html: string, options?: Partial>): TelegramMethodPayload<'sendRichMessageDraft'>['rich_message']; draftMarkdown(markdown: string, options?: Partial>): TelegramMethodPayload<'sendRichMessageDraft'>['rich_message']; draftBlocks(blocks: InputRichBlock[], options?: Partial>): TelegramMethodPayload<'sendRichMessageDraft'>['rich_message']; button(text: string, action: Record, style?: 'danger' | 'success' | 'primary' | 'link'): RichMessageButton; buttonText(text: string, action: Record, style?: 'danger' | 'success' | 'primary' | 'link'): RichTextButton; buttons(buttons: RichMessageButton[], align?: 'left' | 'center' | 'right'): InputRichBlockButtons; block(type: string, props?: Record): InputRichBlock; [builder: string]: (...args: any[]) => any; }; export function inputRichMessage(content: Partial>, options?: Partial>): InputRichMessage; export function makeApi(token: string, transport?: TeleBibzOptions['transport'], transportOpts?: TeleBibzOptions): ApiClient; export function createTransport(token: string, opts?: { apiRoot?: string; proxy?: string; timeoutMs?: number; headers?: Record }): TeleBibzOptions['transport']; export class ApiError extends Error { description: string; error_code?: number; method?: string; payload?: any; parameters: Record; } export function autoRetry(opts?: { maxRetry?: number; baseDelayMs?: number }): Function; export function throttler(opts?: { perSecond?: number }): Function; export function limiter(opts?: { windowMs?: number; limit?: number; onExceeded?: Handler }): Handler; export function broadcast(api: any, ids: Array, message: any, opts?: { delay?: number }): Promise; export function matchInlineQuery(trigger: string | RegExp): (ctx: Context) => boolean; export const iq: Record any>; export function humanize(error: unknown): { pesan: string; saran: string | null; method?: string; code?: number | string }; export const wizard: { define(id: string, def: WizardDef): string; get(id: string): WizardDef | undefined; start(ctx: Context, id: string): Promise; active(ctx: Context): boolean; cancel(ctx: Context): Promise; editAsk(ctx: Context, text: string, extra?: object): Promise; deleteAsk(ctx: Context): Promise; middleware(): Handler; KEY: string; }; export const log: { info(...args: any[]): void; ok(...args: any[]): void; warn(...args: any[]): void; error(...args: any[]): void; paint(code: string, text: unknown): string; banner(title: string, rows?: string[], developer?: string): void; }; export const say: { html(text: string, extra?: object): object };