1 | import { User } from '@telegraf/types'
|
2 | import { FmtString, _fmt, linkOrMention, join } from './core/helpers/formatting'
|
3 |
|
4 | export { FmtString }
|
5 |
|
6 | const fmt = _fmt()
|
7 | const bold = _fmt('bold')
|
8 | const italic = _fmt('italic')
|
9 | const spoiler = _fmt('spoiler')
|
10 | const strikethrough = _fmt('strikethrough')
|
11 | const underline = _fmt('underline')
|
12 | const code = _fmt('code')
|
13 | const pre = (language: string) => _fmt('pre', { language })
|
14 |
|
15 | const link = (content: string | FmtString, url: string) =>
|
16 | linkOrMention(content, { type: 'text_link', url })
|
17 |
|
18 | const 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 |
|
23 | export {
|
24 | fmt,
|
25 | bold,
|
26 | italic,
|
27 | spoiler,
|
28 | strikethrough,
|
29 | underline,
|
30 | code,
|
31 | pre,
|
32 | link,
|
33 | mention,
|
34 | join,
|
35 | }
|