@mtkruto/node 0.0.990 → 0.0.992
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.
- package/esm/1_utilities.d.ts +12 -0
- package/esm/1_utilities.js +12 -0
- package/esm/2_connection.d.ts +2 -0
- package/esm/2_connection.js +2 -0
- package/esm/2_tl.d.ts +10 -0
- package/esm/2_tl.js +10 -0
- package/esm/3_storage.d.ts +6 -0
- package/esm/3_storage.js +6 -0
- package/esm/3_transport.d.ts +4 -0
- package/esm/3_transport.js +4 -0
- package/esm/3_types.d.ts +35 -0
- package/esm/3_types.js +35 -0
- package/esm/{constants.d.ts → 4_constants.d.ts} +2 -2
- package/esm/{constants.js → 4_constants.js} +1 -1
- package/esm/5_client.d.ts +2 -0
- package/esm/5_client.js +2 -0
- package/esm/client/0_html.d.ts +1 -1
- package/esm/client/0_html.js +1 -1
- package/esm/client/0_message.d.ts +1 -2
- package/esm/client/0_message.js +7 -14
- package/esm/client/0_password.d.ts +2 -2
- package/esm/client/0_password.js +2 -4
- package/esm/client/0_utilities.d.ts +3 -5
- package/esm/client/0_utilities.js +3 -22
- package/esm/client/1_client_abstract.d.ts +2 -2
- package/esm/client/1_client_abstract.js +3 -3
- package/esm/client/2_client_plain.d.ts +3 -3
- package/esm/client/2_client_plain.js +13 -20
- package/esm/client/3_client.d.ts +43 -18
- package/esm/client/3_client.js +107 -46
- package/esm/connection/0_connection.d.ts +1 -1
- package/esm/connection/1_connection_web_socket.js +1 -1
- package/esm/mod.d.ts +7 -21
- package/esm/mod.js +7 -21
- package/esm/storage/0_storage.d.ts +4 -5
- package/esm/storage/0_storage.js +3 -8
- package/esm/storage/0_utilities.js +2 -2
- package/esm/storage/1_storage_local_storage.d.ts +1 -1
- package/esm/storage/1_storage_memory.d.ts +1 -1
- package/esm/storage/1_storage_session_storage.d.ts +1 -1
- package/esm/tl/0_tl_raw_reader.js +1 -1
- package/esm/tl/0_tl_raw_writer.js +1 -1
- package/esm/tl/1_tl_object.js +1 -1
- package/esm/tl/3_deserialize.js +1 -1
- package/esm/tl/3_utilities.d.ts +3 -0
- package/esm/tl/3_utilities.js +20 -0
- package/esm/tl/4_tl_writer.js +1 -1
- package/esm/transport/0_obfuscation.d.ts +2 -2
- package/esm/transport/0_obfuscation.js +1 -2
- package/esm/transport/0_transport.d.ts +1 -2
- package/esm/transport/1_transport_abridged.d.ts +1 -1
- package/esm/transport/1_transport_abridged.js +1 -1
- package/esm/transport/1_transport_intermediate.d.ts +1 -1
- package/esm/transport/1_transport_intermediate.js +1 -1
- package/esm/transport/2_transport_provider.d.ts +1 -1
- package/esm/transport/2_transport_provider.js +1 -1
- package/esm/types/!0_file_id.js +6 -9
- package/esm/types/!0_misc.d.ts +7 -0
- package/esm/types/!0_misc.js +1 -0
- package/esm/types/0_audio.d.ts +3 -3
- package/esm/types/0_audio.js +1 -1
- package/esm/types/0_chat_administrator_rights.d.ts +1 -1
- package/esm/types/0_chat_administrator_rights.js +1 -1
- package/esm/types/0_chat_photo.d.ts +3 -3
- package/esm/types/0_chat_photo.js +1 -1
- package/esm/types/0_color.d.ts +2 -0
- package/esm/types/0_color.js +16 -0
- package/esm/types/0_contact.d.ts +2 -2
- package/esm/types/0_dice.d.ts +1 -1
- package/esm/types/0_force_reply.d.ts +1 -1
- package/esm/types/0_force_reply.js +1 -1
- package/esm/types/0_location.d.ts +1 -1
- package/esm/types/0_location.js +1 -2
- package/esm/types/0_mask_position.d.ts +1 -1
- package/esm/types/0_message_entity.d.ts +5 -5
- package/esm/types/0_message_entity.js +1 -1
- package/esm/types/0_poll_option.d.ts +1 -1
- package/esm/types/0_reply_keyboard_remove.d.ts +1 -1
- package/esm/types/0_reply_keyboard_remove.js +2 -2
- package/esm/types/0_thumbnail.d.ts +2 -2
- package/esm/types/0_thumbnail.js +1 -1
- package/esm/types/0_venue.d.ts +1 -1
- package/esm/types/0_venue.js +1 -2
- package/esm/types/0_voice.d.ts +3 -3
- package/esm/types/0_web_app_info.d.ts +2 -2
- package/esm/types/1_animation.d.ts +3 -3
- package/esm/types/1_animation.js +1 -1
- package/esm/types/1_chat.d.ts +5 -4
- package/esm/types/1_chat.js +8 -9
- package/esm/types/1_document.d.ts +4 -4
- package/esm/types/1_document.js +1 -1
- package/esm/types/1_inline_keyboard_button.d.ts +4 -4
- package/esm/types/1_inline_keyboard_button.js +2 -2
- package/esm/types/1_keyboard_button.d.ts +8 -8
- package/esm/types/1_keyboard_button.js +2 -2
- package/esm/types/1_photo.d.ts +2 -2
- package/esm/types/1_photo.js +1 -1
- package/esm/types/1_poll.d.ts +8 -8
- package/esm/types/1_poll.js +1 -1
- package/esm/types/1_sticker.d.ts +3 -3
- package/esm/types/1_sticker.js +1 -2
- package/esm/types/1_user.d.ts +4 -3
- package/esm/types/1_user.js +4 -4
- package/esm/types/1_video.d.ts +3 -3
- package/esm/types/1_video.js +1 -1
- package/esm/types/1_video_note.d.ts +2 -2
- package/esm/types/1_video_note.js +1 -1
- package/esm/types/2_game.d.ts +3 -3
- package/esm/types/2_game.js +2 -3
- package/esm/types/2_inline_keyboard_markup.d.ts +2 -2
- package/esm/types/2_inline_keyboard_markup.js +1 -1
- package/esm/types/2_inline_query.d.ts +19 -0
- package/esm/types/2_inline_query.js +41 -0
- package/esm/types/2_reply_keyboard_markup.d.ts +2 -2
- package/esm/types/2_reply_keyboard_markup.js +1 -1
- package/esm/types/3_message.d.ts +23 -23
- package/esm/types/3_message.js +19 -18
- package/esm/types/4_callback_query.d.ts +14 -0
- package/esm/types/4_callback_query.js +24 -0
- package/esm/utilities/0_base64.js +1 -1
- package/esm/utilities/0_crypto.js +1 -1
- package/esm/utilities/0_queue.js +1 -1
- package/esm/utilities/1_auth.js +1 -1
- package/package.json +1 -1
- package/script/1_utilities.d.ts +12 -0
- package/script/1_utilities.js +28 -0
- package/script/2_connection.d.ts +2 -0
- package/script/2_connection.js +18 -0
- package/script/2_tl.d.ts +10 -0
- package/script/2_tl.js +40 -0
- package/script/3_storage.d.ts +6 -0
- package/script/3_storage.js +22 -0
- package/script/3_transport.d.ts +4 -0
- package/script/3_transport.js +20 -0
- package/script/3_types.d.ts +35 -0
- package/script/3_types.js +51 -0
- package/script/{constants.d.ts → 4_constants.d.ts} +2 -2
- package/script/{constants.js → 4_constants.js} +1 -1
- package/script/5_client.d.ts +2 -0
- package/script/5_client.js +18 -0
- package/script/client/0_html.d.ts +1 -1
- package/script/client/0_html.js +2 -2
- package/script/client/0_message.d.ts +1 -2
- package/script/client/0_message.js +32 -39
- package/script/client/0_password.d.ts +2 -2
- package/script/client/0_password.js +20 -22
- package/script/client/0_utilities.d.ts +3 -5
- package/script/client/0_utilities.js +24 -68
- package/script/client/1_client_abstract.d.ts +2 -2
- package/script/client/1_client_abstract.js +6 -6
- package/script/client/2_client_plain.d.ts +3 -3
- package/script/client/2_client_plain.js +45 -52
- package/script/client/3_client.d.ts +43 -18
- package/script/client/3_client.js +342 -305
- package/script/connection/0_connection.d.ts +1 -1
- package/script/connection/1_connection_web_socket.js +5 -5
- package/script/mod.d.ts +7 -21
- package/script/mod.js +17 -45
- package/script/storage/0_storage.d.ts +4 -5
- package/script/storage/0_storage.js +11 -39
- package/script/storage/0_utilities.js +6 -6
- package/script/storage/1_storage_local_storage.d.ts +1 -1
- package/script/storage/1_storage_memory.d.ts +1 -1
- package/script/storage/1_storage_session_storage.d.ts +1 -1
- package/script/tl/0_tl_raw_reader.js +6 -6
- package/script/tl/0_tl_raw_writer.js +7 -7
- package/script/tl/1_tl_object.js +3 -3
- package/script/tl/3_deserialize.js +2 -2
- package/script/tl/3_utilities.d.ts +3 -0
- package/script/tl/3_utilities.js +48 -0
- package/script/tl/4_tl_writer.js +2 -2
- package/script/transport/0_obfuscation.d.ts +2 -2
- package/script/transport/0_obfuscation.js +5 -6
- package/script/transport/0_transport.d.ts +1 -2
- package/script/transport/1_transport_abridged.d.ts +1 -1
- package/script/transport/1_transport_abridged.js +3 -3
- package/script/transport/1_transport_intermediate.d.ts +1 -1
- package/script/transport/1_transport_intermediate.js +3 -3
- package/script/transport/2_transport_provider.d.ts +1 -1
- package/script/transport/2_transport_provider.js +2 -2
- package/script/types/!0_file_id.js +24 -27
- package/script/types/!0_misc.d.ts +7 -0
- package/script/types/!0_misc.js +2 -0
- package/script/types/0_audio.d.ts +3 -3
- package/script/types/0_audio.js +2 -25
- package/script/types/0_chat_administrator_rights.d.ts +1 -1
- package/script/types/0_chat_administrator_rights.js +2 -25
- package/script/types/0_chat_photo.d.ts +3 -3
- package/script/types/0_chat_photo.js +2 -25
- package/script/types/0_color.d.ts +2 -0
- package/script/types/{!0_id_color.js → 0_color.js} +10 -10
- package/script/types/0_contact.d.ts +2 -2
- package/script/types/0_dice.d.ts +1 -1
- package/script/types/0_force_reply.d.ts +1 -1
- package/script/types/0_force_reply.js +2 -25
- package/script/types/0_location.d.ts +1 -1
- package/script/types/0_location.js +5 -29
- package/script/types/0_mask_position.d.ts +1 -1
- package/script/types/0_message_entity.d.ts +5 -5
- package/script/types/0_message_entity.js +39 -62
- package/script/types/0_poll_option.d.ts +1 -1
- package/script/types/0_reply_keyboard_remove.d.ts +1 -1
- package/script/types/0_reply_keyboard_remove.js +4 -27
- package/script/types/0_thumbnail.d.ts +2 -2
- package/script/types/0_thumbnail.js +2 -25
- package/script/types/0_venue.d.ts +1 -1
- package/script/types/0_venue.js +2 -26
- package/script/types/0_voice.d.ts +3 -3
- package/script/types/0_web_app_info.d.ts +2 -2
- package/script/types/1_animation.d.ts +3 -3
- package/script/types/1_animation.js +2 -25
- package/script/types/1_chat.d.ts +5 -4
- package/script/types/1_chat.js +20 -44
- package/script/types/1_document.d.ts +4 -4
- package/script/types/1_document.js +2 -25
- package/script/types/1_inline_keyboard_button.d.ts +4 -4
- package/script/types/1_inline_keyboard_button.js +19 -42
- package/script/types/1_keyboard_button.d.ts +8 -8
- package/script/types/1_keyboard_button.js +24 -47
- package/script/types/1_photo.d.ts +2 -2
- package/script/types/1_photo.js +4 -27
- package/script/types/1_poll.d.ts +8 -8
- package/script/types/1_poll.js +2 -2
- package/script/types/1_sticker.d.ts +3 -3
- package/script/types/1_sticker.js +6 -30
- package/script/types/1_user.d.ts +4 -3
- package/script/types/1_user.js +6 -29
- package/script/types/1_video.d.ts +3 -3
- package/script/types/1_video.js +2 -25
- package/script/types/1_video_note.d.ts +2 -2
- package/script/types/1_video_note.js +2 -25
- package/script/types/2_game.d.ts +3 -3
- package/script/types/2_game.js +6 -30
- package/script/types/2_inline_keyboard_markup.d.ts +2 -2
- package/script/types/2_inline_keyboard_markup.js +3 -26
- package/script/types/2_inline_query.d.ts +19 -0
- package/script/types/2_inline_query.js +45 -0
- package/script/types/2_reply_keyboard_markup.d.ts +2 -2
- package/script/types/2_reply_keyboard_markup.js +3 -26
- package/script/types/3_message.d.ts +23 -23
- package/script/types/3_message.js +97 -119
- package/script/types/4_callback_query.d.ts +14 -0
- package/script/types/4_callback_query.js +28 -0
- package/script/utilities/0_base64.js +3 -3
- package/script/utilities/0_crypto.js +3 -3
- package/script/utilities/0_queue.js +2 -2
- package/script/utilities/1_auth.js +5 -5
- package/esm/types/!0_id_color.d.ts +0 -1
- package/esm/types/!0_id_color.js +0 -16
- package/script/types/!0_id_color.d.ts +0 -1
- /package/esm/{deps.d.ts → 0_deps.d.ts} +0 -0
- /package/esm/{deps.js → 0_deps.js} +0 -0
- /package/script/{deps.d.ts → 0_deps.d.ts} +0 -0
- /package/script/{deps.js → 0_deps.js} +0 -0
package/esm/client/3_client.js
CHANGED
|
@@ -1,28 +1,11 @@
|
|
|
1
|
-
import { debug, gunzip, Mutex } from "../
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { TLError } from "../tl/0_tl_raw_reader.js";
|
|
10
|
-
import { as } from "../tl/1_tl_object.js";
|
|
11
|
-
import * as types from "../tl/2_types.js";
|
|
12
|
-
import { TLReader } from "../tl/3_tl_reader.js";
|
|
13
|
-
import * as functions from "../tl/3_functions.js";
|
|
14
|
-
import { RPCResult } from "../tl/5_rpc_result.js";
|
|
15
|
-
import { Message as Message_ } from "../tl/6_message.js"; // MTProto API message
|
|
16
|
-
import { MessageContainer } from "../tl/7_message_container.js";
|
|
17
|
-
import { FileID, FileType, ThumbnailSource } from "../types/!0_file_id.js";
|
|
18
|
-
import { replyKeyboardRemoveToTlObject } from "../types/0_reply_keyboard_remove.js";
|
|
19
|
-
import { messageEntityToTlObject } from "../types/0_message_entity.js";
|
|
20
|
-
import { forceReplyToTlObject } from "../types/0_force_reply.js";
|
|
21
|
-
import { constructUser } from "../types/1_user.js";
|
|
22
|
-
import { inlineKeyboardMarkupToTlObject } from "../types/2_inline_keyboard_markup.js";
|
|
23
|
-
import { replyKeyboardMarkupToTlObject } from "../types/2_reply_keyboard_markup.js";
|
|
24
|
-
import { constructMessage } from "../types/3_message.js"; // high-level wrapper for Telegram API's message
|
|
25
|
-
import { StorageMemory } from "../storage/1_storage_memory.js";
|
|
1
|
+
import { debug, gunzip, Mutex } from "../0_deps.js";
|
|
2
|
+
import { bigIntFromBuffer, drop, getRandomBigInt, getRandomId, mustPrompt, mustPromptOneOf, Queue, sha1, UNREACHABLE } from "../1_utilities.js";
|
|
3
|
+
import { as, functions, getChannelChatId, Message as Message_, // MTProto API message
|
|
4
|
+
MessageContainer, peerToChatId, RPCResult, TLError, TLReader, types, } from "../2_tl.js";
|
|
5
|
+
import { StorageMemory } from "../3_storage.js";
|
|
6
|
+
import { constructCallbackQuery, constructInlineQuery, constructMessage, constructUser, FileID, FileType, forceReplyToTlObject, inlineKeyboardMarkupToTlObject, messageEntityToTlObject, replyKeyboardMarkupToTlObject, replyKeyboardRemoveToTlObject, ThumbnailSource, } from "../3_types.js";
|
|
7
|
+
import { ACK_THRESHOLD, APP_VERSION, CHANNEL_DIFFERENCE_LIMIT_BOT, CHANNEL_DIFFERENCE_LIMIT_USER, DEVICE_MODEL, LANG_CODE, LANG_PACK, LAYER, MAX_CHANNEL_ID, MAX_CHAT_ID, STICKER_SET_NAME_TTL, SYSTEM_LANG_CODE, SYSTEM_VERSION, USERNAME_TTL, ZERO_CHANNEL_ID } from "../4_constants.js";
|
|
8
|
+
import { isChannelPtsUpdate, isPtsUpdate } from "./0_utilities.js";
|
|
26
9
|
import { decryptMessage, encryptMessage, getMessageId } from "./0_message.js";
|
|
27
10
|
import { checkPassword } from "./0_password.js";
|
|
28
11
|
import { parseHtml } from "./0_html.js";
|
|
@@ -36,6 +19,7 @@ const dRecv = debug("Client/receiveLoop");
|
|
|
36
19
|
export const getEntity = Symbol();
|
|
37
20
|
export const getStickerSetName = Symbol();
|
|
38
21
|
export const handleMigrationError = Symbol();
|
|
22
|
+
export const getMessageWithReply = Symbol();
|
|
39
23
|
export const restartAuth = Symbol();
|
|
40
24
|
export var ParseMode;
|
|
41
25
|
(function (ParseMode) {
|
|
@@ -204,6 +188,12 @@ export class Client extends ClientAbstract {
|
|
|
204
188
|
writable: true,
|
|
205
189
|
value: false
|
|
206
190
|
});
|
|
191
|
+
Object.defineProperty(this, "lastPropagatedAuthorizationState", {
|
|
192
|
+
enumerable: true,
|
|
193
|
+
configurable: true,
|
|
194
|
+
writable: true,
|
|
195
|
+
value: null
|
|
196
|
+
});
|
|
207
197
|
Object.defineProperty(this, "autoStarted", {
|
|
208
198
|
enumerable: true,
|
|
209
199
|
configurable: true,
|
|
@@ -278,11 +268,11 @@ export class Client extends ClientAbstract {
|
|
|
278
268
|
* Before establishing the connection, the session is saved.
|
|
279
269
|
*/
|
|
280
270
|
async connect() {
|
|
271
|
+
if (this.connected) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
281
274
|
const release = await this.connectMutex.acquire();
|
|
282
275
|
try {
|
|
283
|
-
if (this.connected) {
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
276
|
if (!this.storageInited) {
|
|
287
277
|
await this.storage.init();
|
|
288
278
|
this.storageInited = true;
|
|
@@ -362,6 +352,12 @@ export class Client extends ClientAbstract {
|
|
|
362
352
|
d("connection inited");
|
|
363
353
|
}
|
|
364
354
|
}
|
|
355
|
+
async propagateAuthorizationState(authorized) {
|
|
356
|
+
if (this.lastPropagatedAuthorizationState != authorized) {
|
|
357
|
+
await this.handler({ authorizationState: { authorized } }, resolve);
|
|
358
|
+
this.lastPropagatedAuthorizationState = authorized;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
365
361
|
/**
|
|
366
362
|
* Calls [initConnection](1) and authorizes the client with one of the following:
|
|
367
363
|
*
|
|
@@ -399,6 +395,7 @@ export class Client extends ClientAbstract {
|
|
|
399
395
|
await this.initConnection();
|
|
400
396
|
try {
|
|
401
397
|
await this.fetchState("authorize");
|
|
398
|
+
await this.propagateAuthorizationState(true);
|
|
402
399
|
d("already authorized");
|
|
403
400
|
return;
|
|
404
401
|
}
|
|
@@ -432,6 +429,7 @@ export class Client extends ClientAbstract {
|
|
|
432
429
|
}
|
|
433
430
|
}
|
|
434
431
|
dAuth("authorized as bot");
|
|
432
|
+
await this.propagateAuthorizationState(true);
|
|
435
433
|
await this.fetchState("authorize");
|
|
436
434
|
return;
|
|
437
435
|
}
|
|
@@ -493,6 +491,7 @@ export class Client extends ClientAbstract {
|
|
|
493
491
|
}));
|
|
494
492
|
await this.storage.setAccountType("user");
|
|
495
493
|
dAuth("authorized as user");
|
|
494
|
+
await this.propagateAuthorizationState(true);
|
|
496
495
|
await this.fetchState("authorize");
|
|
497
496
|
return;
|
|
498
497
|
}
|
|
@@ -520,6 +519,7 @@ export class Client extends ClientAbstract {
|
|
|
520
519
|
await this.invoke(new functions.AuthCheckPassword({ password: input }));
|
|
521
520
|
await this.storage.setAccountType("user");
|
|
522
521
|
dAuth("authorized as user");
|
|
522
|
+
await this.propagateAuthorizationState(true);
|
|
523
523
|
await this.fetchState("authorize");
|
|
524
524
|
break;
|
|
525
525
|
}
|
|
@@ -542,6 +542,7 @@ export class Client extends ClientAbstract {
|
|
|
542
542
|
try {
|
|
543
543
|
await this.fetchState("authorize");
|
|
544
544
|
d("already authorized");
|
|
545
|
+
await this.propagateAuthorizationState(true);
|
|
545
546
|
return;
|
|
546
547
|
}
|
|
547
548
|
catch (err) {
|
|
@@ -684,9 +685,18 @@ export class Client extends ClientAbstract {
|
|
|
684
685
|
if (noWait) {
|
|
685
686
|
return;
|
|
686
687
|
}
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
688
|
+
let result;
|
|
689
|
+
try {
|
|
690
|
+
result = await new Promise((resolve, reject) => {
|
|
691
|
+
this.promises.set(message.id, { resolve, reject });
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
catch (err) {
|
|
695
|
+
if (err instanceof types.RPCError && err.errorMessage == "AUTH_KEY_UNREGISTERED") {
|
|
696
|
+
await this.propagateAuthorizationState(false);
|
|
697
|
+
}
|
|
698
|
+
throw err;
|
|
699
|
+
}
|
|
690
700
|
if (result instanceof types.BadServerSalt) {
|
|
691
701
|
return await this.invoke(function_);
|
|
692
702
|
}
|
|
@@ -794,7 +804,7 @@ export class Client extends ClientAbstract {
|
|
|
794
804
|
let originalPts = null;
|
|
795
805
|
const channelPtsMap = new Map();
|
|
796
806
|
for (const update of updates) {
|
|
797
|
-
if (
|
|
807
|
+
if (isPtsUpdate(update)) {
|
|
798
808
|
if (update.pts == 0) {
|
|
799
809
|
continue;
|
|
800
810
|
}
|
|
@@ -808,7 +818,7 @@ export class Client extends ClientAbstract {
|
|
|
808
818
|
localState.pts = update.pts;
|
|
809
819
|
}
|
|
810
820
|
}
|
|
811
|
-
else if (
|
|
821
|
+
else if (isChannelPtsUpdate(update)) {
|
|
812
822
|
if (update.pts == 0) {
|
|
813
823
|
continue;
|
|
814
824
|
}
|
|
@@ -1002,7 +1012,28 @@ export class Client extends ClientAbstract {
|
|
|
1002
1012
|
}
|
|
1003
1013
|
}
|
|
1004
1014
|
}
|
|
1015
|
+
async getUserAccessHash(userId) {
|
|
1016
|
+
const users = await this.invoke(new functions.UsersGetUsers({ id: [new types.InputUser({ userId, accessHash: 0n })] }));
|
|
1017
|
+
return users[0][as](types.User).accessHash ?? 0n;
|
|
1018
|
+
}
|
|
1019
|
+
async getChannelAccessHash(channelId) {
|
|
1020
|
+
const channels = await this.invoke(new functions.ChannelsGetChannels({ id: [new types.InputChannel({ channelId, accessHash: 0n })] }));
|
|
1021
|
+
return channels.chats[0][as](types.Channel).accessHash ?? 0n;
|
|
1022
|
+
}
|
|
1005
1023
|
async getInputPeer(id) {
|
|
1024
|
+
const inputPeer = await this.getInputPeerInner(id);
|
|
1025
|
+
if (inputPeer instanceof types.InputPeerUser || inputPeer instanceof types.InputPeerChannel && inputPeer.accessHash == 0n && await this.storage.getAccountType() == "bot") {
|
|
1026
|
+
if ("channelId" in inputPeer) {
|
|
1027
|
+
inputPeer.accessHash = await this.getChannelAccessHash(inputPeer.channelId);
|
|
1028
|
+
}
|
|
1029
|
+
else {
|
|
1030
|
+
inputPeer.accessHash = await this.getUserAccessHash(inputPeer.userId);
|
|
1031
|
+
await this.storage.setUserAccessHash(inputPeer.userId, inputPeer.accessHash);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
return inputPeer;
|
|
1035
|
+
}
|
|
1036
|
+
async getInputPeerInner(id) {
|
|
1006
1037
|
if (typeof id === "string") {
|
|
1007
1038
|
if (!id.startsWith("@")) {
|
|
1008
1039
|
throw new Error("Expected username to start with @");
|
|
@@ -1107,9 +1138,13 @@ export class Client extends ClientAbstract {
|
|
|
1107
1138
|
result instanceof types.ChatlistsExportedInvites ||
|
|
1108
1139
|
result instanceof types.ChatlistsChatlistInviteAlready ||
|
|
1109
1140
|
result instanceof types.ChatlistsChatlistInvite ||
|
|
1110
|
-
result instanceof types.ChatlistsChatlistUpdates
|
|
1141
|
+
result instanceof types.ChatlistsChatlistUpdates ||
|
|
1142
|
+
result instanceof types.MessagesChats ||
|
|
1143
|
+
result instanceof types.MessagesChatsSlice) {
|
|
1111
1144
|
await this.processChats(result.chats);
|
|
1112
|
-
|
|
1145
|
+
if ("users" in result) {
|
|
1146
|
+
await this.processUsers(result.users);
|
|
1147
|
+
}
|
|
1113
1148
|
}
|
|
1114
1149
|
if (result instanceof types.MessagesMessages) {
|
|
1115
1150
|
for (const message of result.messages) {
|
|
@@ -1253,13 +1288,7 @@ export class Client extends ClientAbstract {
|
|
|
1253
1288
|
const noWebpage = params?.disableWebPagePreview ? true : undefined;
|
|
1254
1289
|
await this.invoke(new functions.MessagesEditMessage({ id, peer, entities, message, noWebpage, replyMarkup }));
|
|
1255
1290
|
}
|
|
1256
|
-
|
|
1257
|
-
* Retrieve multiple messages.
|
|
1258
|
-
*
|
|
1259
|
-
* @param chatId The identifier of the chat to retrieve the messages from.
|
|
1260
|
-
* @param messageIds The identifiers of the messages to retrieve.
|
|
1261
|
-
*/
|
|
1262
|
-
async getMessages(chatId_, messageIds) {
|
|
1291
|
+
async getMessagesInner(chatId_, messageIds) {
|
|
1263
1292
|
const peer = await this.getInputPeer(chatId_);
|
|
1264
1293
|
let messages_ = new Array();
|
|
1265
1294
|
const chatId = peerToChatId(peer);
|
|
@@ -1290,10 +1319,25 @@ export class Client extends ClientAbstract {
|
|
|
1290
1319
|
}
|
|
1291
1320
|
const messages = new Array();
|
|
1292
1321
|
for (const message_ of messages_) {
|
|
1293
|
-
|
|
1322
|
+
const message = await constructMessage(message_, this[getEntity].bind(this), null, this[getStickerSetName].bind(this));
|
|
1323
|
+
const isReplyToMessage = message_ instanceof types.Message && message_.replyTo instanceof types.MessageReplyHeader;
|
|
1324
|
+
messages.push({ message, isReplyToMessage });
|
|
1294
1325
|
}
|
|
1295
1326
|
return messages;
|
|
1296
1327
|
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Retrieve multiple messages.
|
|
1330
|
+
*
|
|
1331
|
+
* @param chatId The identifier of the chat to retrieve the messages from.
|
|
1332
|
+
* @param messageIds The identifiers of the messages to retrieve.
|
|
1333
|
+
*/
|
|
1334
|
+
async getMessages(chatId_, messageIds) {
|
|
1335
|
+
return await this.getMessagesInner(chatId_, messageIds).then((v) => v.map((v) => v.message));
|
|
1336
|
+
}
|
|
1337
|
+
async [getMessageWithReply](chatId, messageId) {
|
|
1338
|
+
const messages = await this.getMessagesInner(chatId, [messageId]);
|
|
1339
|
+
return messages[0]?.message ?? null;
|
|
1340
|
+
}
|
|
1297
1341
|
/**
|
|
1298
1342
|
* Retrieve a single message.
|
|
1299
1343
|
*
|
|
@@ -1473,6 +1517,12 @@ export class Client extends ClientAbstract {
|
|
|
1473
1517
|
await this.handler({ deletedMessages: deletedMessages }, resolve);
|
|
1474
1518
|
}
|
|
1475
1519
|
}
|
|
1520
|
+
if (update instanceof types.UpdateBotCallbackQuery || update instanceof types.UpdateInlineBotCallbackQuery) {
|
|
1521
|
+
await this.handler({ callbackQuery: await constructCallbackQuery(update, this[getEntity].bind(this), this[getMessageWithReply].bind(this)) }, resolve);
|
|
1522
|
+
}
|
|
1523
|
+
else if (update instanceof types.UpdateBotInlineQuery) {
|
|
1524
|
+
await this.handler({ inlineQuery: await constructInlineQuery(update, this[getEntity].bind(this)) }, resolve);
|
|
1525
|
+
}
|
|
1476
1526
|
}
|
|
1477
1527
|
use(middleware) {
|
|
1478
1528
|
const handler = this.handler;
|
|
@@ -1486,9 +1536,7 @@ export class Client extends ClientAbstract {
|
|
|
1486
1536
|
});
|
|
1487
1537
|
};
|
|
1488
1538
|
}
|
|
1489
|
-
on(
|
|
1490
|
-
// deno-lint-ignore no-explicit-any
|
|
1491
|
-
filter, handler) {
|
|
1539
|
+
on(filter, handler) {
|
|
1492
1540
|
const type = typeof filter === "string" ? filter : filter[0];
|
|
1493
1541
|
const keys = Array.isArray(filter) ? filter.slice(1) : [];
|
|
1494
1542
|
this.use((update, next) => {
|
|
@@ -1511,5 +1559,18 @@ export class Client extends ClientAbstract {
|
|
|
1511
1559
|
}
|
|
1512
1560
|
});
|
|
1513
1561
|
}
|
|
1562
|
+
/**
|
|
1563
|
+
* Answer a callback query. Bot-only.
|
|
1564
|
+
*
|
|
1565
|
+
* @param id ID of the callback query to answer.
|
|
1566
|
+
*/
|
|
1567
|
+
async answerCallbackQuery(id, params) {
|
|
1568
|
+
await this.invoke(new functions.MessagesSetBotCallbackAnswer({
|
|
1569
|
+
queryId: BigInt(id),
|
|
1570
|
+
cacheTime: params?.cacheTime ?? 0,
|
|
1571
|
+
message: params?.text,
|
|
1572
|
+
alert: params?.alert ? true : undefined,
|
|
1573
|
+
}));
|
|
1574
|
+
}
|
|
1514
1575
|
}
|
|
1515
1576
|
const resolve = () => Promise.resolve();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
|
2
|
-
import { debug, Mutex } from "../
|
|
2
|
+
import { debug, Mutex } from "../0_deps.js";
|
|
3
3
|
import { ConnectionUnframed } from "./0_connection.js";
|
|
4
4
|
const d = debug("ConnectionWebSocket");
|
|
5
5
|
export class ConnectionWebSocket extends ConnectionUnframed {
|
package/esm/mod.d.ts
CHANGED
|
@@ -1,26 +1,12 @@
|
|
|
1
|
-
import { getRandomId } from "./
|
|
1
|
+
import { getRandomId } from "./1_utilities.js";
|
|
2
2
|
import { checkPassword } from "./client/0_password.js";
|
|
3
3
|
export declare const utils: {
|
|
4
4
|
checkPassword: typeof checkPassword;
|
|
5
5
|
getRandomId: typeof getRandomId;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
8
|
-
export *
|
|
9
|
-
export *
|
|
10
|
-
export * from "./
|
|
11
|
-
export
|
|
12
|
-
export * from "./
|
|
13
|
-
export * from "./client/2_client_plain.js";
|
|
14
|
-
export * from "./client/3_client.js";
|
|
15
|
-
export * from "./storage/0_storage.js";
|
|
16
|
-
export * from "./storage/1_storage_memory.js";
|
|
17
|
-
export * from "./storage/1_storage_local_storage.js";
|
|
18
|
-
export * from "./storage/1_storage_session_storage.js";
|
|
19
|
-
export * from "./storage/1_storage_indexed_db.js";
|
|
20
|
-
export * from "./transport/1_transport_abridged.js";
|
|
21
|
-
export * from "./transport/1_transport_intermediate.js";
|
|
22
|
-
export * from "./transport/0_transport.js";
|
|
23
|
-
export * from "./transport/2_transport_provider.js";
|
|
24
|
-
export * from "./connection/0_connection.js";
|
|
25
|
-
export * from "./connection/1_connection_web_socket.js";
|
|
26
|
-
export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, LAYER, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./constants.js";
|
|
7
|
+
export * from "./2_tl.js";
|
|
8
|
+
export * from "./2_connection.js";
|
|
9
|
+
export * from "./3_storage.js";
|
|
10
|
+
export * from "./3_transport.js";
|
|
11
|
+
export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, LAYER, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./4_constants.js";
|
|
12
|
+
export * from "./5_client.js";
|
package/esm/mod.js
CHANGED
|
@@ -1,23 +1,9 @@
|
|
|
1
|
-
import { getRandomId } from "./
|
|
1
|
+
import { getRandomId } from "./1_utilities.js";
|
|
2
2
|
import { checkPassword } from "./client/0_password.js";
|
|
3
3
|
export const utils = { checkPassword, getRandomId };
|
|
4
|
-
export
|
|
5
|
-
export *
|
|
6
|
-
export *
|
|
7
|
-
export * from "./
|
|
8
|
-
export
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./client/2_client_plain.js";
|
|
11
|
-
export * from "./client/3_client.js";
|
|
12
|
-
export * from "./storage/0_storage.js";
|
|
13
|
-
export * from "./storage/1_storage_memory.js";
|
|
14
|
-
export * from "./storage/1_storage_local_storage.js";
|
|
15
|
-
export * from "./storage/1_storage_session_storage.js";
|
|
16
|
-
export * from "./storage/1_storage_indexed_db.js";
|
|
17
|
-
export * from "./transport/1_transport_abridged.js";
|
|
18
|
-
export * from "./transport/1_transport_intermediate.js";
|
|
19
|
-
export * from "./transport/0_transport.js";
|
|
20
|
-
export * from "./transport/2_transport_provider.js";
|
|
21
|
-
export * from "./connection/0_connection.js";
|
|
22
|
-
export * from "./connection/1_connection_web_socket.js";
|
|
23
|
-
export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, LAYER, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./constants.js";
|
|
4
|
+
export * from "./2_tl.js";
|
|
5
|
+
export * from "./2_connection.js";
|
|
6
|
+
export * from "./3_storage.js";
|
|
7
|
+
export * from "./3_transport.js";
|
|
8
|
+
export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, LAYER, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./4_constants.js";
|
|
9
|
+
export * from "./5_client.js";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { MaybePromise } from "../
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import * as types from "../tl/2_types.js";
|
|
1
|
+
import { MaybePromise } from "../1_utilities.js";
|
|
2
|
+
import { TLObject, types } from "../2_tl.js";
|
|
3
|
+
import { DC } from "../3_transport.js";
|
|
5
4
|
export type StorageKeyPart = string | number | bigint | Uint8Array;
|
|
6
5
|
export declare abstract class Storage {
|
|
7
6
|
private _authKeyId;
|
|
@@ -21,7 +20,7 @@ export declare abstract class Storage {
|
|
|
21
20
|
updateUsernames(type: "user" | "channel", id: bigint, usernames: string[]): Promise<void>;
|
|
22
21
|
getUsername(username: string): Promise<["channel" | "user", bigint, Date] | null>;
|
|
23
22
|
setTlObject(key: readonly StorageKeyPart[], value: TLObject | null): Promise<void>;
|
|
24
|
-
getTLObject(key: readonly StorageKeyPart[]): Promise<import("../
|
|
23
|
+
getTLObject(key: readonly StorageKeyPart[]): Promise<import("../2_tl.js").ReadObject | null>;
|
|
25
24
|
setState(state: types.UpdatesState): Promise<void>;
|
|
26
25
|
getState(): Promise<types.UpdatesState | null>;
|
|
27
26
|
setMessage(chatId: number, messageId: number, message: types.TypeMessage | null): Promise<void>;
|
package/esm/storage/0_storage.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { UNREACHABLE } from "../
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { serialize } from "../tl/1_tl_object.js";
|
|
5
|
-
import * as types from "../tl/2_types.js";
|
|
6
|
-
import { TLReader } from "../tl/3_tl_reader.js";
|
|
7
|
-
import { rleDecode, rleEncode } from "../utilities/0_rle.js";
|
|
8
|
-
import { ZERO_CHANNEL_ID } from "../constants.js";
|
|
1
|
+
import { bigIntFromBuffer, rleDecode, rleEncode, sha1, UNREACHABLE } from "../1_utilities.js";
|
|
2
|
+
import { serialize, TLReader, types } from "../2_tl.js";
|
|
3
|
+
import { ZERO_CHANNEL_ID } from "../4_constants.js";
|
|
9
4
|
const KPARTS__DC = ["dc"];
|
|
10
5
|
const KPARTS__AUTH_KEY = ["authKey"];
|
|
11
6
|
const KPARTS__CHANNEL_ACCESS_HASH = (v) => ["channelAccessHash", v];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { base64Decode, base64Encode } from "../
|
|
2
|
-
import { UNREACHABLE } from "../
|
|
1
|
+
import { base64Decode, base64Encode } from "../0_deps.js";
|
|
2
|
+
import { UNREACHABLE } from "../1_utilities.js";
|
|
3
3
|
export var ValueType;
|
|
4
4
|
(function (ValueType) {
|
|
5
5
|
ValueType[ValueType["Boolean"] = 0] = "Boolean";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MaybePromise } from "../
|
|
1
|
+
import { MaybePromise } from "../1_utilities.js";
|
|
2
2
|
import { Storage, StorageKeyPart } from "./0_storage.js";
|
|
3
3
|
export declare class StorageLocalStorage extends Storage implements Storage {
|
|
4
4
|
private readonly prefix;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MaybePromise } from "../
|
|
1
|
+
import { MaybePromise } from "../1_utilities.js";
|
|
2
2
|
import { Storage, StorageKeyPart } from "./0_storage.js";
|
|
3
3
|
export declare class StorageMemory extends Storage implements Storage {
|
|
4
4
|
protected map: Map<string, unknown>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MaybePromise } from "../
|
|
1
|
+
import { MaybePromise } from "../1_utilities.js";
|
|
2
2
|
import { Storage, StorageKeyPart } from "./0_storage.js";
|
|
3
3
|
export declare class StorageSessionStorage extends Storage implements Storage {
|
|
4
4
|
private readonly prefix;
|
package/esm/tl/1_tl_object.js
CHANGED
package/esm/tl/3_deserialize.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assertEquals } from "../
|
|
1
|
+
import { assertEquals } from "../0_deps.js";
|
|
2
2
|
import { analyzeOptionalParam, flags, isOptionalParam, isTLObjectConstructor, paramDesc } from "./1_tl_object.js";
|
|
3
3
|
import { map } from "./2_types.js";
|
|
4
4
|
function deserializeSingleParam(reader, type, ntype) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { UNREACHABLE } from "../1_utilities.js";
|
|
2
|
+
import { ZERO_CHANNEL_ID } from "../4_constants.js";
|
|
3
|
+
import * as types from "./2_types.js";
|
|
4
|
+
export function getChannelChatId(channelId) {
|
|
5
|
+
return ZERO_CHANNEL_ID + -Number(channelId);
|
|
6
|
+
}
|
|
7
|
+
export function peerToChatId(peer) {
|
|
8
|
+
if (peer instanceof types.PeerUser || peer instanceof types.InputPeerUser) {
|
|
9
|
+
return Number(peer.userId);
|
|
10
|
+
}
|
|
11
|
+
else if (peer instanceof types.PeerChat || peer instanceof types.InputPeerChat) {
|
|
12
|
+
return -Number(peer.chatId);
|
|
13
|
+
}
|
|
14
|
+
else if (peer instanceof types.PeerChannel || peer instanceof types.InputPeerChannel) {
|
|
15
|
+
return getChannelChatId(peer.channelId);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
UNREACHABLE();
|
|
19
|
+
}
|
|
20
|
+
}
|
package/esm/tl/4_tl_writer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CTR } from "../
|
|
2
|
-
import { Connection } from "../
|
|
1
|
+
import { CTR } from "../1_utilities.js";
|
|
2
|
+
import { Connection } from "../2_connection.js";
|
|
3
3
|
export declare function getObfuscationParameters(protocol: number, connection: Connection): Promise<{
|
|
4
4
|
encryptionCTR: CTR;
|
|
5
5
|
decryptionCTR: CTR;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
|
2
|
-
import { bufferFromBigInt, concat } from "../
|
|
3
|
-
import { CTR } from "../utilities/0_crypto.js";
|
|
2
|
+
import { bufferFromBigInt, concat, CTR } from "../1_utilities.js";
|
|
4
3
|
export async function getObfuscationParameters(protocol, connection) {
|
|
5
4
|
const dc = 0xFCFF;
|
|
6
5
|
let init;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { MaybePromise } from "../
|
|
2
|
-
import { CTR } from "../utilities/0_crypto.js";
|
|
1
|
+
import { CTR, MaybePromise } from "../1_utilities.js";
|
|
3
2
|
export declare abstract class Transport {
|
|
4
3
|
protected initialized: boolean;
|
|
5
4
|
protected obfuscationParameters: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bufferFromBigInt, concat } from "../
|
|
1
|
+
import { bufferFromBigInt, concat } from "../1_utilities.js";
|
|
2
2
|
import { getObfuscationParameters } from "./0_obfuscation.js";
|
|
3
3
|
import { Transport } from "./0_transport.js";
|
|
4
4
|
export class TransportAbridged extends Transport {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Connection } from "../
|
|
1
|
+
import { Connection } from "../2_connection.js";
|
|
2
2
|
import { Transport } from "./0_transport.js";
|
|
3
3
|
export declare class TransportIntermediate extends Transport implements Transport {
|
|
4
4
|
private readonly connection;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bufferFromBigInt, concat } from "../
|
|
1
|
+
import { bufferFromBigInt, concat } from "../1_utilities.js";
|
|
2
2
|
import { getObfuscationParameters } from "./0_obfuscation.js";
|
|
3
3
|
import { Transport } from "./0_transport.js";
|
|
4
4
|
export class TransportIntermediate extends Transport {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Connection } from "../
|
|
1
|
+
import { Connection } from "../2_connection.js";
|
|
2
2
|
import { Transport } from "./0_transport.js";
|
|
3
3
|
export type DC = "1" | "2" | "3" | "4" | "5" | "1-test" | "2-test" | "3-test";
|
|
4
4
|
export interface TransportProviderParams {
|
package/esm/types/!0_file_id.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// Direct port from Pyrogram
|
|
2
|
-
import { base64DecodeUrlSafe, base64EncodeUrlSafe } from "../
|
|
3
|
-
import {
|
|
4
|
-
import { rleDecode, rleEncode } from "../utilities/0_rle.js";
|
|
5
|
-
import { TLRawWriter } from "../tl/0_tl_raw_writer.js";
|
|
6
|
-
import { TLRawReader } from "../tl/0_tl_raw_reader.js";
|
|
2
|
+
import { base64DecodeUrlSafe, base64EncodeUrlSafe, rleDecode, rleEncode, UNREACHABLE } from "../1_utilities.js";
|
|
3
|
+
import { TLReader, TLWriter } from "../2_tl.js";
|
|
7
4
|
export var FileType;
|
|
8
5
|
(function (FileType) {
|
|
9
6
|
FileType[FileType["Thumbnail"] = 0] = "Thumbnail";
|
|
@@ -96,7 +93,7 @@ class FileID {
|
|
|
96
93
|
minor = decoded[decoded.length - 2];
|
|
97
94
|
buffer = decoded.slice(0, -2);
|
|
98
95
|
}
|
|
99
|
-
const reader = new
|
|
96
|
+
const reader = new TLReader(buffer);
|
|
100
97
|
let fileType = reader.readInt32();
|
|
101
98
|
const dcId = reader.readInt32();
|
|
102
99
|
const hasWebLocation = Boolean(fileType & WEB_LOCATION_FLAG);
|
|
@@ -159,7 +156,7 @@ class FileID {
|
|
|
159
156
|
encode(major, minor) {
|
|
160
157
|
major ??= this.major;
|
|
161
158
|
minor ??= this.minor;
|
|
162
|
-
const writer = new
|
|
159
|
+
const writer = new TLWriter();
|
|
163
160
|
let fileType = this.fileType;
|
|
164
161
|
if (this.params.url) {
|
|
165
162
|
fileType |= WEB_LOCATION_FLAG;
|
|
@@ -274,7 +271,7 @@ export class FileUniqueID {
|
|
|
274
271
|
});
|
|
275
272
|
}
|
|
276
273
|
static decode(fileId) {
|
|
277
|
-
const reader = new
|
|
274
|
+
const reader = new TLReader(rleDecode(base64DecodeUrlSafe(fileId)));
|
|
278
275
|
const fileUniqueType = reader.readInt32();
|
|
279
276
|
switch (fileUniqueType) {
|
|
280
277
|
case FileUniqueType.Web: {
|
|
@@ -295,7 +292,7 @@ export class FileUniqueID {
|
|
|
295
292
|
}
|
|
296
293
|
}
|
|
297
294
|
encode() {
|
|
298
|
-
const writer = new
|
|
295
|
+
const writer = new TLWriter();
|
|
299
296
|
writer.writeInt32(this.fileUniqueType);
|
|
300
297
|
switch (this.fileUniqueType) {
|
|
301
298
|
case FileUniqueType.Web:
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MaybePromise } from "../1_utilities.js";
|
|
2
|
+
import { types } from "../2_tl.js";
|
|
3
|
+
export interface EntityGetter {
|
|
4
|
+
(peer: types.PeerUser): MaybePromise<types.User | null>;
|
|
5
|
+
(peer: types.PeerChat): MaybePromise<types.Chat | null>;
|
|
6
|
+
(peer: types.PeerChannel): MaybePromise<types.Channel | null>;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|