import type { MessageEntity, User } from "./telegram-types.js"; /** * formatting without `parse_mode`: tagged template literals that build proper * `MessageEntity` objects, so there is nothing to escape (the GramIO idea). */ export interface FormatResult { text: string; entities: MessageEntity[]; } /** a piece of text that carries its own entities, used inside `format`. */ export declare class Stringable implements FormatResult { readonly text: string; readonly entities: MessageEntity[]; constructor(text: string, entities?: MessageEntity[]); } /** * anything a `format` interpolation (or a helper argument) accepts. `null`, * `undefined` and booleans render as empty text, so `${cond && bold("on")}` * just works; numbers and bigints render via `String()`. */ export type Insertable = FormatResult | string | number | bigint | boolean | null | undefined; export declare function isFormatResult(value: unknown): value is FormatResult; /** stitches the literal parts and interpolations into one `{ text, entities }`. */ export declare function format(strings: TemplateStringsArray, ...subs: Insertable[]): FormatResult; /** an entity helper callable both as `bold("hi")` (nestable) and as a tag: `` bold`hi ${italic("!")}` ``. */ export interface Formatter { (value: Insertable): Stringable; (strings: TemplateStringsArray, ...subs: Insertable[]): Stringable; } export declare const bold: Formatter; export declare const italic: Formatter; export declare const underline: Formatter; export declare const strikethrough: Formatter; export declare const spoiler: Formatter; export declare const code: Formatter; export declare const blockquote: Formatter; export declare const expandableBlockquote: Formatter; /** a `pre` block; pass the language telegram should highlight: `pre(src, "ts")`. */ export declare function pre(value: Insertable, language?: string): Stringable; export declare function link(text: Insertable, url: string): Stringable; export declare function mention(text: Insertable, user: User | { id: number; }): Stringable; /** an inline custom emoji; `fallback` is the plain emoji shown to clients that can't render it. */ export declare function customEmoji(fallback: Insertable, customEmojiId: string): Stringable; /** * a date/time entity — telegram renders the timestamp in the reader's locale and * timezone. `dateTimeFormat` follows the Bot API `date_time` format string * (`"r"` relative, `"d"`/`"D"` short/long date, `"t"`/`"T"` short/long time, `"w"` * weekday — combinable like `"wDt"`); empty/omitted shows `text` as-is. */ export declare function dateTime(text: Insertable, unixTime: number, dateTimeFormat?: string): Stringable; /** * join formatted pieces with a separator, keeping entities — `[].join()` would * stringify them away. items that render to empty text (`null`, `undefined`, * booleans, `""`) are skipped, so `join(items.map((x) => cond && bold(x)))` * never leaves a dangling separator. */ export declare function join(items: Insertable[], separator?: Insertable): FormatResult; export declare function join(items: T[], iterator: (item: T, index: number) => Insertable, separator?: Insertable): FormatResult; //# sourceMappingURL=format.d.ts.map