-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstants.js
More file actions
240 lines (232 loc) Β· 7.11 KB
/
constants.js
File metadata and controls
240 lines (232 loc) Β· 7.11 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
/**
* User interaction permissions levels.
*/
const Permissions = {
NONE: 0,
MEMBER: 1 << 0,
ADMIN: 1 << 1,
OWNER: 1 << 2,
ALL: (1 << 0) | (1 << 1) | (1 << 2),
};
/**
* This object represents an incoming update.
*/
class UpdateType {
static MESSAGE = "message";
static EDITED_MESSAGE = "edited_message";
static CHANNEL_POST = "channel_post";
static EDITED_CHANNEL_POST = "edited_channel_post";
static BUSINESS_CONNECTION = "business_connection";
static BUSINESS_MESSAGE = "business_message";
static EDITED_BUSINESS_MESSAGE = "edited_business_message";
static DELETED_BUSINESS_MESSAGE = "deleted_business_message";
static MESSAGE_REACTION = "message_reaction";
static MESSAGE_REACTION_COUNT = "message_reaction_count";
static INLINE_QUERY = "inline_query";
static CHOSEN_INLINE_RESULT = "chosen_inline_result";
static CALLBACK_QUERY = "callback_query";
static SHIPPING_QUERY = "shipping_query";
static PRE_CHECKOUT_QUERY = "pre_checkout_query";
static PURCHASED_PAID_MEDIA = "purchased_paid_media";
static POLL = "poll";
static MY_CHAT_MEMBER = "my_chat_member";
static CHAT_MEMBER = "chat_member";
static CHAT_JOIN_REQUEST = "chat_join_request";
static CHAT_BOOST = "chat_boost";
static REMOVED_CHAT_BOOST = "removed_chat_boost";
static ALL = Object.values(UpdateType).filter(value => typeof value === "string");
};
/**
* Tell the user that something is happening on the bot's side
*/
const ChatAction = {
/**
* `TYPING` for text messages.
*/
TYPING: "typing",
/**
* `upload_photo` for photos.
*/
UPLOAD_PHOTO: "upload_photo",
/**
* `record_video` or `upload_video` for videos.
*/
RECORD_VIDEO: "record_video",
/**
* `record_video` or `upload_video` for videos.
*/
UPLOAD_VIDEO: "upload_video",
/**
* `record_voice` or `upload_voice` for voice notes.
*/
RECORD_VOICE: "record_voice",
/**
* `record_voice` or `upload_voice` for voice notes.
*/
UPLOAD_VOICE: "upload_voice",
/**
* `upload_document` for general files.
*/
UPLOAD_DOCUMENT: "upload_document",
/**
* `choose_sticker` for stickers.
*/
CHOOSE_STICKER: "choose_sticker",
/**
* `find_location` for location data.
*/
FIND_LOCATION: "find_location",
/**
* `record_video_note` or `upload_video_note` for video notes.
*/
RECORD_VOICE_NOTE: "record_video_note",
/**
* `record_video_note` or `upload_video_note` for video notes.
*/
UPLOAD_VOICE_NOTE: "upload_video_note"
};
/**
* Parse mode determines how the text in messages is formatted.
*/
const ParseMode = {
/**
* Use HTML tags. Only the following are allowed:
*
* `b`, `i`, `code`, `pre`, `a href`, `s`, `del`, `u`, `span class="tg-spoiler"`, `tg-spoiler`, `tg-emoji emoji-id`, `pre code class="language-{language}"`, `blockquote`, `blockquote expandable`.
*
* @see {@link https://core.telegram.org/bots/api#html-style|**Telegram Bot API**}
*/
HTML: "HTML",
/**
* Use Markdown. Only the following are allowed:
*
* - \*\*: bold
* - _ _: italic
* - [url]\(https://\): inline url
* - \`\`: inline fixed-width code
* - \`\`\` \`\`\`: pre-formatted fixed-width code (you can specify the language).
*
* Note that escaping is __not__ allowed inside entities, so they must be opened and closed first.
* @see {@link https://core.telegram.org/bots/api#markdown-style|**Telegram Bot API**}
*/
Markdown: "Markdown",
/**
* Use Markdown V2. Only the following are allowed:
* - \*\*: bold
* - _ _: italic
* - __ __: underline
* - ~ ~: strikethrough
* - || ||: spoiler
* - [url]\(https://\): inline url
* - ![emoji]\(tg://emoji?id=\): emoji
* - \`\`: inline fixed-width code
* - \`\`\` \`\`\`: pre-formatted fixed-width code (you can specify the language).
* - \>: blockquote
* - \*\*\> ||: expandable blockquote (end with double line, you can write on multiple lines with \>).
*
* Any character with code between 1 and 126 in markdown V2 can be escaped with the \\ character.
*
* @see {@link https://www.eso.org/~ndelmott/ascii.html|**ASCII Character Chart**}
* @see {@link https://core.telegram.org/bots/api#markdownv2-style|**Telegram Bot API**}
*/
MarkdownV2: "MarkdownV2"
};
/**
* Message filters.
*/
class Filters {
/**
* @param {number} NONE - No filters.
*/
static NONE = 0;
/**
* @param {number} TEXT - Represent a text message.
*/
static TEXT = 1 << 0;
/**
* @param {number} PHOTO - Represent a message containing a photo.
*/
static PHOTO = 1 << 1;
/**
* @param {number} VIDEO - Represent a message containing a video.
*/
static VIDEO = 1 << 2;
/**
* @param {number} DOCUMENT - Represent a message containing a document.
*/
static DOCUMENT = 1 << 3;
/**
* @param {number} COMMAND - Represent a message starting with a command (e.g. `/command TEXT`).
*/
static COMMAND = 1 << 4;
/**
* @param {number} MEDIA_GROUP - Represent a message containing a media group.
*/
static MEDIA_GROUP = 1 << 5;
/**
* @param {number} FORWARDED - Represent a forwarded message.
*/
static FORWARDED = 1 << 6;
/**
* @param {number} NEW_CHAT_MEMBERS - Represents new chat members.
*/
static NEW_CHAT_MEMBERS = 1 << 7;
/**
* @param {number} LEFT_CHAT_MEMBER - Represents a chat member that left.
*/
static LEFT_CHAT_MEMBER = 1 << 8;
/**
* @param {number} ALL - Represent any kind of message.
*/
static ALL = Filters.TEXT | Filters.PHOTO | Filters.VIDEO | Filters.DOCUMENT | Filters.COMMAND | Filters.MEDIA_GROUP | Filters.FORWARDED | Filters.NEW_CHAT_MEMBERS | Filters.LEFT_CHAT_MEMBER;
/**
* Regex pattern.
* @param {RegExp} pattern
* @returns
*/
static regex(pattern) {
return (update) => {
if (!update.message || typeof update.message.text !== 'string') {
return false;
}
return pattern.test(update.message.text);
};
}
}
/**
* Message effect IDs that show up when the message is received.
*/
const MessageEffect = {
/**
* π₯ Fire animation.
*/
FIRE: "5104841245755180586",
/**
* ππ» Thumbs up animation.
*/
THUMBS_UP: "5107584321108051014",
/**
* β€οΈ Hearts animation.
*/
HEART: "5159385139981059251",
/**
* π Party animation.
*/
PARTY: "5046509860389126442",
/**
* ππ» Thumbs down animation.
*/
THUMBS_DOWN: "5104858069142078462",
/**
* π© Poop animation.
*/
POOP: "5046589136895476101"
}
export {
ChatAction,
ParseMode,
MessageEffect,
Filters,
Permissions,
UpdateType
}