UNPKG

843 BPlain TextView Raw
1import { User } from '@telegraf/types'
2import { FmtString, _fmt, linkOrMention, join } from './core/helpers/formatting'
3
4export { FmtString }
5
6const fmt = _fmt()
7const bold = _fmt('bold')
8const italic = _fmt('italic')
9const spoiler = _fmt('spoiler')
10const strikethrough = _fmt('strikethrough')
11const underline = _fmt('underline')
12const code = _fmt('code')
13const pre = (language: string) => _fmt('pre', { language })
14
15const link = (content: string | FmtString, url: string) =>
16 linkOrMention(content, { type: 'text_link', url })
17
18const mention = (name: string | FmtString, user: number | User) =>
19 typeof user === 'number'
20 ? link(name, 'tg://user?id=' + user)
21 : linkOrMention(name, { type: 'text_mention', user })
22
23export {
24 fmt,
25 bold,
26 italic,
27 spoiler,
28 strikethrough,
29 underline,
30 code,
31 pre,
32 link,
33 mention,
34 join,
35}