forked from telegraf/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 6
/
extra.js
94 lines (73 loc) · 1.63 KB
/
extra.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const Markup = require('./markup')
class Extra {
constructor (opts) {
this.load(opts)
}
load (opts = {}) {
return Object.assign(this, opts)
}
inReplyTo (messageId) {
this.reply_to_message_id = messageId
return this
}
notifications (value = true) {
this.disable_notification = !value
return this
}
webPreview (value = true) {
this.disable_web_page_preview = !value
return this
}
markup (markup) {
if (typeof markup === 'function') {
markup = markup(new Markup())
}
this.reply_markup = { ...markup }
return this
}
HTML (value = true) {
this.parse_mode = value ? 'HTML' : undefined
return this
}
markdown (value = true) {
this.parse_mode = value ? 'Markdown' : undefined
return this
}
markdownV2 (value = true) {
this.parse_mode = value ? 'MarkdownV2' : undefined
return this
}
caption (caption = '') {
this.caption = caption
return this
}
static inReplyTo (messageId) {
return new Extra().inReplyTo(messageId)
}
static notifications (value) {
return new Extra().notifications(value)
}
static webPreview (value) {
return new Extra().webPreview(value)
}
static load (opts) {
return new Extra(opts)
}
static markup (markup) {
return new Extra().markup(markup)
}
static HTML (value) {
return new Extra().HTML(value)
}
static markdown (value) {
return new Extra().markdown(value)
}
static markdownV2 (value) {
return new Extra().markdownV2(value)
}
static caption (caption) {
return new Extra().caption(caption)
}
}
Extra.Markup = Markup
module.exports = Extra