@mtkruto/node 0.78.0 → 0.79.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/esm/0_errors.d.ts +1 -0
  2. package/esm/0_errors.d.ts.map +1 -1
  3. package/esm/0_errors.js +5 -0
  4. package/esm/3_types.d.ts +3 -0
  5. package/esm/3_types.d.ts.map +1 -1
  6. package/esm/3_types.js +3 -0
  7. package/esm/4_constants.d.ts +1 -0
  8. package/esm/4_constants.d.ts.map +1 -1
  9. package/esm/4_constants.js +2 -0
  10. package/esm/5_client.d.ts +6 -1
  11. package/esm/5_client.d.ts.map +1 -1
  12. package/esm/5_client.js +6 -1
  13. package/esm/_dnt.polyfills.d.ts +13 -13
  14. package/esm/_dnt.polyfills.d.ts.map +1 -1
  15. package/esm/_dnt.polyfills.js +11 -11
  16. package/esm/client/0_worker_request.d.ts +26 -0
  17. package/esm/client/0_worker_request.d.ts.map +1 -0
  18. package/esm/client/0_worker_request.js +20 -0
  19. package/esm/client/0_worker_response.d.ts +39 -0
  20. package/esm/client/0_worker_response.d.ts.map +1 -0
  21. package/esm/client/0_worker_response.js +20 -0
  22. package/esm/client/1_client_generic.d.ts +1602 -0
  23. package/esm/client/1_client_generic.d.ts.map +1 -0
  24. package/esm/client/1_client_generic.js +24 -0
  25. package/esm/client/2_account_manager.d.ts +6 -1
  26. package/esm/client/2_account_manager.d.ts.map +1 -1
  27. package/esm/client/2_account_manager.js +84 -0
  28. package/esm/client/2_context.d.ts +114 -0
  29. package/esm/client/2_context.d.ts.map +1 -0
  30. package/esm/client/2_context.js +453 -0
  31. package/esm/client/2_file_manager.d.ts.map +1 -1
  32. package/esm/client/2_file_manager.js +3 -4
  33. package/esm/client/2_sign_in.d.ts +25 -0
  34. package/esm/client/2_sign_in.d.ts.map +1 -0
  35. package/esm/client/2_sign_in.js +114 -0
  36. package/esm/client/{0_filters.d.ts → 3_filters.d.ts} +6 -3
  37. package/esm/client/3_filters.d.ts.map +1 -0
  38. package/esm/client/3_filters_test.d.ts.map +1 -0
  39. package/esm/client/{1_composer.d.ts → 4_composer.d.ts} +12 -11
  40. package/esm/client/4_composer.d.ts.map +1 -0
  41. package/esm/client/{1_composer.js → 4_composer.js} +17 -7
  42. package/esm/client/4_composer_test.d.ts.map +1 -0
  43. package/esm/client/5_client.d.ts +43 -179
  44. package/esm/client/5_client.d.ts.map +1 -1
  45. package/esm/client/5_client.js +141 -595
  46. package/esm/client/5_client_dispatcher.d.ts +1660 -0
  47. package/esm/client/5_client_dispatcher.d.ts.map +1 -0
  48. package/esm/client/5_client_dispatcher.js +2141 -0
  49. package/esm/client/6_client_worker.d.ts +27 -0
  50. package/esm/client/6_client_worker.d.ts.map +1 -0
  51. package/esm/client/6_client_worker.js +51 -0
  52. package/esm/types/0_bot_token_check_result.d.ts +29 -0
  53. package/esm/types/0_bot_token_check_result.d.ts.map +1 -0
  54. package/esm/types/0_bot_token_check_result.js +20 -0
  55. package/esm/types/0_code_check_result.d.ts +37 -0
  56. package/esm/types/0_code_check_result.d.ts.map +1 -0
  57. package/esm/types/0_code_check_result.js +20 -0
  58. package/esm/types/0_password_check_result.d.ts +33 -0
  59. package/esm/types/0_password_check_result.d.ts.map +1 -0
  60. package/esm/types/0_password_check_result.js +20 -0
  61. package/package.json +1 -1
  62. package/script/0_errors.d.ts +1 -0
  63. package/script/0_errors.d.ts.map +1 -1
  64. package/script/0_errors.js +5 -0
  65. package/script/3_types.d.ts +3 -0
  66. package/script/3_types.d.ts.map +1 -1
  67. package/script/3_types.js +3 -0
  68. package/script/4_constants.d.ts +1 -0
  69. package/script/4_constants.d.ts.map +1 -1
  70. package/script/4_constants.js +3 -1
  71. package/script/5_client.d.ts +6 -1
  72. package/script/5_client.d.ts.map +1 -1
  73. package/script/5_client.js +6 -1
  74. package/script/_dnt.polyfills.d.ts +13 -13
  75. package/script/_dnt.polyfills.d.ts.map +1 -1
  76. package/script/_dnt.polyfills.js +11 -11
  77. package/script/client/0_worker_request.d.ts +26 -0
  78. package/script/client/0_worker_request.d.ts.map +1 -0
  79. package/script/client/0_worker_request.js +21 -0
  80. package/script/client/0_worker_response.d.ts +39 -0
  81. package/script/client/0_worker_response.d.ts.map +1 -0
  82. package/script/client/0_worker_response.js +21 -0
  83. package/script/client/1_client_generic.d.ts +1602 -0
  84. package/script/client/1_client_generic.d.ts.map +1 -0
  85. package/script/client/1_client_generic.js +28 -0
  86. package/script/client/2_account_manager.d.ts +6 -1
  87. package/script/client/2_account_manager.d.ts.map +1 -1
  88. package/script/client/2_account_manager.js +84 -0
  89. package/script/client/2_context.d.ts +114 -0
  90. package/script/client/2_context.d.ts.map +1 -0
  91. package/script/client/2_context.js +457 -0
  92. package/script/client/2_file_manager.d.ts.map +1 -1
  93. package/script/client/2_file_manager.js +2 -3
  94. package/script/client/2_sign_in.d.ts +25 -0
  95. package/script/client/2_sign_in.d.ts.map +1 -0
  96. package/script/client/2_sign_in.js +118 -0
  97. package/script/client/{0_filters.d.ts → 3_filters.d.ts} +6 -3
  98. package/script/client/3_filters.d.ts.map +1 -0
  99. package/script/client/3_filters_test.d.ts.map +1 -0
  100. package/script/client/{1_composer.d.ts → 4_composer.d.ts} +12 -11
  101. package/script/client/4_composer.d.ts.map +1 -0
  102. package/script/client/{1_composer.js → 4_composer.js} +17 -7
  103. package/script/client/4_composer_test.d.ts.map +1 -0
  104. package/script/client/5_client.d.ts +43 -179
  105. package/script/client/5_client.d.ts.map +1 -1
  106. package/script/client/5_client.js +140 -594
  107. package/script/client/5_client_dispatcher.d.ts +1660 -0
  108. package/script/client/5_client_dispatcher.d.ts.map +1 -0
  109. package/script/client/5_client_dispatcher.js +2178 -0
  110. package/script/client/6_client_worker.d.ts +27 -0
  111. package/script/client/6_client_worker.d.ts.map +1 -0
  112. package/script/client/6_client_worker.js +55 -0
  113. package/script/types/0_bot_token_check_result.d.ts +29 -0
  114. package/script/types/0_bot_token_check_result.d.ts.map +1 -0
  115. package/script/types/0_bot_token_check_result.js +21 -0
  116. package/script/types/0_code_check_result.d.ts +37 -0
  117. package/script/types/0_code_check_result.d.ts.map +1 -0
  118. package/script/types/0_code_check_result.js +21 -0
  119. package/script/types/0_password_check_result.d.ts +33 -0
  120. package/script/types/0_password_check_result.d.ts.map +1 -0
  121. package/script/types/0_password_check_result.js +21 -0
  122. package/esm/client/0_filters.d.ts.map +0 -1
  123. package/esm/client/0_filters_test.d.ts.map +0 -1
  124. package/esm/client/1_composer.d.ts.map +0 -1
  125. package/script/client/0_filters.d.ts.map +0 -1
  126. package/script/client/0_filters_test.d.ts.map +0 -1
  127. package/script/client/1_composer.d.ts.map +0 -1
  128. /package/esm/client/{0_filters.js → 3_filters.js} +0 -0
  129. /package/script/client/{0_filters.js → 3_filters.js} +0 -0
@@ -0,0 +1,2141 @@
1
+ /**
2
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
+ * Copyright (C) 2023-2026 Roj <https://roj.im/>
4
+ *
5
+ * This file is part of MTKruto.
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ */
20
+ import { getLogger } from "../1_utilities.js";
21
+ import { DOWNLOAD_MAX_CHUNK_SIZE } from "../4_constants.js";
22
+ import * as errors from "../4_errors.js";
23
+ import { Composer } from "./4_composer.js";
24
+ import { signIn } from "./2_sign_in.js";
25
+ export class ClientDispatcher extends Composer {
26
+ #worker;
27
+ #id;
28
+ #L;
29
+ #LsignIn;
30
+ // deno-lint-ignore no-explicit-any
31
+ #pendingRequests = new Array();
32
+ constructor(worker, id) {
33
+ super();
34
+ this.#worker = worker;
35
+ this.#id = id;
36
+ this.#L = getLogger("ClientController").branch(this.#id + "");
37
+ this.#LsignIn = this.#L.branch("signIn");
38
+ }
39
+ /** @internal */
40
+ async handleResponse(response) {
41
+ if (response.clientId !== this.#id) {
42
+ return;
43
+ }
44
+ this.#L.debug("handling response message", response);
45
+ if (response.isError) {
46
+ this.#pendingRequests[response.id]?.reject(this.#constructError(response.data));
47
+ }
48
+ else {
49
+ if (response.id === -1) {
50
+ try {
51
+ await this.handleUpdate(this, response.data);
52
+ }
53
+ catch (err) {
54
+ this.#L.error("Error handling update:", err);
55
+ }
56
+ }
57
+ else {
58
+ this.#pendingRequests[response.id]?.resolve(response.data);
59
+ }
60
+ }
61
+ // clean up pending requests
62
+ if (response.id === 0) {
63
+ this.#pendingRequests.shift();
64
+ }
65
+ else if (response.id === this.#pendingRequests.length - 1) {
66
+ this.#pendingRequests.pop();
67
+ }
68
+ }
69
+ #constructError(error) {
70
+ switch (error.name) {
71
+ case "TelegramError":
72
+ return errors.constructTelegramError({
73
+ _: "rpc_error",
74
+ error_code: error.args[0].error_code,
75
+ error_message: error.args[0].error_message,
76
+ }, error.args.call);
77
+ case "ConnectionError":
78
+ return new errors.ConnectionError(error.args[0]);
79
+ case "AccessError":
80
+ return new errors.AccessError(error.args[0]);
81
+ case "InputError":
82
+ return new errors.InputError(error.args[0]);
83
+ case "TransportError":
84
+ return new errors.TransportError(error.args[0]);
85
+ case "TLError":
86
+ return new errors.TLError(error.args[0], error.args[1]);
87
+ default:
88
+ return new TypeError("Unknown error");
89
+ }
90
+ }
91
+ get id() {
92
+ return this.#id;
93
+ }
94
+ async #dispatch(method, ...args) {
95
+ // deno-lint-ignore no-explicit-any
96
+ const promiseWithResolvers = Promise.withResolvers();
97
+ const index = this.#pendingRequests.push(promiseWithResolvers) - 1;
98
+ const request = {
99
+ clientId: this.#id,
100
+ id: index,
101
+ method,
102
+ args,
103
+ };
104
+ this.#L.debug("posted message to worker", request);
105
+ this.#worker.postMessage(request);
106
+ return await promiseWithResolvers.promise;
107
+ }
108
+ #isInited = false;
109
+ async init(params) {
110
+ if (this.#isInited) {
111
+ return;
112
+ }
113
+ this.#isInited = true;
114
+ return await this.#dispatch("initClient", params);
115
+ }
116
+ async connect() {
117
+ return await this.#dispatch("connect");
118
+ }
119
+ async disconnect() {
120
+ return await this.#dispatch("disconnect");
121
+ }
122
+ async start(params) {
123
+ await this.connect();
124
+ await this.signIn(params);
125
+ }
126
+ /**
127
+ * Send a user verification code.
128
+ *
129
+ * @param phoneNumber The phone number to send the code to.
130
+ * @method ac
131
+ */
132
+ async sendCode(phoneNumber) {
133
+ return await this.#dispatch("sendCode", phoneNumber);
134
+ }
135
+ /**
136
+ * Check if a code entered by the user was the same as the verification code.
137
+ *
138
+ * @param code A code entered by the user.
139
+ * @method ac
140
+ */
141
+ async checkCode(code) {
142
+ return await this.#dispatch("checkCode", code);
143
+ }
144
+ /**
145
+ * Get the user account password's hint.
146
+ *
147
+ * @method ac
148
+ */
149
+ async getPasswordHint() {
150
+ return await this.#dispatch("getPasswordHint");
151
+ }
152
+ /**
153
+ * Check whether a password entered by the user is the same as the account's one.
154
+ *
155
+ * @param password The password to check
156
+ * @returns The result of the check.
157
+ */
158
+ async checkPassword(password) {
159
+ return await this.#dispatch("checkPassword", password);
160
+ }
161
+ /**
162
+ * Check whether a bot token is valid.
163
+ *
164
+ * @param password The password to check
165
+ * @returns The result of the check.
166
+ */
167
+ async checkBotToken(botToken) {
168
+ return await this.#dispatch("checkBotToken", botToken);
169
+ }
170
+ /**
171
+ * Signs in using the provided parameters if not already signed in.
172
+ * If no parameters are provided, the credentials will be prompted in runtime.
173
+ *
174
+ * Notes:
175
+ * 1. Requires the `apiId` and `apiHash` paramters to be passed when constructing the client.
176
+ * 3. Reconnects the client to the appropriate DC in case of MIGRATE_X errors.
177
+ */
178
+ async signIn(params) {
179
+ await signIn(this, this.#LsignIn, params);
180
+ }
181
+ async signOut() {
182
+ return await this.#dispatch("signOut");
183
+ }
184
+ async exportAuthString() {
185
+ return await this.#dispatch("exportAuthString");
186
+ }
187
+ async importAuthString(authString) {
188
+ return await this.#dispatch("importAuthString", authString);
189
+ }
190
+ /**
191
+ * Get a chat's inputPeer. Useful when calling API functions directly.
192
+ *
193
+ * @param id The identifier of a chat.
194
+ */
195
+ async getInputPeer(id) {
196
+ return await this.#dispatch("getInputPeer", id);
197
+ }
198
+ /**
199
+ * Get a channel or a supergroup's inputChannel. Useful when calling API functions directly.
200
+ *
201
+ * @param id The identifier of the channel or the supergroup.
202
+ */
203
+ async getInputChannel(id) {
204
+ return await this.#dispatch("getInputChannel", id);
205
+ }
206
+ /**
207
+ * Get a user's inputUser. Useful when calling API functions directly.
208
+ *
209
+ * @param id The identifier of the user.
210
+ */
211
+ async getInputUser(id) {
212
+ return await this.#dispatch("getInputUser", id);
213
+ }
214
+ //
215
+ // ========================= ACCOUNT ========================= //
216
+ //
217
+ /**
218
+ * Get information on the currently authorized user.
219
+ *
220
+ * @method ac
221
+ * @returns Information on the currently authorized user.
222
+ */
223
+ async getMe() {
224
+ return await this.#dispatch("getMe");
225
+ }
226
+ /**
227
+ * Show a username in the current account, a bot account, a supergroup, or a channel's profile. User-only.
228
+ *
229
+ * @method ac
230
+ * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
231
+ * @param username The username to show.
232
+ */
233
+ async showUsername(id, username) {
234
+ return await this.#dispatch("showUsername", id, username);
235
+ }
236
+ /**
237
+ * Hide a username from the current account, a bot account, a supergroup, or a channel's profile. User-only.
238
+ *
239
+ * @method ac
240
+ * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
241
+ * @param username The username to hide.
242
+ */
243
+ async hideUsername(id, username) {
244
+ return await this.#dispatch("hideUsername", id, username);
245
+ }
246
+ /**
247
+ * Reorder the usernames of the current account, a bot account, a supergroup, or a channel's profile. User-only.
248
+ *
249
+ * @method ac
250
+ * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
251
+ * @param order The new order to use.
252
+ * @returns Whether the order was changed.
253
+ */
254
+ async reorderUsernames(id, order) {
255
+ return await this.#dispatch("reorderUsernames", id, order);
256
+ }
257
+ /**
258
+ * Hide all usernames from a supergroup or a channel's profile. User-only.
259
+ *
260
+ * @method ac
261
+ * @param id A supergroup ID or a channel ID.
262
+ * @returns Whether any username was hidden.
263
+ */
264
+ async hideUsernames(id) {
265
+ return await this.#dispatch("hideUsernames", id);
266
+ }
267
+ /**
268
+ * Get a business connection. Bot-only.
269
+ *
270
+ * @method ac
271
+ * @param id The identifier of the business connection.
272
+ * @cache
273
+ */
274
+ async getBusinessConnection(id) {
275
+ return await this.#dispatch("getBusinessConnection", id);
276
+ }
277
+ /**
278
+ * Set the current account's online status. User-only.
279
+ *
280
+ * @method ac
281
+ * @param online The new online status.
282
+ */
283
+ async setOnline(online) {
284
+ return await this.#dispatch("setOnline", online);
285
+ }
286
+ /**
287
+ * Set the current account's emoji status. User-only.
288
+ *
289
+ * @method ac
290
+ * @param id The identifier of the emoji to be used as the new status.
291
+ */
292
+ async setEmojiStatus(id, params) {
293
+ return await this.#dispatch(id, params);
294
+ }
295
+ /**
296
+ * Set the emoji status of a bot's user. Bot-only.
297
+ *
298
+ * @method ac
299
+ * @param userId The identifier of a user of the bot.
300
+ * @param id The identifier of the emoji to be used as the new status.
301
+ */
302
+ async setUserEmojiStatus(userId, id, params) {
303
+ return await this.#dispatch("setUserEmojiStatus", userId, id, params);
304
+ }
305
+ /**
306
+ * Update the profile of the current user. At least one parameter must be specified. User-only.
307
+ *
308
+ * @method ac
309
+ */
310
+ async updateProfile(params) {
311
+ return await this.#dispatch("updateProfile", params);
312
+ }
313
+ /**
314
+ * Set the birthday of the current user. User-only.
315
+ *
316
+ * @method ac
317
+ */
318
+ async setBirthday(params) {
319
+ return await this.#dispatch("setBirthday", params);
320
+ }
321
+ /**
322
+ * Set the personal channel of the current user. User-only.
323
+ *
324
+ * @method ac
325
+ */
326
+ async setPersonalChannel(params) {
327
+ return await this.#dispatch("setPersonalChannel", params);
328
+ }
329
+ /**
330
+ * Set the name color of the current user. User-only.
331
+ *
332
+ * @method ac
333
+ * @param color The identifier of the color to set.
334
+ */
335
+ async setNameColor(color, params) {
336
+ return await this.#dispatch("setNameColor", color, params);
337
+ }
338
+ /**
339
+ * Set the profile color of the current user. User-only.
340
+ *
341
+ * @method ac
342
+ * @param color The identifier of the color to set.
343
+ */
344
+ async setProfileColor(color, params) {
345
+ return await this.#dispatch("setProfileColor", color, params);
346
+ }
347
+ /**
348
+ * Set the location of the current user. User-only.
349
+ *
350
+ * @method ac
351
+ */
352
+ async setLocation(params) {
353
+ return await this.#dispatch("setLocation", params);
354
+ }
355
+ //
356
+ // ========================= MESSAGES ========================= //
357
+ //
358
+ /**
359
+ * Send a text message.
360
+ *
361
+ * @method ms
362
+ * @param chatId The identifier of a chat to send the message to.
363
+ * @param text The message's text.
364
+ * @returns The sent text message.
365
+ */
366
+ async sendMessage(chatId, text, params) {
367
+ return await this.#dispatch("sendMessage", chatId, text, params);
368
+ }
369
+ /**
370
+ * Send a photo.
371
+ *
372
+ * @method ms
373
+ * @param chatId The identifier of a chat to send the photo to.
374
+ * @param photo The photo to send.
375
+ * @returns The sent photo.
376
+ */
377
+ async sendPhoto(chatId, photo, params) {
378
+ return await this.#dispatch("sendPhoto", chatId, photo, params);
379
+ }
380
+ /**
381
+ * Send a document.
382
+ *
383
+ * @method ms
384
+ * @param chatId The identifier of a chat to send the document to.
385
+ * @param document The document to send.
386
+ * @returns The sent document.
387
+ */
388
+ async sendDocument(chatId, document, params) {
389
+ return await this.#dispatch("sendDocument", chatId, document, params);
390
+ }
391
+ /**
392
+ * Send a sticker.
393
+ *
394
+ * @method ms
395
+ * @param chatId The identifier of a chat to send the sticker to.
396
+ * @param document The sticker to send.
397
+ * @returns The sent sticker.
398
+ */
399
+ async sendSticker(chatId, sticker, params) {
400
+ return await this.#dispatch("sendSticker", chatId, sticker, params);
401
+ }
402
+ /**
403
+ * Send a video.
404
+ *
405
+ * @method ms
406
+ * @param chatId The identifier of a chat to send the video to.
407
+ * @param video The video to send.
408
+ * @returns The sent video.
409
+ */
410
+ async sendVideo(chatId, video, params) {
411
+ return await this.#dispatch("sendVideo", chatId, video, params);
412
+ }
413
+ /**
414
+ * Send an animation.
415
+ *
416
+ * @method ms
417
+ * @param chatId The identifier of a chat to send the animation to.
418
+ * @param animation The animation to send.
419
+ * @returns The sent animation.
420
+ */
421
+ async sendAnimation(chatId, animation, params) {
422
+ return await this.#dispatch("sendAnimation", chatId, animation, params);
423
+ }
424
+ /**
425
+ * Send a voice message.
426
+ *
427
+ * @method ms
428
+ * @param chatId The identifier of a chat to send the voice message to.
429
+ * @param voice The voice to send.
430
+ * @returns The sent voice message.
431
+ */
432
+ async sendVoice(chatId, voice, params) {
433
+ return await this.#dispatch("sendVoice", chatId, voice, params);
434
+ }
435
+ /**
436
+ * Send an audio file.
437
+ *
438
+ * @method ms
439
+ * @param chatId The identifier of a chat to send the audio file to.
440
+ * @param audio The audio to send.
441
+ * @returns The sent audio file.
442
+ */
443
+ async sendAudio(chatId, audio, params) {
444
+ return await this.#dispatch("sendAudio", chatId, audio, params);
445
+ }
446
+ /**
447
+ * Send a media group.
448
+ *
449
+ * @method ms
450
+ * @param chatId The identifier of a chat to send the media group to.
451
+ * @param media The media to include in the media group. Animations are not allowed. All of them must be of the same media type, but an exception is that photos and videos can be mixed.
452
+ * @returns The sent messages.
453
+ */
454
+ async sendMediaGroup(chatId, media, params) {
455
+ return await this.#dispatch("sendMediaGroup", chatId, media, params);
456
+ }
457
+ /**
458
+ * Send a video note.
459
+ *
460
+ * @method ms
461
+ * @param chatId The identifier of a chat to send the video note to.
462
+ * @param videoNote The video note to send.
463
+ * @returns The sent video note.
464
+ */
465
+ async sendVideoNote(chatId, videoNote, params) {
466
+ return await this.#dispatch("sendVideoNote", chatId, videoNote, params);
467
+ }
468
+ /**
469
+ * Send a location.
470
+ *
471
+ * @method ms
472
+ * @param chatId The identifier of a chat to send the location to.
473
+ * @param latitude The location's latitude.
474
+ * @param longitude The location's longitude.
475
+ * @returns The sent location.
476
+ */
477
+ async sendLocation(chatId, latitude, longitude, params) {
478
+ return await this.#dispatch("sendLocation", chatId, latitude, longitude, params);
479
+ }
480
+ /**
481
+ * Send a contact.
482
+ *
483
+ * @method ms
484
+ * @param chatId The identifier of a chat to send the contact to.
485
+ * @param firstName The contact's first name.
486
+ * @param number The contact's phone number.
487
+ * @returns The sent contact.
488
+ */
489
+ async sendContact(chatId, firstName, number, params) {
490
+ return await this.#dispatch("sendContact", chatId, firstName, number, params);
491
+ }
492
+ /**
493
+ * Send a dice.
494
+ *
495
+ * @method ms
496
+ * @param chatId The identifier of a chat to send the dice to.
497
+ * @returns The sent dice.
498
+ */
499
+ async sendDice(chatId, params) {
500
+ return await this.#dispatch("sendDice", chatId, params);
501
+ }
502
+ /**
503
+ * Send a venue.
504
+ *
505
+ * @method ms
506
+ * @param chatId The identifier of a chat to send the venue to.
507
+ * @param latitude The latitude of the venue.
508
+ * @param longitude The longitude of the venue.
509
+ * @param title The title of the venue.
510
+ * @param address The written address of the venue.
511
+ * @returns The sent venue.
512
+ */
513
+ async sendVenue(chatId, latitude, longitude, title, address, params) {
514
+ return await this.#dispatch("sendVenue", chatId, latitude, longitude, title, address, params);
515
+ }
516
+ /**
517
+ * Send a poll.
518
+ *
519
+ * @method ms
520
+ * @param chatId The identifier of a chat to send the poll to.
521
+ * @param question The poll's question.
522
+ * @param options The poll's options.
523
+ * @returns The sent poll.
524
+ */
525
+ async sendPoll(chatId, question, options, params) {
526
+ return await this.#dispatch("sendPoll", chatId, question, options, params);
527
+ }
528
+ /**
529
+ * Send an invoice. Bot-only.
530
+ *
531
+ * @method ms
532
+ * @param chatId The identifier of a chat to send the invoice to.
533
+ * @param title The invoice's title.
534
+ * @param description The invoice's description.
535
+ * @param payload The invoice's payload.
536
+ * @param currency The invoice's currency.
537
+ * @param prices The invoice's price tags.
538
+ * @returns The sent invoice.
539
+ */
540
+ async sendInvoice(chatId, title, description, payload, currency, prices, params) {
541
+ return await this.#dispatch("sendInvoice", chatId, title, description, payload, currency, prices, params);
542
+ }
543
+ /**
544
+ * Edit a message's text.
545
+ *
546
+ * @method ms
547
+ * @param chatId The identifier of the chat which the message belongs to.
548
+ * @param messageId The identifier of the message.
549
+ * @param text The new text of the message.
550
+ * @returns The edited text message.
551
+ */
552
+ async editMessageText(chatId, messageId, text, params) {
553
+ return await this.#dispatch("editMessageText", chatId, messageId, text, params);
554
+ }
555
+ /**
556
+ * Edit a message's caption.
557
+ *
558
+ * @method ms
559
+ * @param chatId The identifier of the chat which the message belongs to.
560
+ * @param messageId The identifier of the message.
561
+ * @param text The new caption of the message.
562
+ * @returns The edited message.
563
+ */
564
+ async editMessageCaption(chatId, messageId, params) {
565
+ return await this.#dispatch("editMessageCaption", chatId, messageId, params);
566
+ }
567
+ /**
568
+ * Edit a message's media.
569
+ *
570
+ * @method ms
571
+ * @param chatId The identifier of the chat which the message belongs to.
572
+ * @param messageId The identifier of the message.
573
+ * @param media The new media of the message.
574
+ * @returns The edited message.
575
+ */
576
+ async editMessageMedia(chatId, messageId, media, params) {
577
+ return await this.#dispatch("editMessageMedia", chatId, messageId, media, params);
578
+ }
579
+ /**
580
+ * Edit an inline message's media.
581
+ *
582
+ * @method ms
583
+ * @param inlineMessageId The identifier of the inline message.
584
+ * @param media The new media of the message.
585
+ */
586
+ async editInlineMessageMedia(inlineMessageId, media, params) {
587
+ return await this.#dispatch("editInlineMessageMedia", inlineMessageId, media, params);
588
+ }
589
+ /**
590
+ * Edit an inline message's text. Bot-only.
591
+ *
592
+ * @method ms
593
+ * @param inlineMessageId The identifier of the inline message.
594
+ * @param text The new text of the message.
595
+ */
596
+ async editInlineMessageText(inlineMessageId, text, params) {
597
+ return await this.#dispatch("editInlineMessageText", inlineMessageId, text, params);
598
+ }
599
+ /**
600
+ * Edit an inline message's caption. Bot-only.
601
+ *
602
+ * @method ms
603
+ * @param inlineMessageId The identifier of the inline message.
604
+ */
605
+ async editInlineMessageCaption(inlineMessageId, params) {
606
+ return await this.#dispatch("editInlineMessageCaption", inlineMessageId, params);
607
+ }
608
+ /**
609
+ * Edit a message's reply markup.
610
+ *
611
+ * @method ms
612
+ * @param chatId The identifier of the chat which the message belongs to.
613
+ * @param messageId The identifier of the message.
614
+ * @returns The edited message.
615
+ */
616
+ async editMessageReplyMarkup(chatId, messageId, params) {
617
+ return await this.#dispatch("editMessageReplyMarkup", chatId, messageId, params);
618
+ }
619
+ /**
620
+ * Edit an inline message's reply markup. Bot-only.
621
+ *
622
+ * @method ms
623
+ * @param inlineMessageId The identifier of the inline message.
624
+ */
625
+ async editInlineMessageReplyMarkup(inlineMessageId, params) {
626
+ return await this.#dispatch("editInlineMessageReplyMarkup", inlineMessageId, params);
627
+ }
628
+ /**
629
+ * Edit a message's live location.
630
+ *
631
+ * @method ms
632
+ * @param chatId The identifier of the chat which the message belongs to.
633
+ * @param messageId The identifier of the message.
634
+ * @param latitude The new latitude.
635
+ * @param longitude The new longitude.
636
+ * @returns The edited location message.
637
+ */
638
+ async editMessageLiveLocation(chatId, messageId, latitude, longitude, params) {
639
+ return await this.#dispatch("editMessageLiveLocation", chatId, messageId, latitude, longitude, params);
640
+ }
641
+ /**
642
+ * Edit an inline message's live location. Bot-only.
643
+ *
644
+ * @method ms
645
+ * @param inlineMessageId The identifier of the inline message.
646
+ * @param latitude The new latitude.
647
+ * @param longitude The new longitude.
648
+ * @returns The edited location message.
649
+ */
650
+ async editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params) {
651
+ return await this.#dispatch("editInlineMessageLiveLocation", inlineMessageId, latitude, longitude, params);
652
+ }
653
+ /**
654
+ * Retrieve multiple messages.
655
+ *
656
+ * @method ms
657
+ * @param chatId The identifier of a chat to retrieve the messages from.
658
+ * @param messageIds The identifiers of the messages to retrieve.
659
+ * @example ```ts
660
+ * const message = await client.getMessages("@MTKruto", [210, 212]): Promise<void>;
661
+ * ```
662
+ * @returns The retrieved messages.
663
+ * @cache
664
+ */
665
+ async getMessages(chatId, messageIds) {
666
+ return await this.#dispatch("getMessages", chatId, messageIds);
667
+ }
668
+ /**
669
+ * Retrieve a single message.
670
+ *
671
+ * @method ms
672
+ * @param chatId The identifier of a chat.
673
+ * @param messageId The identifier of the message to retrieve.
674
+ * @example ```ts
675
+ * const message = await client.getMessage("@MTKruto", 212): Promise<void>;
676
+ * ```
677
+ * @returns The retrieved message.
678
+ * @cache
679
+ */
680
+ async getMessage(chatId, messageId) {
681
+ return await this.#dispatch("getMessage", chatId, messageId);
682
+ }
683
+ /**
684
+ * Retrieve a message using its link.
685
+ *
686
+ * @method ms
687
+ * @param link A message link.
688
+ * @example ```ts
689
+ * const message = await client.resolveMessageLink("https://t.me/MTKruto/212"): Promise<void>;
690
+ * ```
691
+ * @returns The message that was linked to.
692
+ */
693
+ async resolveMessageLink(link) {
694
+ return await this.#dispatch("resolveMessageLink", link);
695
+ }
696
+ /**
697
+ * Delete multiple messages.
698
+ *
699
+ * @method ms
700
+ * @param chatId The identifier of the chat which the message belongs to.
701
+ * @param messageIds The identifiers of the messages to delete.
702
+ */
703
+ async deleteMessages(chatId, messageIds, params) {
704
+ return await this.#dispatch("deleteMessages", chatId, messageIds, params);
705
+ }
706
+ /**
707
+ * Delete a single message.
708
+ *
709
+ * @method ms
710
+ * @param chatId The identifier of the chat which the message belongs to.
711
+ * @param messageId The identifier of the message to delete.
712
+ */
713
+ async deleteMessage(chatId, messageId, params) {
714
+ return await this.#dispatch("deleteMessage", chatId, messageId, params);
715
+ }
716
+ /**
717
+ * Delete all messages sent by a specific member of a chat. User-only.
718
+ *
719
+ * @method ms
720
+ * @param chatId The identifier of a chat. Must be a supergroup.
721
+ * @param memberId The identifier of the member.
722
+ */
723
+ async deleteChatMemberMessages(chatId, memberId) {
724
+ return await this.#dispatch("deleteChatMemberMessages", chatId, memberId);
725
+ }
726
+ /**
727
+ * Delete multiple scheduled messages.
728
+ *
729
+ * @method ms
730
+ * @param chatId The identifier of a chat.
731
+ * @param messageIds The identifiers of the scheduled messages to delete.
732
+ */
733
+ async deleteScheduledMessages(chatId, messageIds) {
734
+ return await this.#dispatch("deleteScheduledMessages", chatId, messageIds);
735
+ }
736
+ /**
737
+ * Delete a scheduled message.
738
+ *
739
+ * @method ms
740
+ * @param chatId The identifier of a chat.
741
+ * @param messageId The identifier of the scheduled message to delete.
742
+ */
743
+ async deleteScheduledMessage(chatId, messageId) {
744
+ return await this.#dispatch("deleteScheduledMessage", chatId, messageId);
745
+ }
746
+ /**
747
+ * Send multiple scheduled messages before their schedule.
748
+ *
749
+ * @method ms
750
+ * @param chatId The identifier of a chat.
751
+ * @param messageIds The identifiers of the scheduled messages to send.
752
+ */
753
+ async sendScheduledMessages(chatId, messageIds) {
754
+ return await this.#dispatch("sendScheduledMessages", chatId, messageIds);
755
+ }
756
+ /**
757
+ * Send a scheduled message before its schedule.
758
+ *
759
+ * @method ms
760
+ * @param chatId The identifier of a chat.
761
+ * @param messageId The identifier of the scheduled message to send.
762
+ */
763
+ async sendScheduledMessage(chatId, messageId) {
764
+ return await this.#dispatch("sendScheduledMessage", chatId, messageId);
765
+ }
766
+ /**
767
+ * Pin a message in a chat.
768
+ *
769
+ * @method ms
770
+ * @param chatId The identifier of a chat.
771
+ * @param messageId The identifier of the message.
772
+ */
773
+ async pinMessage(chatId, messageId, params) {
774
+ return await this.#dispatch("pinMessage", chatId, messageId, params);
775
+ }
776
+ /**
777
+ * Unpin a pinned message.
778
+ *
779
+ * @method ms
780
+ * @param chatId The identifier of a chat.
781
+ * @param messageId The identifier of the message.
782
+ */
783
+ async unpinMessage(chatId, messageId, params) {
784
+ return await this.#dispatch("unpinMessage", chatId, messageId, params);
785
+ }
786
+ /**
787
+ * Unpin all pinned messages.
788
+ *
789
+ * @method ms
790
+ * @param chatId The identifier of a chat.
791
+ */
792
+ async unpinMessages(chatId) {
793
+ return await this.#dispatch("unpinMessages", chatId);
794
+ }
795
+ /**
796
+ * Forward multiple messages.
797
+ *
798
+ * @method ms
799
+ * @param from The identifier of a chat to forward the messages from.
800
+ * @param to The identifier of a chat to forward the messages to.
801
+ * @param messageIds The identifiers of the messages to forward.
802
+ * @returns The forwarded messages.
803
+ */
804
+ async forwardMessages(from, to, messageIds, params) {
805
+ return await this.#dispatch("forwardMessages", from, to, messageIds, params);
806
+ }
807
+ /**
808
+ * Forward a single message.
809
+ *
810
+ * @method ms
811
+ * @param from The identifier of a chat to forward the message from.
812
+ * @param to The identifier of a chat to forward the message to.
813
+ * @param messageId The identifier of the message to forward.
814
+ * @returns The forwarded message.
815
+ */
816
+ async forwardMessage(from, to, messageId, params) {
817
+ return await this.#dispatch("forwardMessage", from, to, messageId, params);
818
+ }
819
+ /**
820
+ * Stop a poll.
821
+ *
822
+ * @method ms
823
+ * @param chatId The chat that includes the poll.
824
+ * @param messageId The idenfifier of the poll's message.
825
+ * @returns The new state of the poll.
826
+ */
827
+ async stopPoll(chatId, messageId, params) {
828
+ return await this.#dispatch("stopPoll", chatId, messageId, params);
829
+ }
830
+ /**
831
+ * Send a chat action.
832
+ *
833
+ * @method ms
834
+ * @param chatId The identifier of a chat to send the chat action to.
835
+ * @param action The chat action.
836
+ * @param messageThreadId The thread to send the chat action to.
837
+ */
838
+ async sendChatAction(chatId, action, params) {
839
+ return await this.#dispatch("sendChatAction", chatId, action, params);
840
+ }
841
+ /**
842
+ * Search for messages. User-only.
843
+ *
844
+ * @method ms
845
+ */
846
+ async searchMessages(params) {
847
+ return await this.#dispatch("searchMessages", params);
848
+ }
849
+ /**
850
+ * Mark messages as read. User-only.
851
+ *
852
+ * @method ms
853
+ * @param chatId The identifier of the chat which the messages belong to.
854
+ * @param untilMessageId The identifier of the message that will be marked as read, along with any other unread messages before it.
855
+ */
856
+ async readMessages(chatId, untilMessageId) {
857
+ return await this.#dispatch("readMessages", chatId, untilMessageId);
858
+ }
859
+ /**
860
+ * Start a bot. User-only.
861
+ *
862
+ * @method ms
863
+ * @param botId The identifier of the bot to start.
864
+ * @returns The start message.
865
+ */
866
+ async startBot(botId, params) {
867
+ return await this.#dispatch("startBot", botId, params);
868
+ }
869
+ /**
870
+ * Transcribe a voice message. User-only.
871
+ *
872
+ * @method ms
873
+ * @param chatId The identifier of the chat which the message belongs to.
874
+ * @param messageId The identifier of the message.
875
+ * @cache
876
+ */
877
+ async transcribeVoice(chatId, messageId) {
878
+ return await this.#dispatch("transcribeVoice", chatId, messageId);
879
+ }
880
+ /**
881
+ * Get a sticker set.
882
+ *
883
+ * @method ms
884
+ * @param name The name of the sticker set or its link.
885
+ */
886
+ async getStickerSet(name) {
887
+ return await this.#dispatch("getStickerSet", name);
888
+ }
889
+ /*
890
+ * Get the link preview for a message that is about to be sent. User-only.
891
+ *
892
+ * @method ms
893
+ * @param text The message's text.
894
+ */
895
+ async getLinkPreview(text, params) {
896
+ return await this.#dispatch("getLinkPreview", text, params);
897
+ }
898
+ /**
899
+ * Open a mini app. User-only.
900
+ *
901
+ * @method ms
902
+ * @param botId The identifier of a bot with the mini app.
903
+ * @param chatId The identifier of the chat from which the mini app is opened.
904
+ * @cache
905
+ */
906
+ async openMiniApp(botId, chatId, params) {
907
+ return await this.#dispatch("openMiniApp", botId, chatId, params);
908
+ }
909
+ /**
910
+ * Get a progress ID that can be passed to relevant send* methods to receive upload progress updates for them.
911
+ *
912
+ * @method ms
913
+ * @cache
914
+ */
915
+ async getProgressId() {
916
+ return await this.#dispatch("getProgressId");
917
+ }
918
+ /**
919
+ * Get messages saved from a specific chat.
920
+ *
921
+ * @method ms
922
+ * @param chatId The identifier of a chat.
923
+ */
924
+ async getSavedMessages(chatId, params) {
925
+ return await this.#dispatch("getSavedMessages", chatId, params);
926
+ }
927
+ /**
928
+ * Get a list of saved chats.
929
+ *
930
+ * @method ms
931
+ */
932
+ async getSavedChats(params) {
933
+ return await this.#dispatch("getSavedChats", params);
934
+ }
935
+ /**
936
+ * Get a list of reactions made to a message. User-only.
937
+ *
938
+ * @param chatId The identifier of a chat.
939
+ * @param messageId The identifier of the message.
940
+ * @method ms
941
+ */
942
+ async getMessageReactions(chatId, messageId, params) {
943
+ return await this.#dispatch("getMessageReactions", chatId, messageId, params);
944
+ }
945
+ //
946
+ // ========================= POLLS ========================= //
947
+ //
948
+ /**
949
+ * Cast a vote. User-only.
950
+ *
951
+ * @method pl
952
+ * @param chatId The identifier of the chat that includes the poll.
953
+ * @param messageId The identifier of the message that includes the poll.
954
+ * @param optionIndexes The indexes of the options to cast for.
955
+ */
956
+ async vote(chatId, messageId, optionIndexes) {
957
+ return await this.#dispatch("vote", chatId, messageId, optionIndexes);
958
+ }
959
+ /**
960
+ * Retract a vote. User-only.
961
+ *
962
+ * @method pl
963
+ * @param chatId The identifier of the chat that includes the poll.
964
+ * @param messageId The identifier of the message that includes the poll.
965
+ */
966
+ async retractVote(chatId, messageId) {
967
+ return await this.#dispatch("retractVote", chatId, messageId);
968
+ }
969
+ //
970
+ // ========================= FILES ========================= //
971
+ //
972
+ /**
973
+ * Download a chunk of a file.
974
+ *
975
+ * @method fs
976
+ * @param fileId The identifier of a file.
977
+ * @example ```ts
978
+ * const chunk = await client.downloadChunk(fileId, { chunkSize: 256 * 1024 });
979
+ * ```
980
+ * @returns The downloaded chunk.
981
+ * @cache file
982
+ */
983
+ async downloadChunk(fileId, params) {
984
+ return await this.#dispatch("downloadChunk", fileId, params);
985
+ }
986
+ /**
987
+ * Download a file.
988
+ *
989
+ * @method fs
990
+ * @param fileId The identifier of the file to download.
991
+ * @example ```ts
992
+ * for await (const chunk of client.download(fileId, { chunkSize: 256 * 1024 })) {
993
+ * await outFile.write(chunk): Promise<void>;
994
+ * }
995
+ * ```
996
+ * @returns A generator yielding the contents of the file.
997
+ * @cache file
998
+ */
999
+ async *download(fileId, params) {
1000
+ let offset = 0;
1001
+ const chunkSize = params?.chunkSize ?? DOWNLOAD_MAX_CHUNK_SIZE;
1002
+ while (true) {
1003
+ const chunk = await this.downloadChunk(fileId, { chunkSize, offset });
1004
+ yield chunk;
1005
+ if (chunk.length < chunkSize) {
1006
+ break;
1007
+ }
1008
+ else {
1009
+ offset += chunk.length;
1010
+ }
1011
+ }
1012
+ }
1013
+ /**
1014
+ * Get custom emoji documents for download.
1015
+ *
1016
+ * @method fs
1017
+ * @param id Identifier of one or more of custom emojis.
1018
+ * @returns The custom emoji documents.
1019
+ * @cache
1020
+ */
1021
+ async getCustomEmojiStickers(id) {
1022
+ return await this.#dispatch("getCustomEmojiStickers", id);
1023
+ }
1024
+ //
1025
+ // ========================= CHATS ========================= //
1026
+ //
1027
+ /**
1028
+ * Get chats from a chat list. User-only.
1029
+ *
1030
+ * @method ch
1031
+ */
1032
+ async getChats(params) {
1033
+ return await this.#dispatch("getChats", params);
1034
+ }
1035
+ /**
1036
+ * Get a chat.
1037
+ *
1038
+ * @method ch
1039
+ * @cache
1040
+ */
1041
+ async getChat(chatId) {
1042
+ return await this.#dispatch("getChat", chatId);
1043
+ }
1044
+ /**
1045
+ * Get chat history. User-only.
1046
+ *
1047
+ * @method ch
1048
+ * @param chatId The identifier of a chat.
1049
+ */
1050
+ async getHistory(chatId, params) {
1051
+ return await this.#dispatch("getHistory", chatId, params);
1052
+ }
1053
+ /**
1054
+ * Set a chat's available reactions. User-only.
1055
+ *
1056
+ * @method ch
1057
+ * @param chatId The identifier of a chat.
1058
+ * @param availableReactions The new available reactions.
1059
+ */
1060
+ async setAvailableReactions(chatId, availableReactions) {
1061
+ return await this.#dispatch("setAvailableReactions", chatId, availableReactions);
1062
+ }
1063
+ /**
1064
+ * Set a chat's photo.
1065
+ *
1066
+ * @method ch
1067
+ * @param chatId The identifier of a chat.
1068
+ * @param photo A photo to set as the chat's photo.
1069
+ */
1070
+ async setChatPhoto(chatId, photo, params) {
1071
+ return await this.#dispatch("setChatPhoto", chatId, photo, params);
1072
+ }
1073
+ /**
1074
+ * Delete a chat's photo.
1075
+ *
1076
+ * @method ch
1077
+ * @param chatId The identifier of a chat.
1078
+ */
1079
+ async deleteChatPhoto(chatId) {
1080
+ return await this.#dispatch("deleteChatPhoto", chatId);
1081
+ }
1082
+ /**
1083
+ * Ban a member from a chat.
1084
+ *
1085
+ * @method ch
1086
+ * @param chatId The identifier of a chat.
1087
+ * @param memberId The identifier of the member.
1088
+ */
1089
+ async banChatMember(chatId, memberId, params) {
1090
+ return await this.#dispatch("banChatMember", chatId, memberId, params);
1091
+ }
1092
+ /**
1093
+ * Unban a member from a chat.
1094
+ *
1095
+ * @method ch
1096
+ * @param chatId The identifier of a chat. Must be a supergroup.
1097
+ * @param memberId The identifier of the member.
1098
+ */
1099
+ async unbanChatMember(chatId, memberId) {
1100
+ return await this.#dispatch("unbanChatMember", chatId, memberId);
1101
+ }
1102
+ /**
1103
+ * Kick a member from a chat. Same as a banChatMember call followed by unbanChatMember.
1104
+ *
1105
+ * @method ch
1106
+ * @param chatId The identifier of a chat. Must be a supergroup.
1107
+ * @param memberId The identifier of the member.
1108
+ */
1109
+ async kickChatMember(chatId, memberId) {
1110
+ return await this.#dispatch("kickChatMember", chatId, memberId);
1111
+ }
1112
+ /**
1113
+ * Set the rights of a chat member.
1114
+ *
1115
+ * @method ch
1116
+ * @param chatId The identifier of a chat. Must be a supergroup.
1117
+ * @param memberId The identifier of the member.
1118
+ */
1119
+ async setChatMemberRights(chatId, memberId, params) {
1120
+ return await this.#dispatch("setChatMemberRights", chatId, memberId, params);
1121
+ }
1122
+ /**
1123
+ * Get the administrators of a chat.
1124
+ *
1125
+ * @method ch
1126
+ * @param chatId The identifier of a chat.
1127
+ * @returns The chat's administrators.
1128
+ */
1129
+ async getChatAdministrators(chatId) {
1130
+ return await this.#dispatch("getChatAdministrators", chatId);
1131
+ }
1132
+ /**
1133
+ * Enable join requests in a chat. User-only.
1134
+ *
1135
+ * @method ch
1136
+ * @param chatId The identifier of a chat. Must be a channel or a supergroup.
1137
+ */
1138
+ async enableJoinRequests(chatId) {
1139
+ return await this.#dispatch("enableJoinRequests", chatId);
1140
+ }
1141
+ /**
1142
+ * Disable join requests in a chat. User-only.
1143
+ *
1144
+ * @method ch
1145
+ * @param chatId The identifier of a chat. Must be a channel or a supergroup.
1146
+ */
1147
+ async disableJoinRequests(chatId) {
1148
+ return await this.#dispatch("disableJoinRequests", chatId);
1149
+ }
1150
+ /**
1151
+ * Get inactive chats. User-only.
1152
+ *
1153
+ * @method ch
1154
+ * @retuns A list of inactive chats the current user is member of.
1155
+ */
1156
+ async getInactiveChats() {
1157
+ return await this.#dispatch("getInactiveChats");
1158
+ }
1159
+ /**
1160
+ * Get the invite links created for a chat. User-only.
1161
+ *
1162
+ * @method ch
1163
+ * @param chatId The identifier of a chat.
1164
+ * @returns The invite links created for the chat. This might be a subset of the results if they were less than `limit`. The parameters `afterDate` and `afterInviteLink` can be used for pagination.
1165
+ */
1166
+ async getCreatedInviteLinks(chatId, params) {
1167
+ return await this.#dispatch("getCreatedInviteLinks", chatId, params);
1168
+ }
1169
+ /**
1170
+ * Join a chat. User-only.
1171
+ *
1172
+ * @method ch
1173
+ * @param chatId The identifier of a chat.
1174
+ */
1175
+ async joinChat(chatId) {
1176
+ return await this.#dispatch("joinChat", chatId);
1177
+ }
1178
+ /**
1179
+ * Leave a chat.
1180
+ *
1181
+ * @method ch
1182
+ * @param chatId The identifier of a chat.
1183
+ */
1184
+ async leaveChat(chatId) {
1185
+ return await this.#dispatch("leaveChat", chatId);
1186
+ }
1187
+ /**
1188
+ * Get information on a user's chat membership.
1189
+ *
1190
+ * @method ch
1191
+ * @param chatId The identifier of a chat.
1192
+ * @param userId The identifier of the user.
1193
+ */
1194
+ async getChatMember(chatId, userId) {
1195
+ return await this.#dispatch("getChatMember", chatId, userId);
1196
+ }
1197
+ /**
1198
+ * Get the members of a chat.
1199
+ *
1200
+ * @method ch
1201
+ * @param chatId The identifier of a chat.
1202
+ */
1203
+ async getChatMembers(chatId, params) {
1204
+ return await this.#dispatch("getChatMembers", chatId, params);
1205
+ }
1206
+ /**
1207
+ * Set a chat's sticker set.
1208
+ *
1209
+ * @method ch
1210
+ * @param chatId The identifier of a chat. Must be a supergroup.
1211
+ * @param setName The name of the set.
1212
+ */
1213
+ async setChatStickerSet(chatId, setName) {
1214
+ return await this.#dispatch("setChatStickerSet", chatId, setName);
1215
+ }
1216
+ /**
1217
+ * Delete a chat's sticker set.
1218
+ *
1219
+ * @method ch
1220
+ * @param chatId The identifier of a chat. Must be a supergroup.
1221
+ */
1222
+ async deleteChatStickerSet(chatId) {
1223
+ return await this.#dispatch("deleteChatStickerSet", chatId);
1224
+ }
1225
+ /**
1226
+ * Set the number of boosts required to circument a chat's default restrictions. User-only.
1227
+ *
1228
+ * @method ch
1229
+ * @param chatId The identifier of a chat.
1230
+ * @param boosts The number of boosts required to circumvent its restrictions.
1231
+ */
1232
+ async setBoostsRequiredToCircumventRestrictions(chatId, boosts) {
1233
+ return await this.#dispatch("setBoostsRequiredToCircumventRestrictions", chatId, boosts);
1234
+ }
1235
+ /**
1236
+ * Create an invite link.
1237
+ *
1238
+ * @method ch
1239
+ * @param chatId The identifier of a chat to create the invite link for.
1240
+ * @returns The newly created invite link.
1241
+ */
1242
+ async createInviteLink(chatId, params) {
1243
+ return await this.#dispatch("createInviteLink", chatId, params);
1244
+ }
1245
+ /**
1246
+ * Approve a join request.
1247
+ *
1248
+ * @method ch
1249
+ * @param chatId The identifier of a chat with the join request.
1250
+ * @param userId The user who made the join request.
1251
+ */
1252
+ async approveJoinRequest(chatId, userId) {
1253
+ return await this.#dispatch("approveJoinRequest", chatId, userId);
1254
+ }
1255
+ /**
1256
+ * Decline a join request.
1257
+ *
1258
+ * @method ch
1259
+ * @param chatId The identifier of a chat with the join request.
1260
+ * @param userId The user who made the join request.
1261
+ */
1262
+ async declineJoinRequest(chatId, userId) {
1263
+ return await this.#dispatch("declineJoinRequest", chatId, userId);
1264
+ }
1265
+ /**
1266
+ * Approve all join requests. User-only.
1267
+ *
1268
+ * @method ch
1269
+ * @param chatId The identifier of a chat with the join requests.
1270
+ */
1271
+ async approveJoinRequests(chatId, params) {
1272
+ return await this.#dispatch("approveJoinRequests", chatId, params);
1273
+ }
1274
+ /**
1275
+ * Decline all join requests. User-only.
1276
+ *
1277
+ * @method ch
1278
+ * @param chatId The identifier of a chat with the join requests.
1279
+ */
1280
+ async declineJoinRequests(chatId, params) {
1281
+ return await this.#dispatch("declineJoinRequests", chatId, params);
1282
+ }
1283
+ /**
1284
+ * Get pending join requests in a chat. User-only.
1285
+ *
1286
+ * @method ch
1287
+ * @param chatId The identifier of a chat with the join requests.
1288
+ */
1289
+ async getJoinRequests(chatId, params) {
1290
+ return await this.#dispatch("getJoinRequests", chatId, params);
1291
+ }
1292
+ /**
1293
+ * Add a single user to a chat.
1294
+ *
1295
+ * @method ch
1296
+ * @param chatId The identifier of a chat to add the user to.
1297
+ * @param userId The identifier of the user to add to the chat.
1298
+ * @returns An array of FailedInvitation that has at most a length of 1. If empty, it means that the user was added.
1299
+ */
1300
+ async addChatMember(chatId, userId, params) {
1301
+ return await this.#dispatch("addChatMember", chatId, userId, params);
1302
+ }
1303
+ /**
1304
+ * Add multiple users at once to a channel or a supergroup.
1305
+ *
1306
+ * @method ch
1307
+ * @param chatId The identifier of the channel or supergroup to add the users to.
1308
+ * @param userId The identifiers of the users to add to the channel or supergroup.
1309
+ * @returns An array of FailedInvitation that has at most a length that is the same as that of the parameter userIds. If empty, it means that all the provided users were added.
1310
+ */
1311
+ async addChatMembers(chatId, userIds) {
1312
+ return await this.#dispatch("addChatMembers", chatId, userIds);
1313
+ }
1314
+ /**
1315
+ * Open a chat.
1316
+ *
1317
+ * @method ch
1318
+ * @param chatId The identifier of a chat to open.
1319
+ */
1320
+ async openChat(chatId, params) {
1321
+ return await this.#dispatch("openChat", chatId, params);
1322
+ }
1323
+ /**
1324
+ * Close a chat previously opened by openChat.
1325
+ *
1326
+ * @method ch
1327
+ * @param chatId The identifier of a chat to close.
1328
+ */
1329
+ async closeChat(chatId) {
1330
+ return await this.#dispatch("closeChat", chatId);
1331
+ }
1332
+ /**
1333
+ * Create a group. User-only.
1334
+ *
1335
+ * @method ch
1336
+ * @param title The title of the group.
1337
+ * @returns The created group.
1338
+ */
1339
+ async createGroup(title, params) {
1340
+ return await this.#dispatch("createGroup", title, params);
1341
+ }
1342
+ /**
1343
+ * Create a supergroup. User-only.
1344
+ *
1345
+ * @method ch
1346
+ * @param title The title of the supergroup.
1347
+ * @returns The created supergroup.
1348
+ */
1349
+ async createSupergroup(title, params) {
1350
+ return await this.#dispatch("createSupergroup", title, params);
1351
+ }
1352
+ /**
1353
+ * Create a channel. User-only.
1354
+ *
1355
+ * @method ch
1356
+ * @param title The title of the channel.
1357
+ * @returns The created channel.
1358
+ */
1359
+ async createChannel(title, params) {
1360
+ return await this.#dispatch("createChannel", title, params);
1361
+ }
1362
+ /**
1363
+ * Set the time to live of the messages of a chat. User-only.
1364
+ *
1365
+ * @method ch
1366
+ * @param chatId The identifier of a chat.
1367
+ * @param messageTtl The time to live of the messages in seconds.
1368
+ */
1369
+ async setMessageTtl(chatId, messageTtl) {
1370
+ return await this.#dispatch("setMessageTtl", chatId, messageTtl);
1371
+ }
1372
+ /**
1373
+ * Archive multiple chats. User-only.
1374
+ *
1375
+ * @method ch
1376
+ * @param chatIds The identifiers of the chats to archive.
1377
+ */
1378
+ async archiveChats(chatIds) {
1379
+ return await this.#dispatch("archiveChats", chatIds);
1380
+ }
1381
+ /**
1382
+ * Archive a single chat. User-only.
1383
+ *
1384
+ * @method ch
1385
+ * @param chatId The identifier of a chat.
1386
+ */
1387
+ async archiveChat(chatId) {
1388
+ return await this.#dispatch("archiveChat", chatId);
1389
+ }
1390
+ /**
1391
+ * Unarchive multiple chats. User-only.
1392
+ *
1393
+ * @method ch
1394
+ * @param chatIds The identifiers of the chats to unarchive.
1395
+ */
1396
+ async unarchiveChats(chatIds) {
1397
+ return await this.#dispatch("unarchiveChats", chatIds);
1398
+ }
1399
+ /**
1400
+ * Unarchive a single chat. User-only.
1401
+ *
1402
+ * @method ch
1403
+ * @param chatId The identifier of a chat.
1404
+ */
1405
+ async unarchiveChat(chatId) {
1406
+ return await this.#dispatch("unarchiveChat", chatId);
1407
+ }
1408
+ /**
1409
+ * Get common chats between a user and the current one. User-only.
1410
+ *
1411
+ * @method ch
1412
+ * @param userId The identifier of the user to get the common chats with them.
1413
+ */
1414
+ async getCommonChats(userId, params) {
1415
+ return await this.#dispatch("getCommonChats", userId, params);
1416
+ }
1417
+ /**
1418
+ * Get the settings of a chat. User-only.
1419
+ *
1420
+ * @method ch
1421
+ * @param chatId The identifier of a chat.
1422
+ */
1423
+ async getChatSettings(chatId) {
1424
+ return await this.#dispatch("getChatSettings", chatId);
1425
+ }
1426
+ /**
1427
+ * Disable business bots in a private chat. User-only.
1428
+ *
1429
+ * @method ch
1430
+ * @param chatId The identifier of the private chat to disable business bots in.
1431
+ */
1432
+ async disableBusinessBots(chatId) {
1433
+ return await this.#dispatch("disableBusinessBots", chatId);
1434
+ }
1435
+ /**
1436
+ * Enable business bots in a private chat. User-only.
1437
+ *
1438
+ * @method ch
1439
+ * @param chatId The identifier of the private chat to enable business bots in.
1440
+ */
1441
+ async enableBusinessBots(chatId) {
1442
+ return await this.#dispatch("enableBusinessBots", chatId);
1443
+ }
1444
+ /**
1445
+ * Disable slow mode in a group. User-only.
1446
+ *
1447
+ * @method ch
1448
+ * @param chatId The identifier of the group to disable slow mode in.
1449
+ */
1450
+ async disableSlowMode(chatId) {
1451
+ return await this.#dispatch("disableSlowMode", chatId);
1452
+ }
1453
+ /**
1454
+ * Change slow mode in a group. User-only.
1455
+ *
1456
+ * @method ch
1457
+ * @param chatId The identifier of the group to change slow mode in.
1458
+ * @param duration New slow mode duration.
1459
+ */
1460
+ async setSlowMode(chatId, duration) {
1461
+ return await this.#dispatch("setSlowMode", chatId, duration);
1462
+ }
1463
+ /**
1464
+ * Change the title of a chat.
1465
+ *
1466
+ * @method ch
1467
+ * @param chatId The identifier of a chat.
1468
+ * @param title The new title.
1469
+ */
1470
+ async setChatTitle(chatId, title) {
1471
+ return await this.#dispatch("setChatTitle", chatId, title);
1472
+ }
1473
+ /**
1474
+ * Change the description of a chat.
1475
+ *
1476
+ * @method ch
1477
+ * @param chatId The identifier of a chat.
1478
+ * @param description The new description.
1479
+ */
1480
+ async setChatDescription(chatId, description) {
1481
+ return await this.#dispatch("setChatDescription", chatId, description);
1482
+ }
1483
+ /**
1484
+ * Hide or show the member list of a group to non-admins. User-only.
1485
+ *
1486
+ * @method ch
1487
+ * @param chatId The identifier of the group.
1488
+ * @param visible Whether the member list of the group should be visible.
1489
+ */
1490
+ async setMemberListVisibility(chatId, visible) {
1491
+ return await this.#dispatch("setMemberListVisibility", chatId, visible);
1492
+ }
1493
+ /**
1494
+ * Enable or disable topics in a group. User-only.
1495
+ *
1496
+ * @method ch
1497
+ * @param chatId The identifier of the group.
1498
+ * @param enabled Whether topics should be enabled in the group.
1499
+ * @param tabs Whether topics should be displayed as tabs.
1500
+ */
1501
+ async setTopicsEnabled(chatId, enabled, tabs) {
1502
+ return await this.#dispatch("setTopicsEnabled", chatId, enabled, tabs);
1503
+ }
1504
+ /**
1505
+ * Enable or disable automatic anti-spam in a group. User-only.
1506
+ *
1507
+ * @method ch
1508
+ * @param chatId The identifier of the group.
1509
+ * @param enabled Whether automatic anti-spam should be enabled in the group.
1510
+ */
1511
+ async setAntispamEnabled(chatId, enabled) {
1512
+ return await this.#dispatch("setAntispamEnabled", chatId, enabled);
1513
+ }
1514
+ /**
1515
+ * Enable or disable post signatures in a channel. User-only.
1516
+ *
1517
+ * @method ch
1518
+ * @param chatId The identifier of the channel.
1519
+ * @param enabled Whether post signatures should be enabled in the channel.
1520
+ */
1521
+ async setSignaturesEnabled(chatId, enabled, params) {
1522
+ return await this.#dispatch("setSignaturesEnabled", chatId, enabled, params);
1523
+ }
1524
+ /**
1525
+ * Delete a chat. User-only.
1526
+ *
1527
+ * @method ch
1528
+ * @param chatId The identifier of a chat.
1529
+ */
1530
+ async deleteChat(chatId) {
1531
+ return await this.#dispatch("deleteChat", chatId);
1532
+ }
1533
+ /**
1534
+ * Get discussion chat suggestions. User-only.
1535
+ *
1536
+ * @method ch
1537
+ */
1538
+ async getDiscussionChatSuggestions() {
1539
+ return await this.#dispatch("getDiscussionChatSuggestions");
1540
+ }
1541
+ /**
1542
+ * Set a channel's discussion chat. User-only.
1543
+ *
1544
+ * @method ch
1545
+ * @param chatId The identifier of a channel.
1546
+ * @param discussionChatId The identifier of a chat to use as discussion for the channel.
1547
+ */
1548
+ async setDiscussionChat(chatId, discussionChatId) {
1549
+ return await this.#dispatch("setDiscussionChat", chatId, discussionChatId);
1550
+ }
1551
+ /**
1552
+ * Transfer the ownership of a chat. User-only.
1553
+ *
1554
+ * @method ch
1555
+ * @param chatId The identifier of a chat.
1556
+ * @param userId The identifier of the new owner.
1557
+ * @param password The password of the current account.
1558
+ */
1559
+ async transferChatOwnership(chatId, userId, password) {
1560
+ return await this.#dispatch("transferChatOwnership", chatId, userId, password);
1561
+ }
1562
+ /**
1563
+ * Create a forum topic.
1564
+ *
1565
+ * @method ch
1566
+ * @param chatId The identifier of a chat.
1567
+ * @param title The title of the topic.
1568
+ * @returns The created topic.
1569
+ */
1570
+ async createTopic(chatId, title, params) {
1571
+ return await this.#dispatch("createTopic", chatId, title, params);
1572
+ }
1573
+ /**
1574
+ * Edit a forum topic.
1575
+ *
1576
+ * @method ch
1577
+ * @param chatId The identifier of a chat.
1578
+ * @param topicId The identifier of the topic.
1579
+ * @param title The new title of the topic.
1580
+ * @returns The new topic.
1581
+ */
1582
+ async editTopic(chatId, topicId, title, params) {
1583
+ return await this.#dispatch("editTopic", chatId, topicId, title, params);
1584
+ }
1585
+ /**
1586
+ * Hide the general forum topic.
1587
+ *
1588
+ * @method ch
1589
+ * @param chatId The identifier of a chat.
1590
+ */
1591
+ async hideGeneralTopic(chatId) {
1592
+ return await this.#dispatch("hideGeneralTopic", chatId);
1593
+ }
1594
+ /**
1595
+ * Show the general forum topic.
1596
+ *
1597
+ * @method ch
1598
+ * @param chatId The identifier of a chat.
1599
+ */
1600
+ async showGeneralTopic(chatId) {
1601
+ return await this.#dispatch("showGeneralTopic", chatId);
1602
+ }
1603
+ /**
1604
+ * Close a forum topic.
1605
+ *
1606
+ * @method ch
1607
+ * @param chatId The identifier of a chat.
1608
+ * @param topicId The identifier of the topic.
1609
+ */
1610
+ async closeTopic(chatId, topicId) {
1611
+ return await this.#dispatch("closeTopic", chatId, topicId);
1612
+ }
1613
+ /**
1614
+ * Reopen a forum topic.
1615
+ *
1616
+ * @method ch
1617
+ * @param chatId The identifier of a chat.
1618
+ * @param topicId The identifier of the topic.
1619
+ */
1620
+ async reopenTopic(chatId, topicId) {
1621
+ return await this.#dispatch("reopenTopic", chatId, topicId);
1622
+ }
1623
+ /**
1624
+ * Pin a forum topic.
1625
+ *
1626
+ * @method ch
1627
+ * @param chatId The identifier of a chat.
1628
+ * @param topicId The identifier of the topic.
1629
+ */
1630
+ async pinTopic(chatId, topicId) {
1631
+ return await this.#dispatch("pinTopic", chatId, topicId);
1632
+ }
1633
+ /**
1634
+ * Unpin a forum topic.
1635
+ *
1636
+ * @method ch
1637
+ * @param chatId The identifier of a chat.
1638
+ * @param topicId The identifier of the topic.
1639
+ */
1640
+ async unpinTopic(chatId, topicId) {
1641
+ return await this.#dispatch("unpinTopic", chatId, topicId);
1642
+ }
1643
+ /**
1644
+ * Promote a chat member.
1645
+ *
1646
+ * @method ch
1647
+ * @param chatId The identifier of a chat.
1648
+ * @param userId The identifier of the user to promote.
1649
+ */
1650
+ async promoteChatMember(chatId, userId, params) {
1651
+ return await this.#dispatch("promoteChatMember", chatId, userId, params);
1652
+ }
1653
+ //
1654
+ // ========================= CALLBACK QUERIES ========================= //
1655
+ //
1656
+ /**
1657
+ * Send a callback query. User-only.
1658
+ *
1659
+ * @method cq
1660
+ * @param botId The identifier of the bot to send the callback query to.
1661
+ * @param messageId The identifier of the message that includes at a button responsible for the callback query question.
1662
+ * @param question The callback query's question.
1663
+ * @returns The bot's answer to the callback query.
1664
+ * @cache
1665
+ */
1666
+ async sendCallbackQuery(botId, messageId, question) {
1667
+ return await this.#dispatch("sendCallbackQuery", botId, messageId, question);
1668
+ }
1669
+ /**
1670
+ * Answer a callback query. Bot-only.
1671
+ *
1672
+ * @method cq
1673
+ * @param id ID of the callback query to answer.
1674
+ */
1675
+ async answerCallbackQuery(id, params) {
1676
+ return await this.#dispatch("answerCallbackQuery", id, params);
1677
+ }
1678
+ //
1679
+ // ========================= INLINE QUERIES ========================= //
1680
+ //
1681
+ /**
1682
+ * Send an inline query. User-only.
1683
+ *
1684
+ * @method iq
1685
+ * @param botId The identifier of a bot to send the inline query to.
1686
+ * @param chatId The identifier of the chat from which the inline query is sent.
1687
+ * @returns The bot's answer to the inline query.
1688
+ * @cache
1689
+ */
1690
+ async sendInlineQuery(botId, chatId, params) {
1691
+ return await this.#dispatch("sendInlineQuery", botId, chatId, params);
1692
+ }
1693
+ /**
1694
+ * Answer an inline query. Bot-only.
1695
+ *
1696
+ * @method iq
1697
+ * @param id The identifier of the inline query to answer.
1698
+ * @param results The results to answer with.
1699
+ */
1700
+ async answerInlineQuery(id, results, params) {
1701
+ return await this.#dispatch("answerInlineQuery", id, results, params);
1702
+ }
1703
+ //
1704
+ // ========================= BOTS ========================= //
1705
+ //
1706
+ /**
1707
+ * Set the bot's description in the given language. Bot-only.
1708
+ *
1709
+ * @method bs
1710
+ */
1711
+ async setMyDescription(params) {
1712
+ return await this.#dispatch("setMyDescription", params);
1713
+ }
1714
+ /**
1715
+ * Set the bot's name in the given language. Bot-only.
1716
+ *
1717
+ * @method bs
1718
+ */
1719
+ async setMyName(params) {
1720
+ return await this.#dispatch("setMyName", params);
1721
+ }
1722
+ /**
1723
+ * Set the bot's short description in the given language. Bot-only.
1724
+ *
1725
+ * @method bs
1726
+ */
1727
+ async setMyShortDescription(params) {
1728
+ return await this.#dispatch("setMyShortDescription", params);
1729
+ }
1730
+ /**
1731
+ * Get the bot's description in the given language. Bot-only.
1732
+ *
1733
+ * @method bs
1734
+ * @returns The current bot's description in the specified language.
1735
+ */
1736
+ async getMyDescription(params) {
1737
+ return await this.#dispatch("getMyDescription", params);
1738
+ }
1739
+ /**
1740
+ * Get the bot's name in the given language. Bot-only.
1741
+ *
1742
+ * @method bs
1743
+ * @returns The current bot's name in the specified language.
1744
+ */
1745
+ async getMyName(params) {
1746
+ return await this.#dispatch("getMyName", params);
1747
+ }
1748
+ /**
1749
+ * Get the bot's short description in the given language. Bot-only.
1750
+ *
1751
+ * @method bs
1752
+ * @returns The current bot's short description in the specified language.
1753
+ */
1754
+ async getMyShortDescription(params) {
1755
+ return await this.#dispatch("getMyShortDescription", params);
1756
+ }
1757
+ /**
1758
+ * Set the bot's commands in the given scope and/or language. Bot-only.
1759
+ *
1760
+ * @method bs
1761
+ * @param commands The commands to set.
1762
+ */
1763
+ async setMyCommands(commands, params) {
1764
+ return await this.#dispatch("setMyCommands", commands, params);
1765
+ }
1766
+ /**
1767
+ * Get the bot's commands in the given scope and/or language. Bot-only.
1768
+ *
1769
+ * @method bs
1770
+ * @returns The current bot's commands in the specified language.
1771
+ */
1772
+ async getMyCommands(params) {
1773
+ return await this.#dispatch("getMyCommands", params);
1774
+ }
1775
+ //
1776
+ // ========================= REACTIONS ========================= //
1777
+ //
1778
+ /**
1779
+ * Change reactions made to a message.
1780
+ *
1781
+ * @method re
1782
+ * @param chatId The identifier of the chat which the message belongs to.
1783
+ * @param messageId The identifier of the message to add the reaction to.
1784
+ * @param reactions The new reactions.
1785
+ */
1786
+ async setReactions(chatId, messageId, reactions, params) {
1787
+ return await this.#dispatch("setReactions", chatId, messageId, reactions, params);
1788
+ }
1789
+ /**
1790
+ * Make a reaction to a message.
1791
+ *
1792
+ * @method re
1793
+ * @param chatId The identifier of the chat which the message belongs to.
1794
+ * @param messageId The identifier of the message to add the reaction to.
1795
+ * @param reaction The reaction to add.
1796
+ */
1797
+ async addReaction(chatId, messageId, reaction, params) {
1798
+ return await this.#dispatch("addReaction", chatId, messageId, reaction, params);
1799
+ }
1800
+ /**
1801
+ * Undo a reaction made to a message.
1802
+ *
1803
+ * @method re
1804
+ * @param chatId The identifier of the chat which the message belongs to.
1805
+ * @param messageId The identifier of the message which the reaction was made to.
1806
+ * @param reaction The reaction to remove.
1807
+ */
1808
+ async removeReaction(chatId, messageId, reaction) {
1809
+ return await this.#dispatch("removeReaction", chatId, messageId, reaction);
1810
+ }
1811
+ //
1812
+ // ========================= STORIES ========================= //
1813
+ //
1814
+ /**
1815
+ * Create a story. User-only.
1816
+ *
1817
+ * @method st
1818
+ * @param content The content of the story.
1819
+ * @returns The created story.
1820
+ */
1821
+ async createStory(chatId, content, params) {
1822
+ return await this.#dispatch("createStory", chatId, content, params);
1823
+ }
1824
+ /**
1825
+ * Retrieve multiple stories. User-only.
1826
+ *
1827
+ * @method st
1828
+ * @param chatId The identifier of a chat.
1829
+ * @param storyIds The identifiers of the stories to retrieve.
1830
+ * @returns The retrieved stories.
1831
+ */
1832
+ async getStories(chatId, storyIds) {
1833
+ return await this.#dispatch("getStories", chatId, storyIds);
1834
+ }
1835
+ /**
1836
+ * Retrieve a single story. User-only.
1837
+ *
1838
+ * @method st
1839
+ * @param chatId The identifier of a chat.
1840
+ * @param storyId The identifier of the story to retrieve.
1841
+ * @returns The retrieved story.
1842
+ */
1843
+ async getStory(chatId, storyId) {
1844
+ return await this.#dispatch("getStory", chatId, storyId);
1845
+ }
1846
+ /**
1847
+ * Delete multiple stories. User-only.
1848
+ *
1849
+ * @method st
1850
+ * @param chatId The identifier of a chat.
1851
+ * @param storyIds The identifiers of the stories to delete.
1852
+ */
1853
+ async deleteStories(chatId, storyIds) {
1854
+ return await this.#dispatch("deleteStories", chatId, storyIds);
1855
+ }
1856
+ /**
1857
+ * Delete a single story. User-only.
1858
+ *
1859
+ * @method st
1860
+ * @param chatId The identifier of a chat.
1861
+ * @param storyId The identifier of the story to delete.
1862
+ */
1863
+ async deleteStory(chatId, storyId) {
1864
+ return await this.#dispatch("deleteStory", chatId, storyId);
1865
+ }
1866
+ /**
1867
+ * Add multiple stories to highlights. User-only.
1868
+ *
1869
+ * @method st
1870
+ * @param chatId The identifier of a chat.
1871
+ * @param storyIds The identifiers of the stories to add to highlights.
1872
+ */
1873
+ async addStoriesToHighlights(chatId, storyIds) {
1874
+ return await this.#dispatch("addStoriesToHighlights", chatId, storyIds);
1875
+ }
1876
+ /**
1877
+ * Add a single story to highlights. User-only.
1878
+ *
1879
+ * @method st
1880
+ * @param chatId The identifier of a chat.
1881
+ * @param storyId The identifier of the story to add to highlights.
1882
+ */
1883
+ async addStoryToHighlights(chatId, storyId) {
1884
+ return await this.#dispatch("addStoryToHighlights", chatId, storyId);
1885
+ }
1886
+ /**
1887
+ * Remove multiple stories from highlights. User-only.
1888
+ *
1889
+ * @method st
1890
+ * @param chatId The identifier of a chat.
1891
+ * @param storyIds The identifiers of the stories to remove from highlights.
1892
+ */
1893
+ async removeStoriesFromHighlights(chatId, storyIds) {
1894
+ return await this.#dispatch("removeStoriesFromHighlights", chatId, storyIds);
1895
+ }
1896
+ /**
1897
+ * Remove a single story from highlights. User-only.
1898
+ *
1899
+ * @method st
1900
+ * @param chatId The identifier of a chat.
1901
+ * @param storyId The identifier of the story to remove from highlights.
1902
+ */
1903
+ async removeStoryFromHighlights(chatId, storyId) {
1904
+ return await this.#dispatch("removeStoryFromHighlights", chatId, storyId);
1905
+ }
1906
+ //
1907
+ // ========================= MISC ========================= //
1908
+ //
1909
+ /**
1910
+ * Get network statistics. This might not always be available.
1911
+ *
1912
+ * @method mc
1913
+ */
1914
+ async getNetworkStatistics() {
1915
+ return await this.#dispatch("getNetworkStatistics");
1916
+ }
1917
+ /**
1918
+ * Block a user. User-only.
1919
+ *
1920
+ * @method mc
1921
+ * @param userId The identifier of the user to block.
1922
+ */
1923
+ async blockUser(userId) {
1924
+ return await this.#dispatch("blockUser", userId);
1925
+ }
1926
+ /**
1927
+ * Unblock a user. User-only.
1928
+ *
1929
+ * @method mc
1930
+ * @param userId The identifier of the user to unblock.
1931
+ */
1932
+ async unblockUser(userId) {
1933
+ return await this.#dispatch("unblockUser", userId);
1934
+ }
1935
+ //
1936
+ // ========================= VIDEO CHATS ========================= //
1937
+ //
1938
+ /**
1939
+ * Start a video chat. User-only.
1940
+ *
1941
+ * @method vc
1942
+ * @param chatId The identifier of a chat to start the video chat in.
1943
+ * @returns The started video chat.
1944
+ */
1945
+ async startVideoChat(chatId, params) {
1946
+ return await this.#dispatch("startVideoChat", chatId, params);
1947
+ }
1948
+ /**
1949
+ * Schedule a video chat. User-only.
1950
+ *
1951
+ * @method vc
1952
+ * @param chatId The identifier of a chat to schedule the video chat in.
1953
+ * @param startAt A point in time within the future in which the video chat will be started.
1954
+ * @returns The scheduled video chat.
1955
+ */
1956
+ async scheduleVideoChat(chatId, startAt, params) {
1957
+ return await this.#dispatch("scheduleVideoChat", chatId, startAt, params);
1958
+ }
1959
+ /**
1960
+ * Join a video chat. User-only.
1961
+ *
1962
+ * @method vc
1963
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
1964
+ * @param params_ WebRTC connection parameters.
1965
+ * @returns Parameters to be passed to the used WebRTC library.
1966
+ */
1967
+ async joinVideoChat(id, params_, params) {
1968
+ return await this.#dispatch("joinVideoChat", id, params_, params);
1969
+ }
1970
+ /**
1971
+ * Leave a video chat. User-only.
1972
+ *
1973
+ * @method vc
1974
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
1975
+ */
1976
+ async leaveVideoChat(id) {
1977
+ return await this.#dispatch("leaveVideoChat", id);
1978
+ }
1979
+ /**
1980
+ * Join a live stream. User-only.
1981
+ *
1982
+ * @method vc
1983
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
1984
+ */
1985
+ async joinLiveStream(id) {
1986
+ return await this.#dispatch("joinLiveStream", id);
1987
+ }
1988
+ /**
1989
+ * Get a video chat. User-only.
1990
+ *
1991
+ * @method vc
1992
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
1993
+ * @cache
1994
+ */
1995
+ async getVideoChat(id) {
1996
+ return await this.#dispatch("getVideoChat", id);
1997
+ }
1998
+ /**
1999
+ * Get live stream channels. User-only.
2000
+ *
2001
+ * @method vc
2002
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
2003
+ */
2004
+ async getLiveStreamChannels(id) {
2005
+ return await this.#dispatch("getLiveStreamChannels", id);
2006
+ }
2007
+ /**
2008
+ * Download a live stream segment. User-only.
2009
+ *
2010
+ * @method vc
2011
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
2012
+ * @param channelId Stream channel ID.
2013
+ * @param scale Stream channel scale.
2014
+ * @param timestamp Millisecond timestamp of the chunk to download.
2015
+ */
2016
+ async downloadLiveStreamSegment(id, channelId, scale, timestamp, params) {
2017
+ return await this.#dispatch("downloadLiveStreamSegment", id, channelId, scale, timestamp, params);
2018
+ }
2019
+ //
2020
+ // ========================= PAYMENTS ========================= //
2021
+ //
2022
+ /**
2023
+ * Answer a pre-checkout query. Bot-only.
2024
+ *
2025
+ * @method pa
2026
+ * @param preCheckoutQueryId The identifier of the pre-checkout query.
2027
+ * @param ok Whether the checkout is going to be processed.
2028
+ */
2029
+ async answerPreCheckoutQuery(preCheckoutQueryId, ok, params) {
2030
+ return await this.#dispatch("answerPreCheckoutQuery", preCheckoutQueryId, ok, params);
2031
+ }
2032
+ /**
2033
+ * Refund a star payment. Bot-only.
2034
+ *
2035
+ * @method pa
2036
+ * @param userId The identifier of the user that was charged.
2037
+ * @param telegramPaymentChargeId The identifier of the charge.
2038
+ */
2039
+ async refundStarPayment(userId, telegramPaymentChargeId) {
2040
+ return await this.#dispatch("refundStarPayment", userId, telegramPaymentChargeId);
2041
+ }
2042
+ //
2043
+ // ========================= CONTACTS ========================= //
2044
+ //
2045
+ /**
2046
+ * Get contacts. User-only.
2047
+ *
2048
+ * @method co
2049
+ */
2050
+ async getContacts() {
2051
+ return await this.#dispatch("getContacts");
2052
+ }
2053
+ /**
2054
+ * Delete multiple contacts. User-only.
2055
+ *
2056
+ * @method co
2057
+ * @param userIds The identifiers of contacts to delete.
2058
+ */
2059
+ async deleteContacts(userIds) {
2060
+ return await this.#dispatch("deleteContacts", userIds);
2061
+ }
2062
+ /**
2063
+ * Delete a single contact. User-only.
2064
+ *
2065
+ * @method co
2066
+ * @param userId The identifier of the contact to delete.
2067
+ */
2068
+ async deleteContact(userId) {
2069
+ return await this.#dispatch("deleteContact", userId);
2070
+ }
2071
+ /**
2072
+ * Add a contact. User-only.
2073
+ *
2074
+ * @method co
2075
+ * @param userId The identifier of the user to add as contact.
2076
+ */
2077
+ async addContact(userId, params) {
2078
+ return await this.#dispatch("addContact", userId, params);
2079
+ }
2080
+ //
2081
+ // ========================= TRANSLATIONS ========================= //
2082
+ //
2083
+ /**
2084
+ * Get translations. User-only.
2085
+ *
2086
+ * @method ta
2087
+ * @cache
2088
+ */
2089
+ async getTranslations(params) {
2090
+ return await this.#dispatch("getTranslations", params);
2091
+ }
2092
+ //
2093
+ // ========================= GIFTS ========================= //
2094
+ //
2095
+ /**
2096
+ * Get available gifts.
2097
+ *
2098
+ * @method gf
2099
+ */
2100
+ async getGifts() {
2101
+ return await this.#dispatch("getGifts");
2102
+ }
2103
+ /**
2104
+ * Get gifts claimed by a user or a channel. User-only.
2105
+ *
2106
+ * @method gf
2107
+ * @param chatId The identifier of a user or a channel to get gifts for.
2108
+ */
2109
+ async getClaimedGifts(chatId, params) {
2110
+ return await this.#dispatch("getClaimedGifts", chatId, params);
2111
+ }
2112
+ /**
2113
+ * Send a gift.
2114
+ *
2115
+ * @method gf
2116
+ * @param chatId The identifier of a user or a channel to send the gift to.
2117
+ * @param giftId The identifier of the gift to send.
2118
+ */
2119
+ async sendGift(chatId, giftId, params) {
2120
+ return await this.#dispatch("sendGift", chatId, giftId, params);
2121
+ }
2122
+ /**
2123
+ * Sell a gift.
2124
+ *
2125
+ * @method gf
2126
+ * @param userId The identifier of the user that sent the gift.
2127
+ * @param messageId The identifier of the service message announcing the receival of the gift.
2128
+ */
2129
+ async sellGift(userId, messageId) {
2130
+ return await this.#dispatch("sellGift", userId, messageId);
2131
+ }
2132
+ /**
2133
+ * Get a gift using its slug.
2134
+ *
2135
+ * @method gf
2136
+ * @param slug The slug of a gift.
2137
+ */
2138
+ async getGift(slug) {
2139
+ return await this.#dispatch("getGift", slug);
2140
+ }
2141
+ }