@mtkruto/node 0.78.0 → 0.78.1

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