UNPKG

1.41 kBTypeScriptView Raw
1import { MessageEntity, User } from '@telegraf/types';
2import { Any } from './util';
3export type Nestable<Kind extends string> = string | number | boolean | FmtString<Kind>;
4export type MaybeNestableList<Kind extends string> = Nestable<Kind> | readonly Nestable<Kind>[];
5export interface FmtString<Brand extends string> {
6 text: string;
7 entities?: MessageEntity[];
8 parse_mode?: undefined;
9 __to_nest: Brand;
10}
11export declare class FmtString<Brand extends string = string> implements FmtString<Brand> {
12 text: string;
13 constructor(text: string, entities?: MessageEntity[]);
14 static normalise(content: Nestable<string>): FmtString<string>;
15}
16/**
17 * Given an `Iterable<FmtString | string | Any>` and a separator, flattens the list into a single FmtString.
18 * Analogous to Array#join -> string, but for FmtString
19 */
20export declare const join: (fragments: Iterable<FmtString | string | Any>, separator?: string | FmtString) => FmtString<string>;
21/** Internal constructor for all fmt helpers */
22export declare function createFmt(kind?: MessageEntity['type'], opts?: object): (parts: MaybeNestableList<string>, ...items: Nestable<string>[]) => FmtString<string>;
23export declare const linkOrMention: (content: Nestable<string>, data: {
24 type: 'text_link';
25 url: string;
26} | {
27 type: 'text_mention';
28 user: User;
29}) => FmtString<string>;
30//# sourceMappingURL=formatting.d.ts.map
\No newline at end of file