@mtkruto/node 0.1.141 → 0.1.143
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/4_constants.d.ts +1 -1
- package/esm/4_constants.js +1 -1
- package/esm/5_client.d.ts +1 -0
- package/esm/5_client.js +1 -0
- package/esm/client/0_types.d.ts +2 -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_network_statistics_manager.d.ts +19 -0
- package/esm/client/1_network_statistics_manager.js +48 -0
- package/esm/client/1_reaction_manager.d.ts +9 -0
- package/esm/client/1_reaction_manager.js +84 -0
- package/esm/client/2_message_manager.d.ts +22 -2
- package/esm/client/2_message_manager.js +282 -28
- package/esm/client/3_callback_query_manager.d.ts +16 -0
- package/esm/client/3_callback_query_manager.js +36 -0
- package/esm/client/3_chat_list_manager.d.ts +5 -9
- package/esm/client/3_chat_list_manager.js +190 -103
- package/esm/client/3_inline_query_manager.d.ts +16 -0
- package/esm/client/3_inline_query_manager.js +49 -0
- package/esm/client/4_client.d.ts +12 -12
- package/esm/client/4_client.js +162 -538
- package/esm/client/5_session_string.d.ts +3 -0
- package/esm/client/5_session_string.js +22 -0
- package/esm/connection/1_connection_web_socket.js +1 -1
- package/package.json +1 -1
- package/script/4_constants.d.ts +1 -1
- package/script/4_constants.js +1 -1
- package/script/5_client.d.ts +1 -0
- package/script/5_client.js +1 -0
- package/script/client/0_types.d.ts +2 -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_network_statistics_manager.d.ts +19 -0
- package/script/client/1_network_statistics_manager.js +52 -0
- package/script/client/1_reaction_manager.d.ts +9 -0
- package/script/client/1_reaction_manager.js +88 -0
- package/script/client/2_message_manager.d.ts +22 -2
- package/script/client/2_message_manager.js +281 -27
- package/script/client/3_callback_query_manager.d.ts +16 -0
- package/script/client/3_callback_query_manager.js +40 -0
- package/script/client/3_chat_list_manager.d.ts +5 -9
- package/script/client/3_chat_list_manager.js +187 -100
- package/script/client/3_inline_query_manager.d.ts +16 -0
- package/script/client/3_inline_query_manager.js +53 -0
- package/script/client/4_client.d.ts +12 -12
- package/script/client/4_client.js +158 -534
- package/script/client/5_session_string.d.ts +3 -0
- package/script/client/5_session_string.js +27 -0
- package/script/connection/1_connection_web_socket.js +1 -1
- package/esm/client/3_reaction_manager.d.ts +0 -16
- package/esm/client/3_reaction_manager.js +0 -61
- package/script/client/3_reaction_manager.d.ts +0 -16
- package/script/client/3_reaction_manager.js +0 -65
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
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");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _Client_instances, _Client_auth, _Client_sessionId, _Client_state, _Client_promises, _Client_toAcknowledge, _Client_guaranteeUpdateDelivery, _Client_updateManager, _Client_fileManager, _Client_messageManager,
|
|
13
|
+
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;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.Client = exports.restartAuth = exports.skipInvoke = exports.handleMigrationError = void 0;
|
|
16
16
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
@@ -22,18 +22,21 @@ const _4_constants_js_1 = require("../4_constants.js");
|
|
|
22
22
|
const _4_errors_js_1 = require("../4_errors.js");
|
|
23
23
|
const _0_client_abstract_js_1 = require("./0_client_abstract.js");
|
|
24
24
|
const _0_filters_js_1 = require("./0_filters.js");
|
|
25
|
-
const _0_html_js_1 = require("./0_html.js");
|
|
26
25
|
const _0_message_js_1 = require("./0_message.js");
|
|
27
26
|
const _0_password_js_1 = require("./0_password.js");
|
|
28
27
|
const _0_types_js_1 = require("./0_types.js");
|
|
29
28
|
const _0_utilities_js_1 = require("./0_utilities.js");
|
|
29
|
+
const _1_bot_info_manager_js_1 = require("./1_bot_info_manager.js");
|
|
30
30
|
const _1_composer_js_1 = require("./1_composer.js");
|
|
31
31
|
const _1_file_manager_js_1 = require("./1_file_manager.js");
|
|
32
|
+
const _1_network_statistics_manager_js_1 = require("./1_network_statistics_manager.js");
|
|
33
|
+
const _1_reaction_manager_js_1 = require("./1_reaction_manager.js");
|
|
32
34
|
const _1_update_manager_js_1 = require("./1_update_manager.js");
|
|
33
35
|
const _2_client_plain_js_1 = require("./2_client_plain.js");
|
|
34
36
|
const _2_message_manager_js_1 = require("./2_message_manager.js");
|
|
37
|
+
const _3_callback_query_manager_js_1 = require("./3_callback_query_manager.js");
|
|
35
38
|
const _3_chat_list_manager_js_1 = require("./3_chat_list_manager.js");
|
|
36
|
-
const
|
|
39
|
+
const _3_inline_query_manager_js_1 = require("./3_inline_query_manager.js");
|
|
37
40
|
const d = (0, _0_deps_js_1.debug)("Client");
|
|
38
41
|
const dAuth = (0, _0_deps_js_1.debug)("Client/authorize");
|
|
39
42
|
const dRecv = (0, _0_deps_js_1.debug)("Client/receiveLoop");
|
|
@@ -75,10 +78,14 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
75
78
|
_Client_toAcknowledge.set(this, new Set());
|
|
76
79
|
_Client_guaranteeUpdateDelivery.set(this, void 0);
|
|
77
80
|
_Client_updateManager.set(this, void 0);
|
|
81
|
+
_Client_networkStatisticsManager.set(this, void 0);
|
|
82
|
+
_Client_botInfoManager.set(this, void 0);
|
|
78
83
|
_Client_fileManager.set(this, void 0);
|
|
84
|
+
_Client_reactionManager.set(this, void 0);
|
|
79
85
|
_Client_messageManager.set(this, void 0);
|
|
86
|
+
_Client_callbackQueryManager.set(this, void 0);
|
|
87
|
+
_Client_inlineQueryManager.set(this, void 0);
|
|
80
88
|
_Client_chatListManager.set(this, void 0);
|
|
81
|
-
_Client_reactionManager.set(this, void 0);
|
|
82
89
|
Object.defineProperty(this, "storage", {
|
|
83
90
|
enumerable: true,
|
|
84
91
|
configurable: true,
|
|
@@ -451,7 +458,6 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
451
458
|
}).bind(this)
|
|
452
459
|
});
|
|
453
460
|
_Client_storageInited.set(this, false);
|
|
454
|
-
_Client_authKeyWasCreated.set(this, true);
|
|
455
461
|
_Client_connectMutex.set(this, new _0_deps_js_1.Mutex());
|
|
456
462
|
_Client_connectionInited.set(this, false);
|
|
457
463
|
_Client_lastPropagatedAuthorizationState.set(this, null);
|
|
@@ -489,10 +495,6 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
489
495
|
})
|
|
490
496
|
});
|
|
491
497
|
_Client_lastGetMe.set(this, null);
|
|
492
|
-
_Client_usernameResolver.set(this, async (v) => {
|
|
493
|
-
const inputPeer = await this.getInputPeer(v).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.InputPeerUser));
|
|
494
|
-
return new _2_tl_js_1.types.InputUser(inputPeer);
|
|
495
|
-
});
|
|
496
498
|
//#region Composer
|
|
497
499
|
_Client_handle.set(this, _1_composer_js_1.skip);
|
|
498
500
|
this.storage = storage ?? new _3_storage_js_1.StorageMemory();
|
|
@@ -562,26 +564,23 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
562
564
|
disconnect: client.disconnect.bind(client),
|
|
563
565
|
};
|
|
564
566
|
},
|
|
567
|
+
cdn: params?.cdn ?? false,
|
|
568
|
+
ignoreOutgoing: __classPrivateFieldGet(this, _Client_ignoreOutgoing, "f"),
|
|
565
569
|
};
|
|
566
570
|
__classPrivateFieldSet(this, _Client_updateManager, new _1_update_manager_js_1.UpdateManager(c), "f");
|
|
571
|
+
__classPrivateFieldSet(this, _Client_networkStatisticsManager, new _1_network_statistics_manager_js_1.NetworkStatisticsManager(c), "f");
|
|
572
|
+
__classPrivateFieldSet(this, _Client_botInfoManager, new _1_bot_info_manager_js_1.BotInfoManager(c), "f");
|
|
567
573
|
__classPrivateFieldSet(this, _Client_fileManager, new _1_file_manager_js_1.FileManager(c), "f");
|
|
574
|
+
__classPrivateFieldSet(this, _Client_reactionManager, new _1_reaction_manager_js_1.ReactionManager(c), "f");
|
|
568
575
|
__classPrivateFieldSet(this, _Client_messageManager, new _2_message_manager_js_1.MessageManager({ ...c, fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f") }), "f");
|
|
576
|
+
__classPrivateFieldSet(this, _Client_callbackQueryManager, new _3_callback_query_manager_js_1.CallbackQueryManager({ ...c, messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
|
|
577
|
+
__classPrivateFieldSet(this, _Client_inlineQueryManager, new _3_inline_query_manager_js_1.InlineQueryManager({ ...c, messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
|
|
569
578
|
__classPrivateFieldSet(this, _Client_chatListManager, new _3_chat_list_manager_js_1.ChatListManager({ ...c, messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
|
|
570
|
-
__classPrivateFieldSet(this, _Client_reactionManager, new _3_reaction_manager_js_1.ReactionManager({ ...c, messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
|
|
571
579
|
__classPrivateFieldGet(this, _Client_updateManager, "f").setUpdateHandler(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleUpdate).bind(this));
|
|
572
580
|
const transportProvider = this.transportProvider;
|
|
573
581
|
this.transportProvider = (params) => {
|
|
574
582
|
const transport = transportProvider(params);
|
|
575
|
-
transport.connection.callback =
|
|
576
|
-
read: async (count) => {
|
|
577
|
-
const key = params.cdn ? "netstat_cdn_read" : "netstat_messages_read";
|
|
578
|
-
await this.storage.incr([key], count);
|
|
579
|
-
},
|
|
580
|
-
write: async (count) => {
|
|
581
|
-
const key = params.cdn ? "netstat_cdn_write" : "netstat_messages_write";
|
|
582
|
-
await this.storage.incr([key], count);
|
|
583
|
-
},
|
|
584
|
-
};
|
|
583
|
+
transport.connection.callback = __classPrivateFieldGet(this, _Client_networkStatisticsManager, "f").getTransportReadWriteCallback();
|
|
585
584
|
return transport;
|
|
586
585
|
};
|
|
587
586
|
if (params?.defaultHandlers ?? true) {
|
|
@@ -632,10 +631,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
632
631
|
* @param dc The DC to change to.
|
|
633
632
|
*/
|
|
634
633
|
async setDc(dc) {
|
|
635
|
-
|
|
636
|
-
await this.storage.initialize();
|
|
637
|
-
__classPrivateFieldSet(this, _Client_storageInited, true, "f");
|
|
638
|
-
}
|
|
634
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initStorage).call(this);
|
|
639
635
|
if (await this.storage.getDc() != dc) {
|
|
640
636
|
await this.storage.setDc(dc);
|
|
641
637
|
await this.storage.setAuthKey(null);
|
|
@@ -654,13 +650,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
654
650
|
}
|
|
655
651
|
const release = await __classPrivateFieldGet(this, _Client_connectMutex, "f").acquire();
|
|
656
652
|
try {
|
|
657
|
-
|
|
658
|
-
await this.storage.initialize();
|
|
659
|
-
if (!__classPrivateFieldGet(this, _Client_guaranteeUpdateDelivery, "f")) {
|
|
660
|
-
await this.storage.deleteUpdates();
|
|
661
|
-
}
|
|
662
|
-
__classPrivateFieldSet(this, _Client_storageInited, true, "f");
|
|
663
|
-
}
|
|
653
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initStorage).call(this);
|
|
664
654
|
const authKey = await this.storage.getAuthKey();
|
|
665
655
|
if (authKey == null) {
|
|
666
656
|
const plain = new _2_client_plain_js_1.ClientPlain({ initialDc: this.initialDc, transportProvider: this.transportProvider, cdn: this.cdn, publicKeys: __classPrivateFieldGet(this, _Client_publicKeys, "f") });
|
|
@@ -681,7 +671,6 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
681
671
|
__classPrivateFieldGet(this, _Client_state, "f").salt = await this.storage.getServerSalt() ?? 0n;
|
|
682
672
|
}
|
|
683
673
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setAuth).call(this, authKey);
|
|
684
|
-
__classPrivateFieldSet(this, _Client_authKeyWasCreated, false, "f");
|
|
685
674
|
}
|
|
686
675
|
const dc = await this.storage.getDc();
|
|
687
676
|
if (dc != null) {
|
|
@@ -701,13 +690,21 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
701
690
|
release();
|
|
702
691
|
}
|
|
703
692
|
}
|
|
704
|
-
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_messageManager = new WeakMap(),
|
|
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) {
|
|
705
694
|
__classPrivateFieldGet(this, _Client_instances, "m", _Client_queueHandleCtxUpdate).call(this, { connectionState });
|
|
706
695
|
__classPrivateFieldSet(this, _Client_lastPropagatedConnectionState, connectionState, "f");
|
|
707
696
|
}, _Client_setAuth = async function _Client_setAuth(key) {
|
|
708
697
|
const hash = await (0, _1_utilities_js_1.sha1)(key);
|
|
709
698
|
const id = (0, _1_utilities_js_1.bigIntFromBuffer)(hash.slice(-8), true, false);
|
|
710
699
|
__classPrivateFieldSet(this, _Client_auth, { key, id }, "f");
|
|
700
|
+
}, _Client_initStorage = async function _Client_initStorage() {
|
|
701
|
+
if (!__classPrivateFieldGet(this, _Client_storageInited, "f")) {
|
|
702
|
+
await this.storage.initialize();
|
|
703
|
+
if (!__classPrivateFieldGet(this, _Client_guaranteeUpdateDelivery, "f")) {
|
|
704
|
+
await this.storage.deleteUpdates();
|
|
705
|
+
}
|
|
706
|
+
__classPrivateFieldSet(this, _Client_storageInited, true, "f");
|
|
707
|
+
}
|
|
711
708
|
}, exports.handleMigrationError)](err) {
|
|
712
709
|
let newDc = String(err.dc);
|
|
713
710
|
if (Math.abs(this.dcId) >= 10000) {
|
|
@@ -901,16 +898,11 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
901
898
|
}
|
|
902
899
|
}
|
|
903
900
|
/**
|
|
904
|
-
* Same as calling `.connect()` followed by `.authorize(params)
|
|
901
|
+
* Same as calling `.connect()` followed by `.authorize(params)`.
|
|
905
902
|
*/
|
|
906
903
|
async start(params) {
|
|
907
904
|
await this.connect();
|
|
908
905
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initConnection).call(this);
|
|
909
|
-
if (!__classPrivateFieldGet(this, _Client_authKeyWasCreated, "f")) {
|
|
910
|
-
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("start"));
|
|
911
|
-
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("start"));
|
|
912
|
-
return;
|
|
913
|
-
}
|
|
914
906
|
await this.authorize(params);
|
|
915
907
|
}
|
|
916
908
|
/**
|
|
@@ -1170,6 +1162,10 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1170
1162
|
const channels = await this.api.channels.getChannels({ id: [new _2_tl_js_1.types.InputChannel({ channel_id: channelId, access_hash: 0n })] });
|
|
1171
1163
|
return channels.chats[0][_2_tl_js_1.as](_2_tl_js_1.types.Channel).access_hash ?? 0n;
|
|
1172
1164
|
}, _Client_getInputPeerInner = async function _Client_getInputPeerInner(id) {
|
|
1165
|
+
const idn = Number(id);
|
|
1166
|
+
if (!isNaN(idn)) {
|
|
1167
|
+
id = idn;
|
|
1168
|
+
}
|
|
1173
1169
|
if (typeof id === "string") {
|
|
1174
1170
|
id = (0, _0_utilities_js_1.getUsername)(id);
|
|
1175
1171
|
let userId = 0n;
|
|
@@ -1231,6 +1227,77 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1231
1227
|
const id = peer instanceof _2_tl_js_1.types.PeerUser ? peer.user_id : peer instanceof _2_tl_js_1.types.PeerChat ? peer.chat_id : peer instanceof _2_tl_js_1.types.PeerChannel ? peer.channel_id : (0, _1_utilities_js_1.UNREACHABLE)();
|
|
1232
1228
|
return this.storage.getEntity(type, id);
|
|
1233
1229
|
}
|
|
1230
|
+
use(...middleware) {
|
|
1231
|
+
const composer = new _1_composer_js_1.Composer(...middleware);
|
|
1232
|
+
__classPrivateFieldSet(this, _Client_handle, (0, _1_composer_js_1.concat)(__classPrivateFieldGet(this, _Client_handle, "f"), (0, _1_composer_js_1.flatten)(composer)), "f");
|
|
1233
|
+
return composer;
|
|
1234
|
+
}
|
|
1235
|
+
branch(predicate, trueHandler_, falseHandler_) {
|
|
1236
|
+
const trueHandler = (0, _1_composer_js_1.flatten)(trueHandler_);
|
|
1237
|
+
const falseHandler = (0, _1_composer_js_1.flatten)(falseHandler_);
|
|
1238
|
+
return this.use(async (upd, next) => {
|
|
1239
|
+
if (await predicate(upd)) {
|
|
1240
|
+
await trueHandler(upd, next);
|
|
1241
|
+
}
|
|
1242
|
+
else {
|
|
1243
|
+
await falseHandler(upd, next);
|
|
1244
|
+
}
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
filter(predicate, ...middleware) {
|
|
1248
|
+
const composer = new _1_composer_js_1.Composer(...middleware);
|
|
1249
|
+
this.branch(predicate, composer, _1_composer_js_1.skip);
|
|
1250
|
+
return composer;
|
|
1251
|
+
}
|
|
1252
|
+
on(filter, ...middleawre) {
|
|
1253
|
+
return this.filter((ctx) => {
|
|
1254
|
+
return (0, _0_filters_js_1.match)(filter, ctx);
|
|
1255
|
+
}, ...middleawre);
|
|
1256
|
+
}
|
|
1257
|
+
command(commands, ...middleawre) {
|
|
1258
|
+
const commands__ = typeof commands === "object" && "names" in commands ? commands.names : commands;
|
|
1259
|
+
const commands_ = Array.isArray(commands__) ? commands__ : [commands__];
|
|
1260
|
+
const prefixes_ = typeof commands === "object" && "prefixes" in commands ? commands.prefixes : (__classPrivateFieldGet(this, _Client_prefixes, "f") ?? []);
|
|
1261
|
+
const prefixes = Array.isArray(prefixes_) ? prefixes_ : [prefixes_];
|
|
1262
|
+
for (const left of prefixes) {
|
|
1263
|
+
for (const right of prefixes) {
|
|
1264
|
+
if (left == right) {
|
|
1265
|
+
continue;
|
|
1266
|
+
}
|
|
1267
|
+
if (left.startsWith(right) || right.startsWith(left)) {
|
|
1268
|
+
throw new Error("Intersecting prefixes");
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
return this.on("message:text").filter((ctx) => {
|
|
1273
|
+
const prefixes_ = prefixes.length == 0 ? [!ctx.me?.isBot ? "\\" : "/"] : prefixes;
|
|
1274
|
+
if (prefixes_.length == 0) {
|
|
1275
|
+
return false;
|
|
1276
|
+
}
|
|
1277
|
+
const cmd = ctx.message.text.split(/\s/, 1)[0];
|
|
1278
|
+
const prefix = prefixes_.find((v) => cmd.startsWith(v));
|
|
1279
|
+
if (prefix === undefined) {
|
|
1280
|
+
return false;
|
|
1281
|
+
}
|
|
1282
|
+
if (cmd.includes("@")) {
|
|
1283
|
+
const username = cmd.split("@", 2)[1];
|
|
1284
|
+
if (username.toLowerCase() !== ctx.me.username?.toLowerCase()) {
|
|
1285
|
+
return false;
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
const command_ = cmd.split("@", 1)[0].split(prefix, 2)[1].toLowerCase();
|
|
1289
|
+
for (const command of commands_) {
|
|
1290
|
+
if (typeof command === "string" && (command.toLowerCase() == command_)) {
|
|
1291
|
+
return true;
|
|
1292
|
+
}
|
|
1293
|
+
else if (command instanceof RegExp && command.test(command_)) {
|
|
1294
|
+
return true;
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
return false;
|
|
1298
|
+
}, ...middleawre);
|
|
1299
|
+
}
|
|
1300
|
+
//#endregion
|
|
1234
1301
|
/**
|
|
1235
1302
|
* Send a text message.
|
|
1236
1303
|
*
|
|
@@ -1355,13 +1422,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1355
1422
|
* @param id ID of the callback query to answer.
|
|
1356
1423
|
*/
|
|
1357
1424
|
async answerCallbackQuery(id, params) {
|
|
1358
|
-
await this
|
|
1359
|
-
await this.api.messages.setBotCallbackAnswer({
|
|
1360
|
-
query_id: BigInt(id),
|
|
1361
|
-
cache_time: params?.cacheTime ?? 0,
|
|
1362
|
-
message: params?.text,
|
|
1363
|
-
alert: params?.alert ? true : undefined,
|
|
1364
|
-
});
|
|
1425
|
+
await __classPrivateFieldGet(this, _Client_callbackQueryManager, "f").answerCallbackQuery(id, params);
|
|
1365
1426
|
}
|
|
1366
1427
|
/**
|
|
1367
1428
|
* Send a poll.
|
|
@@ -1384,45 +1445,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1384
1445
|
* @param messageThreadId The thread to send the chat action to.
|
|
1385
1446
|
*/
|
|
1386
1447
|
async sendChatAction(chatId, action, params) {
|
|
1387
|
-
|
|
1388
|
-
switch (action) {
|
|
1389
|
-
case "type":
|
|
1390
|
-
action_ = new _2_tl_js_1.types.SendMessageTypingAction();
|
|
1391
|
-
break;
|
|
1392
|
-
case "uploadPhoto":
|
|
1393
|
-
action_ = new _2_tl_js_1.types.SendMessageUploadPhotoAction({ progress: 0 });
|
|
1394
|
-
break;
|
|
1395
|
-
case "recordVideo":
|
|
1396
|
-
action_ = new _2_tl_js_1.types.SendMessageRecordVideoAction();
|
|
1397
|
-
break;
|
|
1398
|
-
case "uploadVideo":
|
|
1399
|
-
action_ = new _2_tl_js_1.types.SendMessageRecordVideoAction();
|
|
1400
|
-
break;
|
|
1401
|
-
case "recordVoice":
|
|
1402
|
-
action_ = new _2_tl_js_1.types.SendMessageRecordAudioAction();
|
|
1403
|
-
break;
|
|
1404
|
-
case "uploadAudio":
|
|
1405
|
-
action_ = new _2_tl_js_1.types.SendMessageUploadAudioAction({ progress: 0 });
|
|
1406
|
-
break;
|
|
1407
|
-
case "uploadDocument":
|
|
1408
|
-
action_ = new _2_tl_js_1.types.SendMessageUploadDocumentAction({ progress: 0 });
|
|
1409
|
-
break;
|
|
1410
|
-
case "chooseSticker":
|
|
1411
|
-
action_ = new _2_tl_js_1.types.SendMessageChooseStickerAction();
|
|
1412
|
-
break;
|
|
1413
|
-
case "findLocation":
|
|
1414
|
-
action_ = new _2_tl_js_1.types.SendMessageGeoLocationAction();
|
|
1415
|
-
break;
|
|
1416
|
-
case "recordVideoNote":
|
|
1417
|
-
action_ = new _2_tl_js_1.types.SendMessageRecordRoundAction();
|
|
1418
|
-
break;
|
|
1419
|
-
case "uploadVideoNote":
|
|
1420
|
-
action_ = new _2_tl_js_1.types.SendMessageUploadRoundAction({ progress: 0 });
|
|
1421
|
-
break;
|
|
1422
|
-
default:
|
|
1423
|
-
throw new Error("Invalid chat action: " + action);
|
|
1424
|
-
}
|
|
1425
|
-
await this.api.messages.setTyping({ peer: await this.getInputPeer(chatId), action: action_, top_msg_id: params?.messageThreadId });
|
|
1448
|
+
return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendChatAction(chatId, action, params);
|
|
1426
1449
|
}
|
|
1427
1450
|
/**
|
|
1428
1451
|
* Upload a file.
|
|
@@ -1440,21 +1463,13 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1440
1463
|
* @param commands The commands to set.
|
|
1441
1464
|
*/
|
|
1442
1465
|
async setMyCommands(commands, params) {
|
|
1443
|
-
await this.
|
|
1444
|
-
commands: commands.map((v) => new _2_tl_js_1.types.BotCommand(v)),
|
|
1445
|
-
lang_code: params?.languageCode ?? "",
|
|
1446
|
-
scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)),
|
|
1447
|
-
});
|
|
1466
|
+
await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyCommands(commands, params);
|
|
1448
1467
|
}
|
|
1449
1468
|
/**
|
|
1450
1469
|
* Get the bot's commands in the given scope and/or language. Bot-only.
|
|
1451
1470
|
*/
|
|
1452
1471
|
async getMyCommands(params) {
|
|
1453
|
-
|
|
1454
|
-
lang_code: params?.languageCode ?? "",
|
|
1455
|
-
scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)),
|
|
1456
|
-
});
|
|
1457
|
-
return commands_.map((v) => ({ command: v.command, description: v.description }));
|
|
1472
|
+
return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyCommands(params);
|
|
1458
1473
|
}
|
|
1459
1474
|
/**
|
|
1460
1475
|
* Answer an inline query. Bot-only.
|
|
@@ -1464,86 +1479,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1464
1479
|
* @param results The results to answer with.
|
|
1465
1480
|
*/
|
|
1466
1481
|
async answerInlineQuery(id, results, params) {
|
|
1467
|
-
await this.
|
|
1468
|
-
query_id: BigInt(id),
|
|
1469
|
-
results: await Promise.all(results.map((v) => (0, _3_types_js_1.inlineQueryResultToTlObject)(v, __classPrivateFieldGet(this, _Client_instances, "m", _Client_parseText).bind(this), __classPrivateFieldGet(this, _Client_usernameResolver, "f").bind(this)))),
|
|
1470
|
-
cache_time: params?.cacheTime ?? 300,
|
|
1471
|
-
private: params?.isPersonal ? true : undefined,
|
|
1472
|
-
switch_webview: params?.button && params.button.webApp ? new _2_tl_js_1.types.InlineBotWebView({ text: params.button.text, url: params.button.webApp.url }) : undefined,
|
|
1473
|
-
switch_pm: params?.button && params.button.startParameter ? new _2_tl_js_1.types.InlineBotSwitchPM({ text: params.button.text, start_param: params.button.startParameter }) : undefined,
|
|
1474
|
-
gallery: params?.isGallery ? true : undefined,
|
|
1475
|
-
next_offset: params?.nextOffset,
|
|
1476
|
-
});
|
|
1477
|
-
}
|
|
1478
|
-
use(...middleware) {
|
|
1479
|
-
const composer = new _1_composer_js_1.Composer(...middleware);
|
|
1480
|
-
__classPrivateFieldSet(this, _Client_handle, (0, _1_composer_js_1.concat)(__classPrivateFieldGet(this, _Client_handle, "f"), (0, _1_composer_js_1.flatten)(composer)), "f");
|
|
1481
|
-
return composer;
|
|
1482
|
-
}
|
|
1483
|
-
branch(predicate, trueHandler_, falseHandler_) {
|
|
1484
|
-
const trueHandler = (0, _1_composer_js_1.flatten)(trueHandler_);
|
|
1485
|
-
const falseHandler = (0, _1_composer_js_1.flatten)(falseHandler_);
|
|
1486
|
-
return this.use(async (upd, next) => {
|
|
1487
|
-
if (await predicate(upd)) {
|
|
1488
|
-
await trueHandler(upd, next);
|
|
1489
|
-
}
|
|
1490
|
-
else {
|
|
1491
|
-
await falseHandler(upd, next);
|
|
1492
|
-
}
|
|
1493
|
-
});
|
|
1494
|
-
}
|
|
1495
|
-
filter(predicate, ...middleware) {
|
|
1496
|
-
const composer = new _1_composer_js_1.Composer(...middleware);
|
|
1497
|
-
this.branch(predicate, composer, _1_composer_js_1.skip);
|
|
1498
|
-
return composer;
|
|
1499
|
-
}
|
|
1500
|
-
on(filter, ...middleawre) {
|
|
1501
|
-
return this.filter((ctx) => {
|
|
1502
|
-
return (0, _0_filters_js_1.match)(filter, ctx);
|
|
1503
|
-
}, ...middleawre);
|
|
1504
|
-
}
|
|
1505
|
-
command(commands, ...middleawre) {
|
|
1506
|
-
const commands__ = typeof commands === "object" && "names" in commands ? commands.names : commands;
|
|
1507
|
-
const commands_ = Array.isArray(commands__) ? commands__ : [commands__];
|
|
1508
|
-
const prefixes_ = typeof commands === "object" && "prefixes" in commands ? commands.prefixes : (__classPrivateFieldGet(this, _Client_prefixes, "f") ?? []);
|
|
1509
|
-
const prefixes = Array.isArray(prefixes_) ? prefixes_ : [prefixes_];
|
|
1510
|
-
for (const left of prefixes) {
|
|
1511
|
-
for (const right of prefixes) {
|
|
1512
|
-
if (left == right) {
|
|
1513
|
-
continue;
|
|
1514
|
-
}
|
|
1515
|
-
if (left.startsWith(right) || right.startsWith(left)) {
|
|
1516
|
-
throw new Error("Intersecting prefixes");
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
}
|
|
1520
|
-
return this.on("message:text").filter((ctx) => {
|
|
1521
|
-
const prefixes_ = prefixes.length == 0 ? [!ctx.me?.isBot ? "\\" : "/"] : prefixes;
|
|
1522
|
-
if (prefixes_.length == 0) {
|
|
1523
|
-
return false;
|
|
1524
|
-
}
|
|
1525
|
-
const cmd = ctx.message.text.split(/\s/, 1)[0];
|
|
1526
|
-
const prefix = prefixes_.find((v) => cmd.startsWith(v));
|
|
1527
|
-
if (prefix === undefined) {
|
|
1528
|
-
return false;
|
|
1529
|
-
}
|
|
1530
|
-
if (cmd.includes("@")) {
|
|
1531
|
-
const username = cmd.split("@", 2)[1];
|
|
1532
|
-
if (username.toLowerCase() !== ctx.me.username?.toLowerCase()) {
|
|
1533
|
-
return false;
|
|
1534
|
-
}
|
|
1535
|
-
}
|
|
1536
|
-
const command_ = cmd.split("@", 1)[0].split(prefix, 2)[1].toLowerCase();
|
|
1537
|
-
for (const command of commands_) {
|
|
1538
|
-
if (typeof command === "string" && (command.toLowerCase() == command_)) {
|
|
1539
|
-
return true;
|
|
1540
|
-
}
|
|
1541
|
-
else if (command instanceof RegExp && command.test(command_)) {
|
|
1542
|
-
return true;
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
return false;
|
|
1546
|
-
}, ...middleawre);
|
|
1482
|
+
await __classPrivateFieldGet(this, _Client_inlineQueryManager, "f").answerInlineQuery(id, results, params);
|
|
1547
1483
|
}
|
|
1548
1484
|
/**
|
|
1549
1485
|
* Set the bot's description in the given language. Bot-only.
|
|
@@ -1551,8 +1487,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1551
1487
|
* @method
|
|
1552
1488
|
*/
|
|
1553
1489
|
async setMyDescription(params) {
|
|
1554
|
-
await this
|
|
1555
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setMyInfo).call(this, { description: params?.description, lang_code: params?.languageCode ?? "" });
|
|
1490
|
+
await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyDescription(params);
|
|
1556
1491
|
}
|
|
1557
1492
|
/**
|
|
1558
1493
|
* Set the bot's name in the given language. Bot-only.
|
|
@@ -1560,8 +1495,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1560
1495
|
* @method
|
|
1561
1496
|
*/
|
|
1562
1497
|
async setMyName(params) {
|
|
1563
|
-
await this
|
|
1564
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setMyInfo).call(this, { name: params?.name, lang_code: params?.languageCode ?? "" });
|
|
1498
|
+
await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyName(params);
|
|
1565
1499
|
}
|
|
1566
1500
|
/**
|
|
1567
1501
|
* Set the bot's short description in the given language. Bot-only.
|
|
@@ -1569,8 +1503,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1569
1503
|
* @method
|
|
1570
1504
|
*/
|
|
1571
1505
|
async setMyShortDescription(params) {
|
|
1572
|
-
await this
|
|
1573
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setMyInfo).call(this, { about: params?.shortDescription, lang_code: params?.languageCode ?? "" });
|
|
1506
|
+
await __classPrivateFieldGet(this, _Client_botInfoManager, "f").setMyShortDescription(params);
|
|
1574
1507
|
}
|
|
1575
1508
|
/**
|
|
1576
1509
|
* Get the bot's description in the given language. Bot-only.
|
|
@@ -1578,8 +1511,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1578
1511
|
* @method
|
|
1579
1512
|
*/
|
|
1580
1513
|
async getMyDescription(params) {
|
|
1581
|
-
await this
|
|
1582
|
-
return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMyInfo).call(this, params?.languageCode).then((v) => v.description);
|
|
1514
|
+
return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyDescription(params);
|
|
1583
1515
|
}
|
|
1584
1516
|
/**
|
|
1585
1517
|
* Set the bot's name in the given language. Bot-only.
|
|
@@ -1587,8 +1519,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1587
1519
|
* @method
|
|
1588
1520
|
*/
|
|
1589
1521
|
async getMyName(params) {
|
|
1590
|
-
await this
|
|
1591
|
-
return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMyInfo).call(this, params?.languageCode).then((v) => v.description);
|
|
1522
|
+
return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyName(params);
|
|
1592
1523
|
}
|
|
1593
1524
|
/**
|
|
1594
1525
|
* Get the bot's short description in the given language. Bot-only.
|
|
@@ -1596,8 +1527,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1596
1527
|
* @method
|
|
1597
1528
|
*/
|
|
1598
1529
|
async getMyShortDescription(params) {
|
|
1599
|
-
await this
|
|
1600
|
-
return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMyInfo).call(this, params?.languageCode).then((v) => v.about);
|
|
1530
|
+
return await __classPrivateFieldGet(this, _Client_botInfoManager, "f").getMyShortDescription(params);
|
|
1601
1531
|
}
|
|
1602
1532
|
/**
|
|
1603
1533
|
* Delete multiple messages.
|
|
@@ -1739,21 +1669,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1739
1669
|
* @method
|
|
1740
1670
|
*/
|
|
1741
1671
|
async getNetworkStatistics() {
|
|
1742
|
-
|
|
1743
|
-
this.storage.get(["netstat_messages_read"]),
|
|
1744
|
-
this.storage.get(["netstat_messages_write"]),
|
|
1745
|
-
this.storage.get(["netstat_cdn_read"]),
|
|
1746
|
-
this.storage.get(["netstat_cdn_write"]),
|
|
1747
|
-
]);
|
|
1748
|
-
const messages = {
|
|
1749
|
-
sent: Number(messagesWrite || 0),
|
|
1750
|
-
received: Number(messagesRead || 0),
|
|
1751
|
-
};
|
|
1752
|
-
const cdn = {
|
|
1753
|
-
sent: Number(cdnWrite || 0),
|
|
1754
|
-
received: Number(cdnRead || 0),
|
|
1755
|
-
};
|
|
1756
|
-
return { messages, cdn };
|
|
1672
|
+
return await __classPrivateFieldGet(this, _Client_networkStatisticsManager, "f").getNetworkStatistics();
|
|
1757
1673
|
}
|
|
1758
1674
|
/**
|
|
1759
1675
|
* Get chats from a chat list. User-only.
|
|
@@ -1769,69 +1685,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1769
1685
|
* @method
|
|
1770
1686
|
*/
|
|
1771
1687
|
async getChat(chatId) {
|
|
1772
|
-
|
|
1773
|
-
let maybeChatId = null;
|
|
1774
|
-
if (typeof chatId === "number") {
|
|
1775
|
-
maybeChatId = chatId;
|
|
1776
|
-
}
|
|
1777
|
-
else if (typeof chatId === "string") {
|
|
1778
|
-
maybeChatId = __classPrivateFieldGet(this, _Client_chatListManager, "f").tryGetChatId((0, _0_utilities_js_1.getUsername)(chatId));
|
|
1779
|
-
}
|
|
1780
|
-
else {
|
|
1781
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
1782
|
-
}
|
|
1783
|
-
if (maybeChatId != null) {
|
|
1784
|
-
const [chat] = __classPrivateFieldGet(this, _Client_chatListManager, "f").getChatAnywhere(maybeChatId);
|
|
1785
|
-
if (chat !== undefined) {
|
|
1786
|
-
return chat;
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1789
|
-
}
|
|
1790
|
-
let inputPeer = null;
|
|
1791
|
-
if (typeof chatId === "number") {
|
|
1792
|
-
const chat = await (0, _3_types_js_1.constructChat3)(chatId, -1, undefined, this[getEntity].bind(this));
|
|
1793
|
-
if (chat != null) {
|
|
1794
|
-
return chat;
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1797
|
-
else {
|
|
1798
|
-
inputPeer = await this.getInputPeer(chatId);
|
|
1799
|
-
const chatId_ = (0, _2_tl_js_1.peerToChatId)(inputPeer);
|
|
1800
|
-
const chat = await (0, _3_types_js_1.constructChat3)(chatId_, -1, undefined, this[getEntity].bind(this));
|
|
1801
|
-
if (chat != null) {
|
|
1802
|
-
return chat;
|
|
1803
|
-
}
|
|
1804
|
-
}
|
|
1805
|
-
if (inputPeer == null) {
|
|
1806
|
-
inputPeer = await this.getInputPeer(chatId);
|
|
1807
|
-
}
|
|
1808
|
-
if (inputPeer instanceof _2_tl_js_1.types.InputPeerChat) {
|
|
1809
|
-
const chats = await this.api.messages.getChats({ id: [inputPeer.chat_id] }).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.messages.Chats));
|
|
1810
|
-
const chat = chats.chats[0];
|
|
1811
|
-
if (chat instanceof _2_tl_js_1.types.ChatEmpty) {
|
|
1812
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
1813
|
-
}
|
|
1814
|
-
return (0, _3_types_js_1.constructChat2)(chat, -1, undefined);
|
|
1815
|
-
}
|
|
1816
|
-
else if (inputPeer instanceof _2_tl_js_1.types.InputPeerChannel) {
|
|
1817
|
-
const channels = await this.api.channels.getChannels({ id: [new _2_tl_js_1.types.InputChannel(inputPeer)] });
|
|
1818
|
-
const channel = channels.chats[0];
|
|
1819
|
-
if (channel instanceof _2_tl_js_1.types.ChatEmpty) {
|
|
1820
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
1821
|
-
}
|
|
1822
|
-
return (0, _3_types_js_1.constructChat2)(channel, -1, undefined);
|
|
1823
|
-
}
|
|
1824
|
-
else if (inputPeer instanceof _2_tl_js_1.types.InputPeerUser) {
|
|
1825
|
-
const users = await this.api.users.getUsers({ id: [new _2_tl_js_1.types.InputUser(inputPeer)] });
|
|
1826
|
-
const user = users[0];
|
|
1827
|
-
if (user instanceof _2_tl_js_1.types.UserEmpty) {
|
|
1828
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
1829
|
-
}
|
|
1830
|
-
return (0, _3_types_js_1.constructChat2)(user, -1, undefined);
|
|
1831
|
-
}
|
|
1832
|
-
else {
|
|
1833
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
1834
|
-
}
|
|
1688
|
+
return await __classPrivateFieldGet(this, _Client_chatListManager, "f").getChat(chatId);
|
|
1835
1689
|
}
|
|
1836
1690
|
/**
|
|
1837
1691
|
* Get chat history. User-only.
|
|
@@ -1859,7 +1713,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1859
1713
|
* @param availableReactions The new available reactions.
|
|
1860
1714
|
*/
|
|
1861
1715
|
async setAvailableReactions(chatId, availableReactions) {
|
|
1862
|
-
await __classPrivateFieldGet(this,
|
|
1716
|
+
await __classPrivateFieldGet(this, _Client_messageManager, "f").setAvailableReactions(chatId, availableReactions);
|
|
1863
1717
|
}
|
|
1864
1718
|
/**
|
|
1865
1719
|
* Change reactions made to a message.
|
|
@@ -1870,7 +1724,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1870
1724
|
* @param reactions The new reactions.
|
|
1871
1725
|
*/
|
|
1872
1726
|
async setReactions(chatId, messageId, reactions, params) {
|
|
1873
|
-
await __classPrivateFieldGet(this,
|
|
1727
|
+
await __classPrivateFieldGet(this, _Client_messageManager, "f").setReactions(chatId, messageId, reactions, params);
|
|
1874
1728
|
}
|
|
1875
1729
|
/**
|
|
1876
1730
|
* Make a reaction to a message.
|
|
@@ -1881,7 +1735,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1881
1735
|
* @param reaction The reaction to add.
|
|
1882
1736
|
*/
|
|
1883
1737
|
async addReaction(chatId, messageId, reaction, params) {
|
|
1884
|
-
await __classPrivateFieldGet(this,
|
|
1738
|
+
await __classPrivateFieldGet(this, _Client_messageManager, "f").addReaction(chatId, messageId, reaction, params);
|
|
1885
1739
|
}
|
|
1886
1740
|
/**
|
|
1887
1741
|
* Undo a reaction made to a message.
|
|
@@ -1892,7 +1746,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1892
1746
|
* @param reaction The reaction to remove.
|
|
1893
1747
|
*/
|
|
1894
1748
|
async removeReaction(chatId, messageId, reaction) {
|
|
1895
|
-
await __classPrivateFieldGet(this,
|
|
1749
|
+
await __classPrivateFieldGet(this, _Client_messageManager, "f").removeReaction(chatId, messageId, reaction);
|
|
1896
1750
|
}
|
|
1897
1751
|
/**
|
|
1898
1752
|
* Set a chat's photo.
|
|
@@ -1902,19 +1756,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1902
1756
|
* @param photo A photo to set as the chat's photo.
|
|
1903
1757
|
*/
|
|
1904
1758
|
async setChatPhoto(chatId, photo, params) {
|
|
1905
|
-
|
|
1906
|
-
if (!(peer instanceof _2_tl_js_1.types.InputPeerChannel) && !(peer instanceof _2_tl_js_1.types.InputPeerChat)) {
|
|
1907
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
1908
|
-
}
|
|
1909
|
-
const [contents, fileName] = await (0, _0_utilities_js_1.getFileContents)(photo);
|
|
1910
|
-
const file = await this.upload(contents, { fileName: params?.fileName ?? fileName, chunkSize: params?.chunkSize, signal: params?.signal });
|
|
1911
|
-
const photo_ = new _2_tl_js_1.types.InputChatUploadedPhoto({ file });
|
|
1912
|
-
if (peer instanceof _2_tl_js_1.types.InputPeerChannel) {
|
|
1913
|
-
await this.api.channels.editPhoto({ channel: new _2_tl_js_1.types.InputChannel(peer), photo: photo_ });
|
|
1914
|
-
}
|
|
1915
|
-
else if (peer instanceof _2_tl_js_1.types.InputPeerChat) {
|
|
1916
|
-
await this.api.messages.editChatPhoto({ chat_id: peer.chat_id, photo: photo_ });
|
|
1917
|
-
}
|
|
1759
|
+
await __classPrivateFieldGet(this, _Client_messageManager, "f").setChatPhoto(chatId, photo, params);
|
|
1918
1760
|
}
|
|
1919
1761
|
/**
|
|
1920
1762
|
* Delete a chat's photo.
|
|
@@ -1923,16 +1765,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1923
1765
|
* @param chatId The identifier of the chat.
|
|
1924
1766
|
*/
|
|
1925
1767
|
async deleteChatPhoto(chatId) {
|
|
1926
|
-
|
|
1927
|
-
if (!(peer instanceof _2_tl_js_1.types.InputPeerChannel) && !(peer instanceof _2_tl_js_1.types.InputPeerChat)) {
|
|
1928
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
1929
|
-
}
|
|
1930
|
-
if (peer instanceof _2_tl_js_1.types.InputPeerChannel) {
|
|
1931
|
-
await this.api.channels.editPhoto({ channel: new _2_tl_js_1.types.InputChannel(peer), photo: new _2_tl_js_1.types.InputChatPhotoEmpty() });
|
|
1932
|
-
}
|
|
1933
|
-
else if (peer instanceof _2_tl_js_1.types.InputPeerChat) {
|
|
1934
|
-
await this.api.messages.editChatPhoto({ chat_id: peer.chat_id, photo: new _2_tl_js_1.types.InputChatPhotoEmpty() });
|
|
1935
|
-
}
|
|
1768
|
+
await __classPrivateFieldGet(this, _Client_messageManager, "f").deleteChatPhoto(chatId);
|
|
1936
1769
|
}
|
|
1937
1770
|
/**
|
|
1938
1771
|
* Delete all messages sent by a specific member of a chat.
|
|
@@ -1981,46 +1814,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1981
1814
|
* @param memberId The identifier of the member.
|
|
1982
1815
|
*/
|
|
1983
1816
|
async banChatMember(chatId, memberId, params) {
|
|
1984
|
-
|
|
1985
|
-
if (!(chat instanceof _2_tl_js_1.types.InputPeerChannel) && !(chat instanceof _2_tl_js_1.types.InputPeerChat)) {
|
|
1986
|
-
throw new Error("Invalid chat ID");
|
|
1987
|
-
}
|
|
1988
|
-
const member = await this.getInputPeer(memberId);
|
|
1989
|
-
if (chat instanceof _2_tl_js_1.types.InputPeerChannel) {
|
|
1990
|
-
if (params?.deleteMessages) {
|
|
1991
|
-
try {
|
|
1992
|
-
await this.deleteChatMemberMessages(chatId, memberId);
|
|
1993
|
-
}
|
|
1994
|
-
catch {
|
|
1995
|
-
//
|
|
1996
|
-
}
|
|
1997
|
-
}
|
|
1998
|
-
await this.api.channels.editBanned({
|
|
1999
|
-
channel: new _2_tl_js_1.types.InputChannel(chat),
|
|
2000
|
-
participant: member,
|
|
2001
|
-
banned_rights: new _2_tl_js_1.types.ChatBannedRights({
|
|
2002
|
-
until_date: params?.untilDate ? (0, _1_utilities_js_1.toUnixTimestamp)(params.untilDate) : 0,
|
|
2003
|
-
view_messages: true,
|
|
2004
|
-
send_messages: true,
|
|
2005
|
-
send_media: true,
|
|
2006
|
-
send_stickers: true,
|
|
2007
|
-
send_gifs: true,
|
|
2008
|
-
send_games: true,
|
|
2009
|
-
send_inline: true,
|
|
2010
|
-
embed_links: true,
|
|
2011
|
-
}),
|
|
2012
|
-
});
|
|
2013
|
-
}
|
|
2014
|
-
else if (chat instanceof _2_tl_js_1.types.InputPeerChat) {
|
|
2015
|
-
if (!(member instanceof _2_tl_js_1.types.InputPeerUser)) {
|
|
2016
|
-
throw new Error("Invalid user ID");
|
|
2017
|
-
}
|
|
2018
|
-
await this.api.messages.deleteChatUser({
|
|
2019
|
-
chat_id: chat.chat_id,
|
|
2020
|
-
user_id: new _2_tl_js_1.types.InputUser(member),
|
|
2021
|
-
revoke_history: params?.deleteMessages ? true : undefined,
|
|
2022
|
-
});
|
|
2023
|
-
}
|
|
1817
|
+
await __classPrivateFieldGet(this, _Client_messageManager, "f").banChatMember(chatId, memberId, params);
|
|
2024
1818
|
}
|
|
2025
1819
|
/**
|
|
2026
1820
|
* Unban a member from a chat.
|
|
@@ -2030,16 +1824,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
2030
1824
|
* @param memberId The identifier of the member.
|
|
2031
1825
|
*/
|
|
2032
1826
|
async unbanChatMember(chatId, memberId) {
|
|
2033
|
-
|
|
2034
|
-
if (!(chat instanceof _2_tl_js_1.types.InputPeerChannel)) {
|
|
2035
|
-
throw new Error("Invalid chat ID");
|
|
2036
|
-
}
|
|
2037
|
-
const member = await this.getInputPeer(memberId);
|
|
2038
|
-
await this.api.channels.editBanned({
|
|
2039
|
-
channel: new _2_tl_js_1.types.InputChannel(chat),
|
|
2040
|
-
participant: member,
|
|
2041
|
-
banned_rights: new _2_tl_js_1.types.ChatBannedRights({ until_date: 0 }),
|
|
2042
|
-
});
|
|
1827
|
+
await __classPrivateFieldGet(this, _Client_messageManager, "f").unbanChatMember(chatId, memberId);
|
|
2043
1828
|
}
|
|
2044
1829
|
/**
|
|
2045
1830
|
* Kick a member from a chat. Same as a banChatMember call followed by unbanChatMember.
|
|
@@ -2049,8 +1834,8 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
2049
1834
|
* @param memberId The identifier of the member.
|
|
2050
1835
|
*/
|
|
2051
1836
|
async kickChatMember(chatId, memberId) {
|
|
2052
|
-
await this.banChatMember(chatId, memberId);
|
|
2053
|
-
await this.unbanChatMember(chatId, memberId);
|
|
1837
|
+
await __classPrivateFieldGet(this, _Client_messageManager, "f").banChatMember(chatId, memberId);
|
|
1838
|
+
await __classPrivateFieldGet(this, _Client_messageManager, "f").unbanChatMember(chatId, memberId);
|
|
2054
1839
|
}
|
|
2055
1840
|
/**
|
|
2056
1841
|
* Set the rights of a chat member.
|
|
@@ -2060,67 +1845,11 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
2060
1845
|
* @param memberId The identifier of a member.
|
|
2061
1846
|
*/
|
|
2062
1847
|
async setChatMemberRights(chatId, memberId, params) {
|
|
2063
|
-
|
|
2064
|
-
if (!(chat instanceof _2_tl_js_1.types.InputPeerChannel)) {
|
|
2065
|
-
throw new Error("Invalid chat ID");
|
|
2066
|
-
}
|
|
2067
|
-
const member = await this.getInputPeer(memberId);
|
|
2068
|
-
await this.api.channels.editBanned({
|
|
2069
|
-
channel: new _2_tl_js_1.types.InputChannel(chat),
|
|
2070
|
-
participant: member,
|
|
2071
|
-
banned_rights: new _2_tl_js_1.types.ChatBannedRights({
|
|
2072
|
-
until_date: params?.untilDate ? (0, _1_utilities_js_1.toUnixTimestamp)(params.untilDate) : 0,
|
|
2073
|
-
send_messages: params?.rights?.canSendMessages ? true : undefined,
|
|
2074
|
-
send_audios: params?.rights?.canSendAudio ? true : undefined,
|
|
2075
|
-
send_docs: params?.rights?.canSendDocuments ? true : undefined,
|
|
2076
|
-
send_photos: params?.rights?.canSendPhotos ? true : undefined,
|
|
2077
|
-
send_videos: params?.rights?.canSendVideos ? true : undefined,
|
|
2078
|
-
send_roundvideos: params?.rights?.canSendVideoNotes ? true : undefined,
|
|
2079
|
-
send_voices: params?.rights?.canSendVoice ? true : undefined,
|
|
2080
|
-
send_polls: params?.rights?.canSendPolls ? true : undefined,
|
|
2081
|
-
send_stickers: params?.rights?.canSendStickers ? true : undefined,
|
|
2082
|
-
send_gifs: params?.rights?.canSendAnimations ? true : undefined,
|
|
2083
|
-
send_games: params?.rights?.canSendGames ? true : undefined,
|
|
2084
|
-
send_inline: params?.rights?.canSendInlineBotResults ? true : undefined,
|
|
2085
|
-
embed_links: params?.rights?.canAddWebPagePreviews ? true : undefined,
|
|
2086
|
-
change_info: params?.rights?.canChangeInfo ? true : undefined,
|
|
2087
|
-
invite_users: params?.rights?.canInviteUsers ? true : undefined,
|
|
2088
|
-
pin_messages: params?.rights?.canPinMessages ? true : undefined,
|
|
2089
|
-
manage_topics: params?.rights?.canManageTopics ? true : undefined,
|
|
2090
|
-
}),
|
|
2091
|
-
});
|
|
1848
|
+
await __classPrivateFieldGet(this, _Client_messageManager, "f").setChatMemberRights(chatId, memberId, params);
|
|
2092
1849
|
}
|
|
2093
1850
|
}
|
|
2094
1851
|
exports.Client = Client;
|
|
2095
|
-
|
|
2096
|
-
const entities_ = params?.entities ?? [];
|
|
2097
|
-
const parseMode = params?.parseMode ?? __classPrivateFieldGet(this, _Client_parseMode, "f");
|
|
2098
|
-
switch (parseMode) {
|
|
2099
|
-
case null:
|
|
2100
|
-
break;
|
|
2101
|
-
case "HTML": {
|
|
2102
|
-
const [newText, entitiesToPush] = (0, _0_html_js_1.parseHtml)(text);
|
|
2103
|
-
text = newText;
|
|
2104
|
-
for (const entity of entitiesToPush) {
|
|
2105
|
-
entities_.push(entity);
|
|
2106
|
-
}
|
|
2107
|
-
break;
|
|
2108
|
-
}
|
|
2109
|
-
default:
|
|
2110
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
2111
|
-
}
|
|
2112
|
-
const entities = entities_?.length > 0 ? entities_.map((v) => (0, _3_types_js_1.messageEntityToTlObject)(v)) : undefined;
|
|
2113
|
-
return [text, entities];
|
|
2114
|
-
}, _Client_getMe = async function _Client_getMe() {
|
|
2115
|
-
if (__classPrivateFieldGet(this, _Client_lastGetMe, "f") != null) {
|
|
2116
|
-
return __classPrivateFieldGet(this, _Client_lastGetMe, "f");
|
|
2117
|
-
}
|
|
2118
|
-
else {
|
|
2119
|
-
const user = await this.getMe();
|
|
2120
|
-
__classPrivateFieldSet(this, _Client_lastGetMe, user, "f");
|
|
2121
|
-
return user;
|
|
2122
|
-
}
|
|
2123
|
-
}, _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
|
|
1852
|
+
_Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
|
|
2124
1853
|
await __classPrivateFieldGet(this, _Client_handle, "f").call(this, await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, update), _0_utilities_js_1.resolve);
|
|
2125
1854
|
}, _Client_queueHandleCtxUpdate = function _Client_queueHandleCtxUpdate(update) {
|
|
2126
1855
|
__classPrivateFieldGet(this, _Client_updateManager, "f").getHandleUpdateQueue(_1_update_manager_js_1.UpdateManager.MAIN_BOX_ID).add(async () => {
|
|
@@ -2139,152 +1868,47 @@ _Client_parseText = function _Client_parseText(text, params) {
|
|
|
2139
1868
|
await this.storage.setEntity(entity);
|
|
2140
1869
|
}
|
|
2141
1870
|
}
|
|
2142
|
-
if (
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
await this.storage.setMessage(chatId, update.message.id, update.message);
|
|
2146
|
-
promises.push(__classPrivateFieldGet(this, _Client_chatListManager, "f").reassignChatLastMessage(chatId));
|
|
2147
|
-
}
|
|
2148
|
-
}
|
|
2149
|
-
if (update instanceof _2_tl_js_1.types.UpdateMessageReactions) {
|
|
2150
|
-
const chatId = (0, _2_tl_js_1.peerToChatId)(update.peer);
|
|
2151
|
-
const message = await this.storage.getMessage(chatId, update.msg_id);
|
|
2152
|
-
if (message instanceof _2_tl_js_1.types.Message) {
|
|
2153
|
-
message.reactions = update.reactions;
|
|
2154
|
-
await this.storage.setMessage(chatId, update.msg_id, message);
|
|
2155
|
-
const views = message.views ?? 0;
|
|
2156
|
-
const forwards = message.forwards ?? 0;
|
|
2157
|
-
const recentReactions = update.reactions.recent_reactions ?? [];
|
|
2158
|
-
const reactions = update.reactions.results.map((v) => (0, _3_types_js_1.constructMessageReaction)(v, recentReactions));
|
|
2159
|
-
promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, { messageInteractions: { chatId, messageId: update.msg_id, reactions, views, forwards } }));
|
|
2160
|
-
}
|
|
2161
|
-
}
|
|
2162
|
-
else if (update instanceof _2_tl_js_1.types.UpdateChannelMessageViews || update instanceof _2_tl_js_1.types.UpdateChannelMessageForwards) {
|
|
2163
|
-
const chatId = (0, _2_tl_js_1.peerToChatId)(new _2_tl_js_1.types.PeerChannel(update));
|
|
2164
|
-
const message = await this.storage.getMessage(chatId, update.id);
|
|
2165
|
-
if (message instanceof _2_tl_js_1.types.Message) {
|
|
2166
|
-
if ("views" in update) {
|
|
2167
|
-
message.views = update.views;
|
|
2168
|
-
}
|
|
2169
|
-
if ("forwards" in update) {
|
|
2170
|
-
message.forwards = update.forwards;
|
|
2171
|
-
}
|
|
2172
|
-
const views = message.views ?? 0;
|
|
2173
|
-
const forwards = message.forwards ?? 0;
|
|
2174
|
-
const recentReactions = message.reactions?.recent_reactions ?? [];
|
|
2175
|
-
const reactions = message.reactions?.results.map((v) => (0, _3_types_js_1.constructMessageReaction)(v, recentReactions)) ?? [];
|
|
2176
|
-
promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, { messageInteractions: { chatId, messageId: update.id, reactions, views, forwards } }));
|
|
2177
|
-
}
|
|
2178
|
-
}
|
|
2179
|
-
if (update instanceof _2_tl_js_1.types.UpdateNewMessage ||
|
|
2180
|
-
update instanceof _2_tl_js_1.types.UpdateNewChannelMessage ||
|
|
2181
|
-
update instanceof _2_tl_js_1.types.UpdateEditMessage ||
|
|
2182
|
-
update instanceof _2_tl_js_1.types.UpdateEditChannelMessage) {
|
|
2183
|
-
if (!(update.message instanceof _2_tl_js_1.types.MessageEmpty)) {
|
|
2184
|
-
const isOutgoing = update.message.out;
|
|
2185
|
-
let shouldIgnore = isOutgoing ? (await this.storage.getAccountType()) == "user" ? false : true : false;
|
|
2186
|
-
if (__classPrivateFieldGet(this, _Client_ignoreOutgoing, "f") != null && isOutgoing) {
|
|
2187
|
-
shouldIgnore = __classPrivateFieldGet(this, _Client_ignoreOutgoing, "f");
|
|
2188
|
-
}
|
|
2189
|
-
if (!shouldIgnore) {
|
|
2190
|
-
const message = await __classPrivateFieldGet(this, _Client_messageManager, "f").constructMessage(update.message);
|
|
2191
|
-
promises.push((async () => {
|
|
2192
|
-
if (update instanceof _2_tl_js_1.types.UpdateNewMessage || update instanceof _2_tl_js_1.types.UpdateNewChannelMessage) {
|
|
2193
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, { message });
|
|
2194
|
-
}
|
|
2195
|
-
else {
|
|
2196
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, { editedMessage: message });
|
|
2197
|
-
}
|
|
2198
|
-
})());
|
|
2199
|
-
}
|
|
2200
|
-
}
|
|
2201
|
-
}
|
|
2202
|
-
if (update instanceof _2_tl_js_1.types.UpdateDeleteMessages) {
|
|
2203
|
-
const deletedMessages = new Array();
|
|
2204
|
-
for (const messageId of update.messages) {
|
|
2205
|
-
const chatId = await this.storage.getMessageChat(messageId);
|
|
2206
|
-
if (chatId) {
|
|
2207
|
-
deletedMessages.push({ chatId, messageId });
|
|
2208
|
-
}
|
|
2209
|
-
}
|
|
2210
|
-
if (deletedMessages.length > 0) {
|
|
2211
|
-
promises.push((async () => {
|
|
2212
|
-
try {
|
|
2213
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, { deletedMessages });
|
|
2214
|
-
}
|
|
2215
|
-
finally {
|
|
2216
|
-
for (const { chatId, messageId } of deletedMessages) {
|
|
2217
|
-
await this.storage.setMessage(chatId, messageId, null);
|
|
2218
|
-
await __classPrivateFieldGet(this, _Client_chatListManager, "f").reassignChatLastMessage(chatId);
|
|
2219
|
-
}
|
|
2220
|
-
}
|
|
2221
|
-
})());
|
|
2222
|
-
}
|
|
2223
|
-
}
|
|
2224
|
-
else if (update instanceof _2_tl_js_1.types.UpdateDeleteChannelMessages) {
|
|
2225
|
-
const chatId = (0, _2_tl_js_1.getChannelChatId)(update.channel_id);
|
|
2226
|
-
const deletedMessages = new Array();
|
|
2227
|
-
for (const messageId of update.messages) {
|
|
2228
|
-
const message = await this.storage.getMessage(chatId, messageId);
|
|
2229
|
-
if (message != null) {
|
|
2230
|
-
deletedMessages.push({ chatId, messageId });
|
|
2231
|
-
}
|
|
2232
|
-
}
|
|
2233
|
-
if (deletedMessages.length > 0) {
|
|
1871
|
+
if (_2_message_manager_js_1.MessageManager.canHandleUpdate(update)) {
|
|
1872
|
+
const update_ = await __classPrivateFieldGet(this, _Client_messageManager, "f").handleUpdate(update);
|
|
1873
|
+
if (update_) {
|
|
2234
1874
|
promises.push((async () => {
|
|
2235
1875
|
try {
|
|
2236
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this,
|
|
1876
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, update_);
|
|
2237
1877
|
}
|
|
2238
1878
|
finally {
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
1879
|
+
if ("deletedMessages" in update_) {
|
|
1880
|
+
for (const { chatId, messageId } of update_.deletedMessages) {
|
|
1881
|
+
await this.storage.setMessage(chatId, messageId, null);
|
|
1882
|
+
await __classPrivateFieldGet(this, _Client_chatListManager, "f").reassignChatLastMessage(chatId);
|
|
1883
|
+
}
|
|
2242
1884
|
}
|
|
2243
1885
|
}
|
|
2244
1886
|
})());
|
|
2245
1887
|
}
|
|
2246
1888
|
}
|
|
2247
|
-
if (
|
|
2248
|
-
promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this,
|
|
1889
|
+
if (_3_callback_query_manager_js_1.CallbackQueryManager.canHandleUpdate(update)) {
|
|
1890
|
+
promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, await __classPrivateFieldGet(this, _Client_callbackQueryManager, "f").handleUpdate(update)));
|
|
2249
1891
|
}
|
|
2250
|
-
|
|
2251
|
-
promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this,
|
|
1892
|
+
if (_3_inline_query_manager_js_1.InlineQueryManager.canHandleUpdate(update)) {
|
|
1893
|
+
promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, await __classPrivateFieldGet(this, _Client_inlineQueryManager, "f").handleUpdate(update)));
|
|
2252
1894
|
}
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
const messageReactionCount = await (0, _3_types_js_1.constructMessageReactionCount)(update, this[getEntity].bind(this));
|
|
2258
|
-
if (messageReactionCount) {
|
|
2259
|
-
promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, { messageReactionCount }));
|
|
1895
|
+
if (_1_reaction_manager_js_1.ReactionManager.canHandleUpdate(update)) {
|
|
1896
|
+
const upd = await __classPrivateFieldGet(this, _Client_reactionManager, "f").handleUpdate(update);
|
|
1897
|
+
if (upd) {
|
|
1898
|
+
promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, upd));
|
|
2260
1899
|
}
|
|
2261
1900
|
}
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
if (messageReactions) {
|
|
2265
|
-
promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, { messageReactions }));
|
|
2266
|
-
}
|
|
1901
|
+
if (_3_chat_list_manager_js_1.ChatListManager.canHandleUpdate(update)) {
|
|
1902
|
+
await __classPrivateFieldGet(this, _Client_chatListManager, "f").handleUpdate(update);
|
|
2267
1903
|
}
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
await __classPrivateFieldGet(this, _Client_chatListManager, "f").handelUpdateFolderPeers(update);
|
|
2273
|
-
}
|
|
2274
|
-
if (update instanceof _2_tl_js_1.types.UpdateChannel) {
|
|
2275
|
-
await __classPrivateFieldGet(this, _Client_chatListManager, "f").handleUpdateChannel(update);
|
|
2276
|
-
}
|
|
2277
|
-
else if (update instanceof _2_tl_js_1.types.UpdateChat) {
|
|
2278
|
-
await __classPrivateFieldGet(this, _Client_chatListManager, "f").handleUpdateChat(update);
|
|
1904
|
+
return () => Promise.all(promises);
|
|
1905
|
+
}, _Client_getMe = async function _Client_getMe() {
|
|
1906
|
+
if (__classPrivateFieldGet(this, _Client_lastGetMe, "f") != null) {
|
|
1907
|
+
return __classPrivateFieldGet(this, _Client_lastGetMe, "f");
|
|
2279
1908
|
}
|
|
2280
|
-
else
|
|
2281
|
-
await
|
|
1909
|
+
else {
|
|
1910
|
+
const user = await this.getMe();
|
|
1911
|
+
__classPrivateFieldSet(this, _Client_lastGetMe, user, "f");
|
|
1912
|
+
return user;
|
|
2282
1913
|
}
|
|
2283
|
-
return () => Promise.all(promises);
|
|
2284
|
-
}, _Client_setMyInfo =
|
|
2285
|
-
//#endregion
|
|
2286
|
-
async function _Client_setMyInfo(info) {
|
|
2287
|
-
await this.api.bots.setBotInfo({ bot: new _2_tl_js_1.types.InputUserSelf(), ...info });
|
|
2288
|
-
}, _Client_getMyInfo = function _Client_getMyInfo(languageCode) {
|
|
2289
|
-
return this.api.bots.getBotInfo({ bot: new _2_tl_js_1.types.InputUserSelf(), lang_code: languageCode ?? "" });
|
|
2290
1914
|
};
|