@mtkruto/node 0.1.142 → 0.1.144
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/3_types.d.ts +1 -0
- package/esm/3_types.js +1 -0
- package/esm/4_constants.d.ts +1 -1
- package/esm/4_constants.js +1 -1
- package/esm/client/0_message.js +9 -9
- package/esm/client/0_types.d.ts +1 -0
- package/esm/client/1_bot_info_manager.d.ts +30 -0
- package/esm/client/1_bot_info_manager.js +66 -0
- package/esm/client/1_file_manager.js +1 -1
- package/esm/client/1_network_statistics_manager.d.ts +19 -0
- package/esm/client/1_network_statistics_manager.js +48 -0
- package/esm/client/2_client_plain.js +4 -4
- package/esm/client/2_message_manager.d.ts +11 -2
- package/esm/client/2_message_manager.js +170 -1
- package/esm/client/3_callback_query_manager.js +1 -1
- package/esm/client/3_inline_query_manager.js +2 -1
- package/esm/client/4_client.d.ts +21 -12
- package/esm/client/4_client.js +134 -311
- package/esm/storage/0_storage.js +1 -1
- package/esm/tl/0_tl_raw_reader.js +3 -2
- package/esm/tl/0_tl_raw_writer.js +3 -3
- package/esm/transport/0_obfuscation.js +2 -2
- package/esm/transport/1_transport_abridged.js +1 -1
- package/esm/transport/1_transport_intermediate.js +1 -1
- package/esm/types/0__file_id.js +2 -2
- package/esm/types/0_chat_member_rights.d.ts +3 -0
- package/esm/types/0_chat_member_rights.js +45 -1
- package/esm/types/2_chat_member.d.ts +46 -0
- package/esm/types/2_chat_member.js +89 -0
- package/package.json +1 -1
- package/script/3_types.d.ts +1 -0
- package/script/3_types.js +1 -0
- package/script/4_constants.d.ts +1 -1
- package/script/4_constants.js +1 -1
- package/script/client/0_message.js +9 -9
- package/script/client/0_types.d.ts +1 -0
- package/script/client/1_bot_info_manager.d.ts +30 -0
- package/script/client/1_bot_info_manager.js +70 -0
- package/script/client/1_file_manager.js +1 -1
- package/script/client/1_network_statistics_manager.d.ts +19 -0
- package/script/client/1_network_statistics_manager.js +52 -0
- package/script/client/2_client_plain.js +4 -4
- package/script/client/2_message_manager.d.ts +11 -2
- package/script/client/2_message_manager.js +169 -0
- package/script/client/3_callback_query_manager.js +1 -1
- package/script/client/3_inline_query_manager.js +2 -1
- package/script/client/4_client.d.ts +21 -12
- package/script/client/4_client.js +131 -308
- package/script/storage/0_storage.js +1 -1
- package/script/tl/0_tl_raw_reader.js +3 -2
- package/script/tl/0_tl_raw_writer.js +3 -3
- package/script/transport/0_obfuscation.js +2 -2
- package/script/transport/1_transport_abridged.js +1 -1
- package/script/transport/1_transport_intermediate.js +1 -1
- package/script/types/0__file_id.js +2 -2
- package/script/types/0_chat_member_rights.d.ts +3 -0
- package/script/types/0_chat_member_rights.js +48 -0
- package/script/types/2_chat_member.d.ts +46 -0
- package/script/types/2_chat_member.js +93 -0
package/esm/client/4_client.js
CHANGED
|
@@ -9,23 +9,24 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _Client_instances, _Client_auth, _Client_sessionId, _Client_state, _Client_promises, _Client_toAcknowledge, _Client_guaranteeUpdateDelivery, _Client_updateManager, _Client_fileManager, _Client_reactionManager, _Client_messageManager, _Client_callbackQueryManager, _Client_inlineQueryManager, _Client_chatListManager, _Client_parseMode, _Client_publicKeys, _Client_autoStart, _Client_ignoreOutgoing, _Client_prefixes, _Client_namespaceProxies, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_setAuth, _Client_storageInited, _Client_initStorage, _Client_connectMutex, _Client_connectionInited, _Client_initConnection, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_selfId, _Client_getSelfId, _Client_receiveLoop, _Client_pingLoopAbortSignal, _Client_pingInterval, _Client_lastUpdates, _Client_pingLoop, _Client_pingLoopStarted, _Client_autoStarted, _Client_lastMsgId, _Client_invoke, _Client_handleInvokeError, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerInner,
|
|
12
|
+
var _Client_instances, _Client_auth, _Client_sessionId, _Client_state, _Client_promises, _Client_toAcknowledge, _Client_guaranteeUpdateDelivery, _Client_updateManager, _Client_networkStatisticsManager, _Client_botInfoManager, _Client_fileManager, _Client_reactionManager, _Client_messageManager, _Client_callbackQueryManager, _Client_inlineQueryManager, _Client_chatListManager, _Client_parseMode, _Client_publicKeys, _Client_autoStart, _Client_ignoreOutgoing, _Client_prefixes, _Client_namespaceProxies, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_setAuth, _Client_storageInited, _Client_initStorage, _Client_connectMutex, _Client_connectionInited, _Client_initConnection, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_selfId, _Client_getSelfId, _Client_receiveLoop, _Client_pingLoopAbortSignal, _Client_pingInterval, _Client_lastUpdates, _Client_pingLoop, _Client_pingLoopStarted, _Client_autoStarted, _Client_lastMsgId, _Client_invoke, _Client_handleInvokeError, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe, _Client_handle;
|
|
13
13
|
import { debug, gunzip, Mutex } from "../0_deps.js";
|
|
14
|
-
import { bigIntFromBuffer, cleanObject, drop, getRandomBigInt, getRandomId, mustPrompt, mustPromptOneOf, sha1,
|
|
14
|
+
import { bigIntFromBuffer, cleanObject, drop, getRandomBigInt, getRandomId, mustPrompt, mustPromptOneOf, sha1, UNREACHABLE, ZERO_CHANNEL_ID } from "../1_utilities.js";
|
|
15
15
|
import { as, functions, Message_, MessageContainer, name, RPCResult, TLError, TLReader, types } from "../2_tl.js";
|
|
16
16
|
import { StorageMemory } from "../3_storage.js";
|
|
17
|
-
import {
|
|
17
|
+
import { constructUser } from "../3_types.js";
|
|
18
18
|
import { ACK_THRESHOLD, APP_VERSION, DEVICE_MODEL, LANG_CODE, LANG_PACK, LAYER, MAX_CHANNEL_ID, MAX_CHAT_ID, SYSTEM_LANG_CODE, SYSTEM_VERSION, USERNAME_TTL } from "../4_constants.js";
|
|
19
19
|
import { AuthKeyUnregistered, FloodWait, Migrate, PasswordHashInvalid, PhoneNumberInvalid, SessionPasswordNeeded, upgradeInstance } from "../4_errors.js";
|
|
20
20
|
import { ClientAbstract } from "./0_client_abstract.js";
|
|
21
21
|
import { match } from "./0_filters.js";
|
|
22
|
-
import { parseHtml } from "./0_html.js";
|
|
23
22
|
import { decryptMessage, encryptMessage, getMessageId } from "./0_message.js";
|
|
24
23
|
import { checkPassword } from "./0_password.js";
|
|
25
24
|
import { ConnectionError } from "./0_types.js";
|
|
26
|
-
import {
|
|
25
|
+
import { getUsername, resolve } from "./0_utilities.js";
|
|
26
|
+
import { BotInfoManager } from "./1_bot_info_manager.js";
|
|
27
27
|
import { Composer, concat, flatten, skip } from "./1_composer.js";
|
|
28
28
|
import { FileManager } from "./1_file_manager.js";
|
|
29
|
+
import { NetworkStatisticsManager } from "./1_network_statistics_manager.js";
|
|
29
30
|
import { ReactionManager } from "./1_reaction_manager.js";
|
|
30
31
|
import { UpdateManager } from "./1_update_manager.js";
|
|
31
32
|
import { ClientPlain } from "./2_client_plain.js";
|
|
@@ -73,6 +74,8 @@ export class Client extends ClientAbstract {
|
|
|
73
74
|
_Client_toAcknowledge.set(this, new Set());
|
|
74
75
|
_Client_guaranteeUpdateDelivery.set(this, void 0);
|
|
75
76
|
_Client_updateManager.set(this, void 0);
|
|
77
|
+
_Client_networkStatisticsManager.set(this, void 0);
|
|
78
|
+
_Client_botInfoManager.set(this, void 0);
|
|
76
79
|
_Client_fileManager.set(this, void 0);
|
|
77
80
|
_Client_reactionManager.set(this, void 0);
|
|
78
81
|
_Client_messageManager.set(this, void 0);
|
|
@@ -320,6 +323,10 @@ export class Client extends ClientAbstract {
|
|
|
320
323
|
}
|
|
321
324
|
return this.setChatMemberRights(chatId, senderId, params);
|
|
322
325
|
},
|
|
326
|
+
getChatAdministrators: () => {
|
|
327
|
+
const { chatId } = mustGetMsg();
|
|
328
|
+
return this.getChatAdministrators(chatId);
|
|
329
|
+
},
|
|
323
330
|
react: (reactions, params) => {
|
|
324
331
|
const { chatId, messageId } = mustGetMsg();
|
|
325
332
|
return this.setReactions(chatId, messageId, reactions, params);
|
|
@@ -557,9 +564,12 @@ export class Client extends ClientAbstract {
|
|
|
557
564
|
disconnect: client.disconnect.bind(client),
|
|
558
565
|
};
|
|
559
566
|
},
|
|
567
|
+
cdn: params?.cdn ?? false,
|
|
560
568
|
ignoreOutgoing: __classPrivateFieldGet(this, _Client_ignoreOutgoing, "f"),
|
|
561
569
|
};
|
|
562
570
|
__classPrivateFieldSet(this, _Client_updateManager, new UpdateManager(c), "f");
|
|
571
|
+
__classPrivateFieldSet(this, _Client_networkStatisticsManager, new NetworkStatisticsManager(c), "f");
|
|
572
|
+
__classPrivateFieldSet(this, _Client_botInfoManager, new BotInfoManager(c), "f");
|
|
563
573
|
__classPrivateFieldSet(this, _Client_fileManager, new FileManager(c), "f");
|
|
564
574
|
__classPrivateFieldSet(this, _Client_reactionManager, new ReactionManager(c), "f");
|
|
565
575
|
__classPrivateFieldSet(this, _Client_messageManager, new MessageManager({ ...c, fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f") }), "f");
|
|
@@ -570,16 +580,7 @@ export class Client extends ClientAbstract {
|
|
|
570
580
|
const transportProvider = this.transportProvider;
|
|
571
581
|
this.transportProvider = (params) => {
|
|
572
582
|
const transport = transportProvider(params);
|
|
573
|
-
transport.connection.callback =
|
|
574
|
-
read: async (count) => {
|
|
575
|
-
const key = params.cdn ? "netstat_cdn_read" : "netstat_messages_read";
|
|
576
|
-
await this.storage.incr([key], count);
|
|
577
|
-
},
|
|
578
|
-
write: async (count) => {
|
|
579
|
-
const key = params.cdn ? "netstat_cdn_write" : "netstat_messages_write";
|
|
580
|
-
await this.storage.incr([key], count);
|
|
581
|
-
},
|
|
582
|
-
};
|
|
583
|
+
transport.connection.callback = __classPrivateFieldGet(this, _Client_networkStatisticsManager, "f").getTransportReadWriteCallback();
|
|
583
584
|
return transport;
|
|
584
585
|
};
|
|
585
586
|
if (params?.defaultHandlers ?? true) {
|
|
@@ -689,7 +690,7 @@ export class Client extends ClientAbstract {
|
|
|
689
690
|
release();
|
|
690
691
|
}
|
|
691
692
|
}
|
|
692
|
-
async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = new WeakMap(), _Client_guaranteeUpdateDelivery = new WeakMap(), _Client_updateManager = new WeakMap(), _Client_fileManager = new WeakMap(), _Client_reactionManager = new WeakMap(), _Client_messageManager = new WeakMap(), _Client_callbackQueryManager = new WeakMap(), _Client_inlineQueryManager = new WeakMap(), _Client_chatListManager = new WeakMap(), _Client_parseMode = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_autoStart = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_prefixes = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_pingLoopAbortSignal = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_handle = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
|
|
693
|
+
async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = new WeakMap(), _Client_guaranteeUpdateDelivery = new WeakMap(), _Client_updateManager = new WeakMap(), _Client_networkStatisticsManager = new WeakMap(), _Client_botInfoManager = new WeakMap(), _Client_fileManager = new WeakMap(), _Client_reactionManager = new WeakMap(), _Client_messageManager = new WeakMap(), _Client_callbackQueryManager = new WeakMap(), _Client_inlineQueryManager = new WeakMap(), _Client_chatListManager = new WeakMap(), _Client_parseMode = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_autoStart = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_prefixes = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_pingLoopAbortSignal = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_handle = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
|
|
693
694
|
__classPrivateFieldGet(this, _Client_instances, "m", _Client_queueHandleCtxUpdate).call(this, { connectionState });
|
|
694
695
|
__classPrivateFieldSet(this, _Client_lastPropagatedConnectionState, connectionState, "f");
|
|
695
696
|
}, _Client_setAuth = async function _Client_setAuth(key) {
|
|
@@ -741,16 +742,6 @@ export class Client extends ClientAbstract {
|
|
|
741
742
|
if (!this.apiHash) {
|
|
742
743
|
throw new Error("apiHash not set");
|
|
743
744
|
}
|
|
744
|
-
if (typeof params === "undefined") {
|
|
745
|
-
const loginType = mustPromptOneOf("Do you want to login as bot [b] or user [u]?", ["b", "u"]);
|
|
746
|
-
if (loginType == "b") {
|
|
747
|
-
params = mustPrompt("Bot token:");
|
|
748
|
-
}
|
|
749
|
-
else {
|
|
750
|
-
params = { phone: () => mustPrompt("Phone number:"), code: () => mustPrompt("Verification code:"), password: () => mustPrompt("Password:") };
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
dAuth("authorizing with %s", typeof params === "string" ? "bot token" : params instanceof types.auth.ExportedAuthorization ? "exported authorization" : "AuthorizeUserParams");
|
|
754
745
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initConnection).call(this);
|
|
755
746
|
try {
|
|
756
747
|
await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("authorize");
|
|
@@ -764,6 +755,16 @@ export class Client extends ClientAbstract {
|
|
|
764
755
|
throw err;
|
|
765
756
|
}
|
|
766
757
|
}
|
|
758
|
+
if (typeof params === "undefined") {
|
|
759
|
+
const loginType = mustPromptOneOf("Do you want to login as bot [b] or user [u]?", ["b", "u"]);
|
|
760
|
+
if (loginType == "b") {
|
|
761
|
+
params = mustPrompt("Bot token:");
|
|
762
|
+
}
|
|
763
|
+
else {
|
|
764
|
+
params = { phone: () => mustPrompt("Phone number:"), code: () => mustPrompt("Verification code:"), password: () => mustPrompt("Password:") };
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
dAuth("authorizing with %s", typeof params === "string" ? "bot token" : params instanceof types.auth.ExportedAuthorization ? "exported authorization" : "AuthorizeUserParams");
|
|
767
768
|
if (typeof params === "string") {
|
|
768
769
|
while (true) {
|
|
769
770
|
try {
|
|
@@ -901,7 +902,6 @@ export class Client extends ClientAbstract {
|
|
|
901
902
|
*/
|
|
902
903
|
async start(params) {
|
|
903
904
|
await this.connect();
|
|
904
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initConnection).call(this);
|
|
905
905
|
await this.authorize(params);
|
|
906
906
|
}
|
|
907
907
|
/**
|
|
@@ -1226,6 +1226,77 @@ export class Client extends ClientAbstract {
|
|
|
1226
1226
|
const id = peer instanceof types.PeerUser ? peer.user_id : peer instanceof types.PeerChat ? peer.chat_id : peer instanceof types.PeerChannel ? peer.channel_id : UNREACHABLE();
|
|
1227
1227
|
return this.storage.getEntity(type, id);
|
|
1228
1228
|
}
|
|
1229
|
+
use(...middleware) {
|
|
1230
|
+
const composer = new Composer(...middleware);
|
|
1231
|
+
__classPrivateFieldSet(this, _Client_handle, concat(__classPrivateFieldGet(this, _Client_handle, "f"), flatten(composer)), "f");
|
|
1232
|
+
return composer;
|
|
1233
|
+
}
|
|
1234
|
+
branch(predicate, trueHandler_, falseHandler_) {
|
|
1235
|
+
const trueHandler = flatten(trueHandler_);
|
|
1236
|
+
const falseHandler = flatten(falseHandler_);
|
|
1237
|
+
return this.use(async (upd, next) => {
|
|
1238
|
+
if (await predicate(upd)) {
|
|
1239
|
+
await trueHandler(upd, next);
|
|
1240
|
+
}
|
|
1241
|
+
else {
|
|
1242
|
+
await falseHandler(upd, next);
|
|
1243
|
+
}
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
filter(predicate, ...middleware) {
|
|
1247
|
+
const composer = new Composer(...middleware);
|
|
1248
|
+
this.branch(predicate, composer, skip);
|
|
1249
|
+
return composer;
|
|
1250
|
+
}
|
|
1251
|
+
on(filter, ...middleawre) {
|
|
1252
|
+
return this.filter((ctx) => {
|
|
1253
|
+
return match(filter, ctx);
|
|
1254
|
+
}, ...middleawre);
|
|
1255
|
+
}
|
|
1256
|
+
command(commands, ...middleawre) {
|
|
1257
|
+
const commands__ = typeof commands === "object" && "names" in commands ? commands.names : commands;
|
|
1258
|
+
const commands_ = Array.isArray(commands__) ? commands__ : [commands__];
|
|
1259
|
+
const prefixes_ = typeof commands === "object" && "prefixes" in commands ? commands.prefixes : (__classPrivateFieldGet(this, _Client_prefixes, "f") ?? []);
|
|
1260
|
+
const prefixes = Array.isArray(prefixes_) ? prefixes_ : [prefixes_];
|
|
1261
|
+
for (const left of prefixes) {
|
|
1262
|
+
for (const right of prefixes) {
|
|
1263
|
+
if (left == right) {
|
|
1264
|
+
continue;
|
|
1265
|
+
}
|
|
1266
|
+
if (left.startsWith(right) || right.startsWith(left)) {
|
|
1267
|
+
throw new Error("Intersecting prefixes");
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
return this.on("message:text").filter((ctx) => {
|
|
1272
|
+
const prefixes_ = prefixes.length == 0 ? [!ctx.me?.isBot ? "\\" : "/"] : prefixes;
|
|
1273
|
+
if (prefixes_.length == 0) {
|
|
1274
|
+
return false;
|
|
1275
|
+
}
|
|
1276
|
+
const cmd = ctx.message.text.split(/\s/, 1)[0];
|
|
1277
|
+
const prefix = prefixes_.find((v) => cmd.startsWith(v));
|
|
1278
|
+
if (prefix === undefined) {
|
|
1279
|
+
return false;
|
|
1280
|
+
}
|
|
1281
|
+
if (cmd.includes("@")) {
|
|
1282
|
+
const username = cmd.split("@", 2)[1];
|
|
1283
|
+
if (username.toLowerCase() !== ctx.me.username?.toLowerCase()) {
|
|
1284
|
+
return false;
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
const command_ = cmd.split("@", 1)[0].split(prefix, 2)[1].toLowerCase();
|
|
1288
|
+
for (const command of commands_) {
|
|
1289
|
+
if (typeof command === "string" && (command.toLowerCase() == command_)) {
|
|
1290
|
+
return true;
|
|
1291
|
+
}
|
|
1292
|
+
else if (command instanceof RegExp && command.test(command_)) {
|
|
1293
|
+
return true;
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
return false;
|
|
1297
|
+
}, ...middleawre);
|
|
1298
|
+
}
|
|
1299
|
+
//#endregion
|
|
1229
1300
|
/**
|
|
1230
1301
|
* Send a text message.
|
|
1231
1302
|
*
|
|
@@ -1343,77 +1414,6 @@ export class Client extends ClientAbstract {
|
|
|
1343
1414
|
__classPrivateFieldSet(this, _Client_lastGetMe, user, "f");
|
|
1344
1415
|
return user;
|
|
1345
1416
|
}
|
|
1346
|
-
use(...middleware) {
|
|
1347
|
-
const composer = new Composer(...middleware);
|
|
1348
|
-
__classPrivateFieldSet(this, _Client_handle, concat(__classPrivateFieldGet(this, _Client_handle, "f"), flatten(composer)), "f");
|
|
1349
|
-
return composer;
|
|
1350
|
-
}
|
|
1351
|
-
branch(predicate, trueHandler_, falseHandler_) {
|
|
1352
|
-
const trueHandler = flatten(trueHandler_);
|
|
1353
|
-
const falseHandler = flatten(falseHandler_);
|
|
1354
|
-
return this.use(async (upd, next) => {
|
|
1355
|
-
if (await predicate(upd)) {
|
|
1356
|
-
await trueHandler(upd, next);
|
|
1357
|
-
}
|
|
1358
|
-
else {
|
|
1359
|
-
await falseHandler(upd, next);
|
|
1360
|
-
}
|
|
1361
|
-
});
|
|
1362
|
-
}
|
|
1363
|
-
filter(predicate, ...middleware) {
|
|
1364
|
-
const composer = new Composer(...middleware);
|
|
1365
|
-
this.branch(predicate, composer, skip);
|
|
1366
|
-
return composer;
|
|
1367
|
-
}
|
|
1368
|
-
on(filter, ...middleawre) {
|
|
1369
|
-
return this.filter((ctx) => {
|
|
1370
|
-
return match(filter, ctx);
|
|
1371
|
-
}, ...middleawre);
|
|
1372
|
-
}
|
|
1373
|
-
command(commands, ...middleawre) {
|
|
1374
|
-
const commands__ = typeof commands === "object" && "names" in commands ? commands.names : commands;
|
|
1375
|
-
const commands_ = Array.isArray(commands__) ? commands__ : [commands__];
|
|
1376
|
-
const prefixes_ = typeof commands === "object" && "prefixes" in commands ? commands.prefixes : (__classPrivateFieldGet(this, _Client_prefixes, "f") ?? []);
|
|
1377
|
-
const prefixes = Array.isArray(prefixes_) ? prefixes_ : [prefixes_];
|
|
1378
|
-
for (const left of prefixes) {
|
|
1379
|
-
for (const right of prefixes) {
|
|
1380
|
-
if (left == right) {
|
|
1381
|
-
continue;
|
|
1382
|
-
}
|
|
1383
|
-
if (left.startsWith(right) || right.startsWith(left)) {
|
|
1384
|
-
throw new Error("Intersecting prefixes");
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
return this.on("message:text").filter((ctx) => {
|
|
1389
|
-
const prefixes_ = prefixes.length == 0 ? [!ctx.me?.isBot ? "\\" : "/"] : prefixes;
|
|
1390
|
-
if (prefixes_.length == 0) {
|
|
1391
|
-
return false;
|
|
1392
|
-
}
|
|
1393
|
-
const cmd = ctx.message.text.split(/\s/, 1)[0];
|
|
1394
|
-
const prefix = prefixes_.find((v) => cmd.startsWith(v));
|
|
1395
|
-
if (prefix === undefined) {
|
|
1396
|
-
return false;
|
|
1397
|
-
}
|
|
1398
|
-
if (cmd.includes("@")) {
|
|
1399
|
-
const username = cmd.split("@", 2)[1];
|
|
1400
|
-
if (username.toLowerCase() !== ctx.me.username?.toLowerCase()) {
|
|
1401
|
-
return false;
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
const command_ = cmd.split("@", 1)[0].split(prefix, 2)[1].toLowerCase();
|
|
1405
|
-
for (const command of commands_) {
|
|
1406
|
-
if (typeof command === "string" && (command.toLowerCase() == command_)) {
|
|
1407
|
-
return true;
|
|
1408
|
-
}
|
|
1409
|
-
else if (command instanceof RegExp && command.test(command_)) {
|
|
1410
|
-
return true;
|
|
1411
|
-
}
|
|
1412
|
-
}
|
|
1413
|
-
return false;
|
|
1414
|
-
}, ...middleawre);
|
|
1415
|
-
}
|
|
1416
|
-
//#endregion
|
|
1417
1417
|
/**
|
|
1418
1418
|
* Answer a callback query. Bot-only.
|
|
1419
1419
|
*
|
|
@@ -1444,45 +1444,7 @@ export class Client extends ClientAbstract {
|
|
|
1444
1444
|
* @param messageThreadId The thread to send the chat action to.
|
|
1445
1445
|
*/
|
|
1446
1446
|
async sendChatAction(chatId, action, params) {
|
|
1447
|
-
|
|
1448
|
-
switch (action) {
|
|
1449
|
-
case "type":
|
|
1450
|
-
action_ = new types.SendMessageTypingAction();
|
|
1451
|
-
break;
|
|
1452
|
-
case "uploadPhoto":
|
|
1453
|
-
action_ = new types.SendMessageUploadPhotoAction({ progress: 0 });
|
|
1454
|
-
break;
|
|
1455
|
-
case "recordVideo":
|
|
1456
|
-
action_ = new types.SendMessageRecordVideoAction();
|
|
1457
|
-
break;
|
|
1458
|
-
case "uploadVideo":
|
|
1459
|
-
action_ = new types.SendMessageRecordVideoAction();
|
|
1460
|
-
break;
|
|
1461
|
-
case "recordVoice":
|
|
1462
|
-
action_ = new types.SendMessageRecordAudioAction();
|
|
1463
|
-
break;
|
|
1464
|
-
case "uploadAudio":
|
|
1465
|
-
action_ = new types.SendMessageUploadAudioAction({ progress: 0 });
|
|
1466
|
-
break;
|
|
1467
|
-
case "uploadDocument":
|
|
1468
|
-
action_ = new types.SendMessageUploadDocumentAction({ progress: 0 });
|
|
1469
|
-
break;
|
|
1470
|
-
case "chooseSticker":
|
|
1471
|
-
action_ = new types.SendMessageChooseStickerAction();
|
|
1472
|
-
break;
|
|
1473
|
-
case "findLocation":
|
|
1474
|
-
action_ = new types.SendMessageGeoLocationAction();
|
|
1475
|
-
break;
|
|
1476
|
-
case "recordVideoNote":
|
|
1477
|
-
action_ = new types.SendMessageRecordRoundAction();
|
|
1478
|
-
break;
|
|
1479
|
-
case "uploadVideoNote":
|
|
1480
|
-
action_ = new types.SendMessageUploadRoundAction({ progress: 0 });
|
|
1481
|
-
break;
|
|
1482
|
-
default:
|
|
1483
|
-
throw new Error("Invalid chat action: " + action);
|
|
1484
|
-
}
|
|
1485
|
-
await this.api.messages.setTyping({ peer: await this.getInputPeer(chatId), action: action_, top_msg_id: params?.messageThreadId });
|
|
1447
|
+
return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendChatAction(chatId, action, params);
|
|
1486
1448
|
}
|
|
1487
1449
|
/**
|
|
1488
1450
|
* Upload a file.
|
|
@@ -1500,21 +1462,13 @@ export class Client extends ClientAbstract {
|
|
|
1500
1462
|
* @param commands The commands to set.
|
|
1501
1463
|
*/
|
|
1502
1464
|
async setMyCommands(commands, params) {
|
|
1503
|
-
await this.
|
|
1504
|
-
commands: commands.map((v) => new types.BotCommand(v)),
|
|
1505
|
-
lang_code: params?.languageCode ?? "",
|
|
1506
|
-
scope: await botCommandScopeToTlObject(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)),
|
|
1507
|
-
});
|
|
1465
|
+
await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyCommands(commands, params);
|
|
1508
1466
|
}
|
|
1509
1467
|
/**
|
|
1510
1468
|
* Get the bot's commands in the given scope and/or language. Bot-only.
|
|
1511
1469
|
*/
|
|
1512
1470
|
async getMyCommands(params) {
|
|
1513
|
-
|
|
1514
|
-
lang_code: params?.languageCode ?? "",
|
|
1515
|
-
scope: await botCommandScopeToTlObject(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)),
|
|
1516
|
-
});
|
|
1517
|
-
return commands_.map((v) => ({ command: v.command, description: v.description }));
|
|
1471
|
+
return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyCommands(params);
|
|
1518
1472
|
}
|
|
1519
1473
|
/**
|
|
1520
1474
|
* Answer an inline query. Bot-only.
|
|
@@ -1532,8 +1486,7 @@ export class Client extends ClientAbstract {
|
|
|
1532
1486
|
* @method
|
|
1533
1487
|
*/
|
|
1534
1488
|
async setMyDescription(params) {
|
|
1535
|
-
await this
|
|
1536
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setMyInfo).call(this, { description: params?.description, lang_code: params?.languageCode ?? "" });
|
|
1489
|
+
await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyDescription(params);
|
|
1537
1490
|
}
|
|
1538
1491
|
/**
|
|
1539
1492
|
* Set the bot's name in the given language. Bot-only.
|
|
@@ -1541,8 +1494,7 @@ export class Client extends ClientAbstract {
|
|
|
1541
1494
|
* @method
|
|
1542
1495
|
*/
|
|
1543
1496
|
async setMyName(params) {
|
|
1544
|
-
await this
|
|
1545
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setMyInfo).call(this, { name: params?.name, lang_code: params?.languageCode ?? "" });
|
|
1497
|
+
await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyName(params);
|
|
1546
1498
|
}
|
|
1547
1499
|
/**
|
|
1548
1500
|
* Set the bot's short description in the given language. Bot-only.
|
|
@@ -1550,8 +1502,7 @@ export class Client extends ClientAbstract {
|
|
|
1550
1502
|
* @method
|
|
1551
1503
|
*/
|
|
1552
1504
|
async setMyShortDescription(params) {
|
|
1553
|
-
await this
|
|
1554
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setMyInfo).call(this, { about: params?.shortDescription, lang_code: params?.languageCode ?? "" });
|
|
1505
|
+
await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyShortDescription(params);
|
|
1555
1506
|
}
|
|
1556
1507
|
/**
|
|
1557
1508
|
* Get the bot's description in the given language. Bot-only.
|
|
@@ -1559,8 +1510,7 @@ export class Client extends ClientAbstract {
|
|
|
1559
1510
|
* @method
|
|
1560
1511
|
*/
|
|
1561
1512
|
async getMyDescription(params) {
|
|
1562
|
-
await this
|
|
1563
|
-
return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMyInfo).call(this, params?.languageCode).then((v) => v.description);
|
|
1513
|
+
return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyDescription(params);
|
|
1564
1514
|
}
|
|
1565
1515
|
/**
|
|
1566
1516
|
* Set the bot's name in the given language. Bot-only.
|
|
@@ -1568,8 +1518,7 @@ export class Client extends ClientAbstract {
|
|
|
1568
1518
|
* @method
|
|
1569
1519
|
*/
|
|
1570
1520
|
async getMyName(params) {
|
|
1571
|
-
await this
|
|
1572
|
-
return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMyInfo).call(this, params?.languageCode).then((v) => v.description);
|
|
1521
|
+
return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyName(params);
|
|
1573
1522
|
}
|
|
1574
1523
|
/**
|
|
1575
1524
|
* Get the bot's short description in the given language. Bot-only.
|
|
@@ -1577,8 +1526,7 @@ export class Client extends ClientAbstract {
|
|
|
1577
1526
|
* @method
|
|
1578
1527
|
*/
|
|
1579
1528
|
async getMyShortDescription(params) {
|
|
1580
|
-
await this
|
|
1581
|
-
return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMyInfo).call(this, params?.languageCode).then((v) => v.about);
|
|
1529
|
+
return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyShortDescription(params);
|
|
1582
1530
|
}
|
|
1583
1531
|
/**
|
|
1584
1532
|
* Delete multiple messages.
|
|
@@ -1720,21 +1668,7 @@ export class Client extends ClientAbstract {
|
|
|
1720
1668
|
* @method
|
|
1721
1669
|
*/
|
|
1722
1670
|
async getNetworkStatistics() {
|
|
1723
|
-
|
|
1724
|
-
this.storage.get(["netstat_messages_read"]),
|
|
1725
|
-
this.storage.get(["netstat_messages_write"]),
|
|
1726
|
-
this.storage.get(["netstat_cdn_read"]),
|
|
1727
|
-
this.storage.get(["netstat_cdn_write"]),
|
|
1728
|
-
]);
|
|
1729
|
-
const messages = {
|
|
1730
|
-
sent: Number(messagesWrite || 0),
|
|
1731
|
-
received: Number(messagesRead || 0),
|
|
1732
|
-
};
|
|
1733
|
-
const cdn = {
|
|
1734
|
-
sent: Number(cdnWrite || 0),
|
|
1735
|
-
received: Number(cdnRead || 0),
|
|
1736
|
-
};
|
|
1737
|
-
return { messages, cdn };
|
|
1671
|
+
return await __classPrivateFieldGet(this, _Client_networkStatisticsManager, "f").getNetworkStatistics();
|
|
1738
1672
|
}
|
|
1739
1673
|
/**
|
|
1740
1674
|
* Get chats from a chat list. User-only.
|
|
@@ -1821,19 +1755,7 @@ export class Client extends ClientAbstract {
|
|
|
1821
1755
|
* @param photo A photo to set as the chat's photo.
|
|
1822
1756
|
*/
|
|
1823
1757
|
async setChatPhoto(chatId, photo, params) {
|
|
1824
|
-
|
|
1825
|
-
if (!(peer instanceof types.InputPeerChannel) && !(peer instanceof types.InputPeerChat)) {
|
|
1826
|
-
UNREACHABLE();
|
|
1827
|
-
}
|
|
1828
|
-
const [contents, fileName] = await getFileContents(photo);
|
|
1829
|
-
const file = await this.upload(contents, { fileName: params?.fileName ?? fileName, chunkSize: params?.chunkSize, signal: params?.signal });
|
|
1830
|
-
const photo_ = new types.InputChatUploadedPhoto({ file });
|
|
1831
|
-
if (peer instanceof types.InputPeerChannel) {
|
|
1832
|
-
await this.api.channels.editPhoto({ channel: new types.InputChannel(peer), photo: photo_ });
|
|
1833
|
-
}
|
|
1834
|
-
else if (peer instanceof types.InputPeerChat) {
|
|
1835
|
-
await this.api.messages.editChatPhoto({ chat_id: peer.chat_id, photo: photo_ });
|
|
1836
|
-
}
|
|
1758
|
+
await __classPrivateFieldGet(this, _Client_messageManager, "f").setChatPhoto(chatId, photo, params);
|
|
1837
1759
|
}
|
|
1838
1760
|
/**
|
|
1839
1761
|
* Delete a chat's photo.
|
|
@@ -1842,16 +1764,7 @@ export class Client extends ClientAbstract {
|
|
|
1842
1764
|
* @param chatId The identifier of the chat.
|
|
1843
1765
|
*/
|
|
1844
1766
|
async deleteChatPhoto(chatId) {
|
|
1845
|
-
|
|
1846
|
-
if (!(peer instanceof types.InputPeerChannel) && !(peer instanceof types.InputPeerChat)) {
|
|
1847
|
-
UNREACHABLE();
|
|
1848
|
-
}
|
|
1849
|
-
if (peer instanceof types.InputPeerChannel) {
|
|
1850
|
-
await this.api.channels.editPhoto({ channel: new types.InputChannel(peer), photo: new types.InputChatPhotoEmpty() });
|
|
1851
|
-
}
|
|
1852
|
-
else if (peer instanceof types.InputPeerChat) {
|
|
1853
|
-
await this.api.messages.editChatPhoto({ chat_id: peer.chat_id, photo: new types.InputChatPhotoEmpty() });
|
|
1854
|
-
}
|
|
1767
|
+
await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteChatPhoto(chatId);
|
|
1855
1768
|
}
|
|
1856
1769
|
/**
|
|
1857
1770
|
* Delete all messages sent by a specific member of a chat.
|
|
@@ -1900,46 +1813,7 @@ export class Client extends ClientAbstract {
|
|
|
1900
1813
|
* @param memberId The identifier of the member.
|
|
1901
1814
|
*/
|
|
1902
1815
|
async banChatMember(chatId, memberId, params) {
|
|
1903
|
-
|
|
1904
|
-
if (!(chat instanceof types.InputPeerChannel) && !(chat instanceof types.InputPeerChat)) {
|
|
1905
|
-
throw new Error("Invalid chat ID");
|
|
1906
|
-
}
|
|
1907
|
-
const member = await this.getInputPeer(memberId);
|
|
1908
|
-
if (chat instanceof types.InputPeerChannel) {
|
|
1909
|
-
if (params?.deleteMessages) {
|
|
1910
|
-
try {
|
|
1911
|
-
await this.deleteChatMemberMessages(chatId, memberId);
|
|
1912
|
-
}
|
|
1913
|
-
catch {
|
|
1914
|
-
//
|
|
1915
|
-
}
|
|
1916
|
-
}
|
|
1917
|
-
await this.api.channels.editBanned({
|
|
1918
|
-
channel: new types.InputChannel(chat),
|
|
1919
|
-
participant: member,
|
|
1920
|
-
banned_rights: new types.ChatBannedRights({
|
|
1921
|
-
until_date: params?.untilDate ? toUnixTimestamp(params.untilDate) : 0,
|
|
1922
|
-
view_messages: true,
|
|
1923
|
-
send_messages: true,
|
|
1924
|
-
send_media: true,
|
|
1925
|
-
send_stickers: true,
|
|
1926
|
-
send_gifs: true,
|
|
1927
|
-
send_games: true,
|
|
1928
|
-
send_inline: true,
|
|
1929
|
-
embed_links: true,
|
|
1930
|
-
}),
|
|
1931
|
-
});
|
|
1932
|
-
}
|
|
1933
|
-
else if (chat instanceof types.InputPeerChat) {
|
|
1934
|
-
if (!(member instanceof types.InputPeerUser)) {
|
|
1935
|
-
throw new Error("Invalid user ID");
|
|
1936
|
-
}
|
|
1937
|
-
await this.api.messages.deleteChatUser({
|
|
1938
|
-
chat_id: chat.chat_id,
|
|
1939
|
-
user_id: new types.InputUser(member),
|
|
1940
|
-
revoke_history: params?.deleteMessages ? true : undefined,
|
|
1941
|
-
});
|
|
1942
|
-
}
|
|
1816
|
+
await __classPrivateFieldGet(this, _Client_messageManager, "f").banChatMember(chatId, memberId, params);
|
|
1943
1817
|
}
|
|
1944
1818
|
/**
|
|
1945
1819
|
* Unban a member from a chat.
|
|
@@ -1949,16 +1823,7 @@ export class Client extends ClientAbstract {
|
|
|
1949
1823
|
* @param memberId The identifier of the member.
|
|
1950
1824
|
*/
|
|
1951
1825
|
async unbanChatMember(chatId, memberId) {
|
|
1952
|
-
|
|
1953
|
-
if (!(chat instanceof types.InputPeerChannel)) {
|
|
1954
|
-
throw new Error("Invalid chat ID");
|
|
1955
|
-
}
|
|
1956
|
-
const member = await this.getInputPeer(memberId);
|
|
1957
|
-
await this.api.channels.editBanned({
|
|
1958
|
-
channel: new types.InputChannel(chat),
|
|
1959
|
-
participant: member,
|
|
1960
|
-
banned_rights: new types.ChatBannedRights({ until_date: 0 }),
|
|
1961
|
-
});
|
|
1826
|
+
await __classPrivateFieldGet(this, _Client_messageManager, "f").unbanChatMember(chatId, memberId);
|
|
1962
1827
|
}
|
|
1963
1828
|
/**
|
|
1964
1829
|
* Kick a member from a chat. Same as a banChatMember call followed by unbanChatMember.
|
|
@@ -1968,8 +1833,8 @@ export class Client extends ClientAbstract {
|
|
|
1968
1833
|
* @param memberId The identifier of the member.
|
|
1969
1834
|
*/
|
|
1970
1835
|
async kickChatMember(chatId, memberId) {
|
|
1971
|
-
await this.banChatMember(chatId, memberId);
|
|
1972
|
-
await this.unbanChatMember(chatId, memberId);
|
|
1836
|
+
await __classPrivateFieldGet(this, _Client_messageManager, "f").banChatMember(chatId, memberId);
|
|
1837
|
+
await __classPrivateFieldGet(this, _Client_messageManager, "f").unbanChatMember(chatId, memberId);
|
|
1973
1838
|
}
|
|
1974
1839
|
/**
|
|
1975
1840
|
* Set the rights of a chat member.
|
|
@@ -1979,66 +1844,19 @@ export class Client extends ClientAbstract {
|
|
|
1979
1844
|
* @param memberId The identifier of a member.
|
|
1980
1845
|
*/
|
|
1981
1846
|
async setChatMemberRights(chatId, memberId, params) {
|
|
1982
|
-
|
|
1983
|
-
if (!(chat instanceof types.InputPeerChannel)) {
|
|
1984
|
-
throw new Error("Invalid chat ID");
|
|
1985
|
-
}
|
|
1986
|
-
const member = await this.getInputPeer(memberId);
|
|
1987
|
-
await this.api.channels.editBanned({
|
|
1988
|
-
channel: new types.InputChannel(chat),
|
|
1989
|
-
participant: member,
|
|
1990
|
-
banned_rights: new types.ChatBannedRights({
|
|
1991
|
-
until_date: params?.untilDate ? toUnixTimestamp(params.untilDate) : 0,
|
|
1992
|
-
send_messages: params?.rights?.canSendMessages ? true : undefined,
|
|
1993
|
-
send_audios: params?.rights?.canSendAudio ? true : undefined,
|
|
1994
|
-
send_docs: params?.rights?.canSendDocuments ? true : undefined,
|
|
1995
|
-
send_photos: params?.rights?.canSendPhotos ? true : undefined,
|
|
1996
|
-
send_videos: params?.rights?.canSendVideos ? true : undefined,
|
|
1997
|
-
send_roundvideos: params?.rights?.canSendVideoNotes ? true : undefined,
|
|
1998
|
-
send_voices: params?.rights?.canSendVoice ? true : undefined,
|
|
1999
|
-
send_polls: params?.rights?.canSendPolls ? true : undefined,
|
|
2000
|
-
send_stickers: params?.rights?.canSendStickers ? true : undefined,
|
|
2001
|
-
send_gifs: params?.rights?.canSendAnimations ? true : undefined,
|
|
2002
|
-
send_games: params?.rights?.canSendGames ? true : undefined,
|
|
2003
|
-
send_inline: params?.rights?.canSendInlineBotResults ? true : undefined,
|
|
2004
|
-
embed_links: params?.rights?.canAddWebPagePreviews ? true : undefined,
|
|
2005
|
-
change_info: params?.rights?.canChangeInfo ? true : undefined,
|
|
2006
|
-
invite_users: params?.rights?.canInviteUsers ? true : undefined,
|
|
2007
|
-
pin_messages: params?.rights?.canPinMessages ? true : undefined,
|
|
2008
|
-
manage_topics: params?.rights?.canManageTopics ? true : undefined,
|
|
2009
|
-
}),
|
|
2010
|
-
});
|
|
1847
|
+
await __classPrivateFieldGet(this, _Client_messageManager, "f").setChatMemberRights(chatId, memberId, params);
|
|
2011
1848
|
}
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
const [newText, entitiesToPush] = parseHtml(text);
|
|
2021
|
-
text = newText;
|
|
2022
|
-
for (const entity of entitiesToPush) {
|
|
2023
|
-
entities_.push(entity);
|
|
2024
|
-
}
|
|
2025
|
-
break;
|
|
2026
|
-
}
|
|
2027
|
-
default:
|
|
2028
|
-
UNREACHABLE();
|
|
2029
|
-
}
|
|
2030
|
-
const entities = entities_?.length > 0 ? entities_.map((v) => messageEntityToTlObject(v)) : undefined;
|
|
2031
|
-
return [text, entities];
|
|
2032
|
-
}, _Client_getMe = async function _Client_getMe() {
|
|
2033
|
-
if (__classPrivateFieldGet(this, _Client_lastGetMe, "f") != null) {
|
|
2034
|
-
return __classPrivateFieldGet(this, _Client_lastGetMe, "f");
|
|
2035
|
-
}
|
|
2036
|
-
else {
|
|
2037
|
-
const user = await this.getMe();
|
|
2038
|
-
__classPrivateFieldSet(this, _Client_lastGetMe, user, "f");
|
|
2039
|
-
return user;
|
|
1849
|
+
/**
|
|
1850
|
+
* Get the administrators of a chat.
|
|
1851
|
+
*
|
|
1852
|
+
* @method
|
|
1853
|
+
* @param chatId The identifier of the chat.
|
|
1854
|
+
*/
|
|
1855
|
+
async getChatAdministrators(chatId) {
|
|
1856
|
+
return await __classPrivateFieldGet(this, _Client_messageManager, "f").getChatAdministrators(chatId);
|
|
2040
1857
|
}
|
|
2041
|
-
}
|
|
1858
|
+
}
|
|
1859
|
+
_Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
|
|
2042
1860
|
await __classPrivateFieldGet(this, _Client_handle, "f").call(this, await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, update), resolve);
|
|
2043
1861
|
}, _Client_queueHandleCtxUpdate = function _Client_queueHandleCtxUpdate(update) {
|
|
2044
1862
|
__classPrivateFieldGet(this, _Client_updateManager, "f").getHandleUpdateQueue(UpdateManager.MAIN_BOX_ID).add(async () => {
|
|
@@ -2091,8 +1909,13 @@ _Client_parseText = function _Client_parseText(text, params) {
|
|
|
2091
1909
|
await __classPrivateFieldGet(this, _Client_chatListManager, "f").handleUpdate(update);
|
|
2092
1910
|
}
|
|
2093
1911
|
return () => Promise.all(promises);
|
|
2094
|
-
},
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
1912
|
+
}, _Client_getMe = async function _Client_getMe() {
|
|
1913
|
+
if (__classPrivateFieldGet(this, _Client_lastGetMe, "f") != null) {
|
|
1914
|
+
return __classPrivateFieldGet(this, _Client_lastGetMe, "f");
|
|
1915
|
+
}
|
|
1916
|
+
else {
|
|
1917
|
+
const user = await this.getMe();
|
|
1918
|
+
__classPrivateFieldSet(this, _Client_lastGetMe, user, "f");
|
|
1919
|
+
return user;
|
|
1920
|
+
}
|
|
2098
1921
|
};
|
package/esm/storage/0_storage.js
CHANGED
|
@@ -301,7 +301,7 @@ export class Storage {
|
|
|
301
301
|
}
|
|
302
302
|
_Storage_authKeyId = new WeakMap(), _Storage_instances = new WeakSet(), _Storage_resetAuthKeyId = async function _Storage_resetAuthKeyId(authKey) {
|
|
303
303
|
if (authKey != null) {
|
|
304
|
-
__classPrivateFieldSet(this, _Storage_authKeyId, await sha1(authKey).then((hash) => bigIntFromBuffer(hash.
|
|
304
|
+
__classPrivateFieldSet(this, _Storage_authKeyId, await sha1(authKey).then((hash) => bigIntFromBuffer(hash.subarray(-8), true, false)), "f");
|
|
305
305
|
}
|
|
306
306
|
else {
|
|
307
307
|
__classPrivateFieldSet(this, _Storage_authKeyId, null, "f");
|