@mtkruto/browser 0.119.0 → 0.120.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/esm/0_errors.d.ts.map +1 -1
- package/esm/0_errors.js +9 -31
- package/esm/3_errors.js +2 -12
- package/esm/4_errors.js +2 -12
- package/esm/_dnt.polyfills.d.ts +0 -99
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/_dnt.polyfills.js +1 -127
- package/esm/client/0_abortable_loop.js +26 -39
- package/esm/client/0_storage_operations.js +179 -218
- package/esm/client/1_client_plain.js +4 -22
- package/esm/client/2_account_manager.js +140 -149
- package/esm/client/2_bot_info_manager.js +26 -38
- package/esm/client/2_business_connection_manager.js +10 -23
- package/esm/client/2_client_encrypted.js +198 -215
- package/esm/client/2_file_manager.js +255 -262
- package/esm/client/2_network_statistics_manager.js +31 -44
- package/esm/client/2_payment_manager.js +7 -20
- package/esm/client/2_reaction_manager.js +7 -20
- package/esm/client/2_translations_manager.js +101 -111
- package/esm/client/2_update_manager.js +750 -745
- package/esm/client/3_client_encrypted_pool.js +10 -26
- package/esm/client/3_message_manager.js +503 -508
- package/esm/client/3_video_chat_manager.js +57 -68
- package/esm/client/4_callback_query_manager.js +18 -30
- package/esm/client/4_chat_list_manager.js +140 -146
- package/esm/client/4_chat_manager.js +161 -169
- package/esm/client/4_checklist_manager.js +26 -39
- package/esm/client/4_context.js +244 -259
- package/esm/client/4_forum_manager.js +67 -73
- package/esm/client/4_gift_manager.js +22 -35
- package/esm/client/4_inline_query_manager.js +16 -28
- package/esm/client/4_link_preview_manager.js +6 -19
- package/esm/client/4_poll_manager.js +44 -57
- package/esm/client/4_story_manager.js +41 -53
- package/esm/client/5_composer.js +13 -26
- package/esm/client/6_client.js +866 -896
- package/esm/client/6_client_dispatcher.js +308 -325
- package/esm/client/7_client_worker.js +16 -29
- package/esm/connection/1_connection_tcp.js +55 -82
- package/esm/connection/1_connection_web_socket.js +75 -91
- package/esm/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
- package/esm/deps/jsr.io/@std/async/1.2.0/mux_async_iterator.js +31 -47
- package/esm/deps/jsr.io/@std/async/1.2.0/tee.js +11 -34
- package/esm/deps/jsr.io/@std/cache/0.2.2/lru_cache.js +30 -47
- package/esm/deps/jsr.io/@std/datetime/0.225.7/_date_time_formatter.js +4 -17
- package/esm/session/0_session_state.js +12 -38
- package/esm/session/1_session.js +49 -72
- package/esm/session/2_session_encrypted.js +422 -420
- package/esm/storage/2_storage_indexed_db.js +26 -44
- package/esm/storage/2_storage_local_storage.js +3 -16
- package/esm/storage/2_storage_memory.js +24 -41
- package/esm/storage/2_storage_session_storage.js +3 -16
- package/esm/tl/1_tl_reader.d.ts +1 -1
- package/esm/tl/1_tl_reader.d.ts.map +1 -1
- package/esm/tl/1_tl_reader.js +95 -103
- package/esm/tl/1_tl_writer.js +169 -178
- package/esm/transport/0_transport.js +1 -8
- package/esm/transport/1_transport_abridged.js +11 -24
- package/esm/transport/1_transport_intermediate.js +10 -23
- package/esm/utilities/0_mutex.js +4 -19
- package/esm/utilities/0_part_stream.js +11 -25
- package/esm/utilities/1_crypto.js +42 -53
- package/esm/utilities/2_queue.js +29 -47
- package/package.json +1 -1
- package/script/0_errors.d.ts.map +1 -1
- package/script/0_errors.js +9 -31
- package/script/3_errors.js +2 -12
- package/script/4_errors.js +2 -12
- package/script/_dnt.polyfills.d.ts +0 -99
- package/script/_dnt.polyfills.d.ts.map +1 -1
- package/script/_dnt.polyfills.js +0 -128
- package/script/client/0_abortable_loop.js +27 -40
- package/script/client/0_storage_operations.js +179 -218
- package/script/client/1_client_plain.js +4 -22
- package/script/client/2_account_manager.js +140 -149
- package/script/client/2_bot_info_manager.js +26 -38
- package/script/client/2_business_connection_manager.js +10 -23
- package/script/client/2_client_encrypted.js +199 -216
- package/script/client/2_file_manager.js +255 -262
- package/script/client/2_network_statistics_manager.js +32 -45
- package/script/client/2_payment_manager.js +7 -20
- package/script/client/2_reaction_manager.js +7 -20
- package/script/client/2_translations_manager.js +102 -112
- package/script/client/2_update_manager.js +750 -745
- package/script/client/3_client_encrypted_pool.js +10 -26
- package/script/client/3_message_manager.js +503 -508
- package/script/client/3_video_chat_manager.js +57 -68
- package/script/client/4_callback_query_manager.js +18 -30
- package/script/client/4_chat_list_manager.js +140 -146
- package/script/client/4_chat_manager.js +161 -169
- package/script/client/4_checklist_manager.js +26 -39
- package/script/client/4_context.js +244 -259
- package/script/client/4_forum_manager.js +67 -73
- package/script/client/4_gift_manager.js +22 -35
- package/script/client/4_inline_query_manager.js +16 -28
- package/script/client/4_link_preview_manager.js +6 -19
- package/script/client/4_poll_manager.js +44 -57
- package/script/client/4_story_manager.js +41 -53
- package/script/client/5_composer.js +13 -26
- package/script/client/6_client.js +866 -896
- package/script/client/6_client_dispatcher.js +308 -325
- package/script/client/7_client_worker.js +16 -29
- package/script/connection/1_connection_tcp.js +55 -82
- package/script/connection/1_connection_web_socket.js +75 -91
- package/script/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
- package/script/deps/jsr.io/@std/async/1.2.0/mux_async_iterator.js +31 -47
- package/script/deps/jsr.io/@std/async/1.2.0/tee.js +11 -34
- package/script/deps/jsr.io/@std/cache/0.2.2/lru_cache.js +30 -47
- package/script/deps/jsr.io/@std/datetime/0.225.7/_date_time_formatter.js +4 -17
- package/script/session/0_session_state.js +12 -38
- package/script/session/1_session.js +49 -72
- package/script/session/2_session_encrypted.js +423 -421
- package/script/storage/2_storage_indexed_db.js +26 -44
- package/script/storage/2_storage_local_storage.js +3 -16
- package/script/storage/2_storage_memory.js +24 -41
- package/script/storage/2_storage_session_storage.js +3 -16
- package/script/tl/1_tl_reader.d.ts +1 -1
- package/script/tl/1_tl_reader.d.ts.map +1 -1
- package/script/tl/1_tl_reader.js +96 -104
- package/script/tl/1_tl_writer.js +170 -179
- package/script/transport/0_transport.js +1 -8
- package/script/transport/1_transport_abridged.js +11 -24
- package/script/transport/1_transport_intermediate.js +10 -23
- package/script/utilities/0_mutex.js +4 -19
- package/script/utilities/0_part_stream.js +11 -25
- package/script/utilities/1_crypto.js +43 -54
- package/script/utilities/2_queue.js +30 -48
package/esm/client/6_client.js
CHANGED
|
@@ -17,18 +17,6 @@
|
|
|
17
17
|
* You should have received a copy of the GNU Lesser General Public License
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
21
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
22
|
-
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");
|
|
23
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
24
|
-
};
|
|
25
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
26
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
27
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
28
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
29
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
30
|
-
};
|
|
31
|
-
var _Client_instances, _Client_clients, _Client_downloadPools, _Client_uploadPools, _Client_guaranteeUpdateDelivery, _Client_accountManager, _Client_botInfoManager, _Client_businessConnectionManager, _Client_fileManager, _Client_networkStatisticsManager, _Client_paymentManager, _Client_reactionManager, _Client_translationsManager, _Client_updateManager, _Client_messageManager, _Client_videoChatManager, _Client_callbackQueryManager, _Client_chatListManager, _Client_chatManager, _Client_checklistManager, _Client_forumManager, _Client_giftManager, _Client_inlineQueryManager, _Client_linkPreviewManager, _Client_pollManager, _Client_storyManager, _Client_managers, _Client_storage_, _Client_messageStorage_, _Client_parseMode, _Client_apiId, _Client_apiHash, _Client_transportProvider, _Client_publicKeys, _Client_outgoingMessages, _Client_persistCache, _Client_disableUpdates, _Client_authString, _Client_initialDc, _Client_L, _Client_LsignIn, _Client_LupdateGapRecoveryLoop, _Client_LstorageWriteLoop, _Client_LhandleMigrationError, _Client_Lmin, _Client_setMainClient, _Client_newClient, _Client_disconnectAllClients, _Client_client_get, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_stateChangeHandler, _Client_storageInited, _Client_initStorage, _Client_connectMutex, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_getSelfId, _Client_getIsPremium, _Client_lastUpdates, _Client_updateGapRecoveryLoop, _Client_clientDisconnectionLoop, _Client_storageWriteLoop, _Client_checkAuthorization, _Client_getClient, _Client_getMainClientMutex, _Client_getMainClient, _Client_getDownloadClient, _Client_getUploadPoolSize, _Client_getUploadClient, _Client_setupClient, _Client_importAuthorization, _Client_invoke, _Client_handleInvokeError, _Client_authStringImported, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerChatId, _Client_getInputPeerInner, _Client_getMinInputPeer, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe, _Client_getMeInner, _Client_previouslyConnected, _Client_lastConnectionState, _Client_onConnectionStateChange;
|
|
32
20
|
import { delay, MINUTE, SECOND, unreachable } from "../0_deps.js";
|
|
33
21
|
import { AccessError, ConnectionError, InputError } from "../0_errors.js";
|
|
34
22
|
import { drop, getLogger, Mutex, ZERO_CHANNEL_ID } from "../1_utilities.js";
|
|
@@ -78,258 +66,131 @@ const mustGetPeer = Symbol();
|
|
|
78
66
|
* An MTKruto client.
|
|
79
67
|
*/
|
|
80
68
|
export class Client extends Composer {
|
|
69
|
+
#clients = new Array();
|
|
70
|
+
#downloadPools = {};
|
|
71
|
+
#uploadPools = {};
|
|
72
|
+
#guaranteeUpdateDelivery;
|
|
73
|
+
// 2_
|
|
74
|
+
#accountManager;
|
|
75
|
+
#botInfoManager;
|
|
76
|
+
#businessConnectionManager;
|
|
77
|
+
#fileManager;
|
|
78
|
+
#networkStatisticsManager;
|
|
79
|
+
#paymentManager;
|
|
80
|
+
#reactionManager;
|
|
81
|
+
#translationsManager;
|
|
82
|
+
#updateManager;
|
|
83
|
+
// 3_
|
|
84
|
+
#messageManager;
|
|
85
|
+
#videoChatManager;
|
|
86
|
+
// 4_
|
|
87
|
+
#callbackQueryManager;
|
|
88
|
+
#chatListManager;
|
|
89
|
+
#chatManager;
|
|
90
|
+
#checklistManager;
|
|
91
|
+
#forumManager;
|
|
92
|
+
#giftManager;
|
|
93
|
+
#inlineQueryManager;
|
|
94
|
+
#linkPreviewManager;
|
|
95
|
+
#pollManager;
|
|
96
|
+
#storyManager;
|
|
97
|
+
// deno-lint-ignore no-explicit-any
|
|
98
|
+
#managers;
|
|
81
99
|
// deno-lint-ignore no-explicit-any
|
|
82
100
|
get managers() {
|
|
83
|
-
return
|
|
101
|
+
return this.#managers ?? (this.#managers ??= {
|
|
84
102
|
// 2_
|
|
85
|
-
accountManager:
|
|
86
|
-
botInfoManager:
|
|
87
|
-
businessConnectionManager:
|
|
88
|
-
fileManager:
|
|
89
|
-
networkStatisticsManager:
|
|
90
|
-
paymentManager:
|
|
91
|
-
reactionManager:
|
|
92
|
-
translationsManager:
|
|
93
|
-
updateManager:
|
|
103
|
+
accountManager: this.#accountManager,
|
|
104
|
+
botInfoManager: this.#botInfoManager,
|
|
105
|
+
businessConnectionManager: this.#businessConnectionManager,
|
|
106
|
+
fileManager: this.#fileManager,
|
|
107
|
+
networkStatisticsManager: this.#networkStatisticsManager,
|
|
108
|
+
paymentManager: this.#paymentManager,
|
|
109
|
+
reactionManager: this.#reactionManager,
|
|
110
|
+
translationsManager: this.#translationsManager,
|
|
111
|
+
updateManager: this.#updateManager,
|
|
94
112
|
// 3_
|
|
95
|
-
messageManager:
|
|
96
|
-
videoChatManager:
|
|
113
|
+
messageManager: this.#messageManager,
|
|
114
|
+
videoChatManager: this.#videoChatManager,
|
|
97
115
|
// 4_
|
|
98
|
-
callbackQueryManager:
|
|
99
|
-
chatListManager:
|
|
100
|
-
chatManager:
|
|
101
|
-
checklistManager:
|
|
102
|
-
forumManager:
|
|
103
|
-
giftManager:
|
|
104
|
-
inlineQueryManager:
|
|
105
|
-
linkPreviewManager:
|
|
106
|
-
pollManager:
|
|
107
|
-
storyManager:
|
|
108
|
-
}
|
|
116
|
+
callbackQueryManager: this.#callbackQueryManager,
|
|
117
|
+
chatListManager: this.#chatListManager,
|
|
118
|
+
chatManager: this.#chatManager,
|
|
119
|
+
checklistManager: this.#checklistManager,
|
|
120
|
+
forumManager: this.#forumManager,
|
|
121
|
+
giftManager: this.#giftManager,
|
|
122
|
+
inlineQueryManager: this.#inlineQueryManager,
|
|
123
|
+
linkPreviewManager: this.#linkPreviewManager,
|
|
124
|
+
pollManager: this.#pollManager,
|
|
125
|
+
storyManager: this.#storyManager,
|
|
126
|
+
});
|
|
109
127
|
}
|
|
128
|
+
#storage_;
|
|
129
|
+
#messageStorage_;
|
|
130
|
+
storage;
|
|
131
|
+
messageStorage;
|
|
132
|
+
#parseMode;
|
|
133
|
+
#apiId;
|
|
134
|
+
#apiHash;
|
|
135
|
+
#transportProvider;
|
|
136
|
+
appVersion;
|
|
137
|
+
deviceModel;
|
|
138
|
+
language;
|
|
139
|
+
platform;
|
|
140
|
+
systemLangCode;
|
|
141
|
+
systemVersion;
|
|
142
|
+
#publicKeys;
|
|
143
|
+
#outgoingMessages;
|
|
144
|
+
#persistCache;
|
|
145
|
+
#disableUpdates;
|
|
146
|
+
#authString;
|
|
147
|
+
#initialDc;
|
|
148
|
+
#L;
|
|
149
|
+
#LsignIn;
|
|
150
|
+
#LupdateGapRecoveryLoop;
|
|
151
|
+
#LstorageWriteLoop;
|
|
152
|
+
#LhandleMigrationError;
|
|
153
|
+
#Lmin;
|
|
110
154
|
/**
|
|
111
155
|
* Constructs the client.
|
|
112
156
|
*/
|
|
113
157
|
constructor(params) {
|
|
114
158
|
super();
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
_Client_businessConnectionManager.set(this, void 0);
|
|
124
|
-
_Client_fileManager.set(this, void 0);
|
|
125
|
-
_Client_networkStatisticsManager.set(this, void 0);
|
|
126
|
-
_Client_paymentManager.set(this, void 0);
|
|
127
|
-
_Client_reactionManager.set(this, void 0);
|
|
128
|
-
_Client_translationsManager.set(this, void 0);
|
|
129
|
-
_Client_updateManager.set(this, void 0);
|
|
130
|
-
// 3_
|
|
131
|
-
_Client_messageManager.set(this, void 0);
|
|
132
|
-
_Client_videoChatManager.set(this, void 0);
|
|
133
|
-
// 4_
|
|
134
|
-
_Client_callbackQueryManager.set(this, void 0);
|
|
135
|
-
_Client_chatListManager.set(this, void 0);
|
|
136
|
-
_Client_chatManager.set(this, void 0);
|
|
137
|
-
_Client_checklistManager.set(this, void 0);
|
|
138
|
-
_Client_forumManager.set(this, void 0);
|
|
139
|
-
_Client_giftManager.set(this, void 0);
|
|
140
|
-
_Client_inlineQueryManager.set(this, void 0);
|
|
141
|
-
_Client_linkPreviewManager.set(this, void 0);
|
|
142
|
-
_Client_pollManager.set(this, void 0);
|
|
143
|
-
_Client_storyManager.set(this, void 0);
|
|
144
|
-
// deno-lint-ignore no-explicit-any
|
|
145
|
-
_Client_managers.set(this, void 0);
|
|
146
|
-
_Client_storage_.set(this, void 0);
|
|
147
|
-
_Client_messageStorage_.set(this, void 0);
|
|
148
|
-
Object.defineProperty(this, "storage", {
|
|
149
|
-
enumerable: true,
|
|
150
|
-
configurable: true,
|
|
151
|
-
writable: true,
|
|
152
|
-
value: void 0
|
|
153
|
-
});
|
|
154
|
-
Object.defineProperty(this, "messageStorage", {
|
|
155
|
-
enumerable: true,
|
|
156
|
-
configurable: true,
|
|
157
|
-
writable: true,
|
|
158
|
-
value: void 0
|
|
159
|
-
});
|
|
160
|
-
_Client_parseMode.set(this, void 0);
|
|
161
|
-
_Client_apiId.set(this, void 0);
|
|
162
|
-
_Client_apiHash.set(this, void 0);
|
|
163
|
-
_Client_transportProvider.set(this, void 0);
|
|
164
|
-
Object.defineProperty(this, "appVersion", {
|
|
165
|
-
enumerable: true,
|
|
166
|
-
configurable: true,
|
|
167
|
-
writable: true,
|
|
168
|
-
value: void 0
|
|
169
|
-
});
|
|
170
|
-
Object.defineProperty(this, "deviceModel", {
|
|
171
|
-
enumerable: true,
|
|
172
|
-
configurable: true,
|
|
173
|
-
writable: true,
|
|
174
|
-
value: void 0
|
|
175
|
-
});
|
|
176
|
-
Object.defineProperty(this, "language", {
|
|
177
|
-
enumerable: true,
|
|
178
|
-
configurable: true,
|
|
179
|
-
writable: true,
|
|
180
|
-
value: void 0
|
|
181
|
-
});
|
|
182
|
-
Object.defineProperty(this, "platform", {
|
|
183
|
-
enumerable: true,
|
|
184
|
-
configurable: true,
|
|
185
|
-
writable: true,
|
|
186
|
-
value: void 0
|
|
187
|
-
});
|
|
188
|
-
Object.defineProperty(this, "systemLangCode", {
|
|
189
|
-
enumerable: true,
|
|
190
|
-
configurable: true,
|
|
191
|
-
writable: true,
|
|
192
|
-
value: void 0
|
|
193
|
-
});
|
|
194
|
-
Object.defineProperty(this, "systemVersion", {
|
|
195
|
-
enumerable: true,
|
|
196
|
-
configurable: true,
|
|
197
|
-
writable: true,
|
|
198
|
-
value: void 0
|
|
199
|
-
});
|
|
200
|
-
_Client_publicKeys.set(this, void 0);
|
|
201
|
-
_Client_outgoingMessages.set(this, void 0);
|
|
202
|
-
_Client_persistCache.set(this, void 0);
|
|
203
|
-
_Client_disableUpdates.set(this, void 0);
|
|
204
|
-
_Client_authString.set(this, void 0);
|
|
205
|
-
_Client_initialDc.set(this, void 0);
|
|
206
|
-
_Client_L.set(this, void 0);
|
|
207
|
-
_Client_LsignIn.set(this, void 0);
|
|
208
|
-
_Client_LupdateGapRecoveryLoop.set(this, void 0);
|
|
209
|
-
_Client_LstorageWriteLoop.set(this, void 0);
|
|
210
|
-
_Client_LhandleMigrationError.set(this, void 0);
|
|
211
|
-
_Client_Lmin.set(this, void 0);
|
|
212
|
-
_Client_lastPropagatedConnectionState.set(this, null);
|
|
213
|
-
_Client_stateChangeHandler.set(this, ((isConnected) => {
|
|
214
|
-
const connectionState = isConnected ? "ready" : "notConnected";
|
|
215
|
-
if (__classPrivateFieldGet(this, _Client_lastPropagatedConnectionState, "f") !== connectionState) {
|
|
216
|
-
__classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateConnectionState).call(this, connectionState);
|
|
217
|
-
}
|
|
218
|
-
}).bind(this));
|
|
219
|
-
_Client_storageInited.set(this, false);
|
|
220
|
-
_Client_connectMutex.set(this, new Mutex());
|
|
221
|
-
_Client_lastPropagatedAuthorizationState.set(this, null);
|
|
222
|
-
_Client_lastUpdates.set(this, new Date());
|
|
223
|
-
_Client_updateGapRecoveryLoop.set(this, new AbortableLoop(async (loop, signal) => {
|
|
224
|
-
await delay(60 * SECOND, { signal });
|
|
225
|
-
if (!this.isConnected) {
|
|
226
|
-
loop.abort();
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
if (Date.now() - __classPrivateFieldGet(this, _Client_lastUpdates, "f").getTime() >= 15 * MINUTE) {
|
|
230
|
-
drop(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("lastUpdates").then(() => {
|
|
231
|
-
__classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
|
|
232
|
-
}));
|
|
233
|
-
}
|
|
234
|
-
}, (loop, err) => {
|
|
235
|
-
if (!this.isConnected) {
|
|
236
|
-
loop.abort();
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
__classPrivateFieldGet(this, _Client_LupdateGapRecoveryLoop, "f").error(err);
|
|
240
|
-
}
|
|
241
|
-
}));
|
|
242
|
-
_Client_clientDisconnectionLoop.set(this, new AbortableLoop(async (loop, signal) => {
|
|
243
|
-
await delay(60 * SECOND, { signal });
|
|
244
|
-
if (!this.isConnected) {
|
|
245
|
-
loop.abort();
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
const now = Date.now();
|
|
249
|
-
const disconnectAfter = 5 * MINUTE;
|
|
250
|
-
for (const [i, client] of __classPrivateFieldGet(this, _Client_clients, "f").entries()) {
|
|
251
|
-
if (i > 0 && !client.isDisconnected && client.lastRequest && now - client.lastRequest.getTime() >= disconnectAfter) {
|
|
252
|
-
client?.disconnect();
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}, (loop) => {
|
|
256
|
-
if (!this.isConnected) {
|
|
257
|
-
loop.abort();
|
|
258
|
-
}
|
|
259
|
-
}));
|
|
260
|
-
_Client_storageWriteLoop.set(this, new AbortableLoop(async (_loop, signal) => {
|
|
261
|
-
await delay(5 * SECOND, { signal });
|
|
262
|
-
await this.messageStorage.commit();
|
|
263
|
-
await this.storage.commit();
|
|
264
|
-
}, (err) => {
|
|
265
|
-
__classPrivateFieldGet(this, _Client_LstorageWriteLoop, "f").error(err);
|
|
266
|
-
}));
|
|
267
|
-
_Client_getMainClientMutex.set(this, new Mutex());
|
|
268
|
-
_Client_handleInvokeError.set(this, skipInvoke());
|
|
269
|
-
/**
|
|
270
|
-
* Invokes a function waiting and returning its reply.
|
|
271
|
-
* Requires the client to be connected.
|
|
272
|
-
*
|
|
273
|
-
* @param function_ The function to invoke.
|
|
274
|
-
*/
|
|
275
|
-
Object.defineProperty(this, "invoke", {
|
|
276
|
-
enumerable: true,
|
|
277
|
-
configurable: true,
|
|
278
|
-
writable: true,
|
|
279
|
-
value: Object.assign(__classPrivateFieldGet(this, _Client_instances, "m", _Client_invoke), {
|
|
280
|
-
use: (handler) => {
|
|
281
|
-
const handle = __classPrivateFieldGet(this, _Client_handleInvokeError, "f");
|
|
282
|
-
__classPrivateFieldSet(this, _Client_handleInvokeError, async (ctx, next) => {
|
|
283
|
-
let result = null;
|
|
284
|
-
return await handle(ctx, async () => {
|
|
285
|
-
if (result !== null)
|
|
286
|
-
return result;
|
|
287
|
-
result = await handler(ctx, next);
|
|
288
|
-
return result;
|
|
289
|
-
});
|
|
290
|
-
}, "f");
|
|
291
|
-
},
|
|
292
|
-
})
|
|
293
|
-
});
|
|
294
|
-
_Client_authStringImported.set(this, false);
|
|
295
|
-
_Client_lastGetMe.set(this, null);
|
|
296
|
-
_Client_previouslyConnected.set(this, false);
|
|
297
|
-
_Client_lastConnectionState.set(this, false);
|
|
298
|
-
__classPrivateFieldSet(this, _Client_apiId, params?.apiId ?? 0, "f");
|
|
299
|
-
__classPrivateFieldSet(this, _Client_apiHash, params?.apiHash ?? "", "f");
|
|
300
|
-
__classPrivateFieldSet(this, _Client_transportProvider, params?.transportProvider, "f");
|
|
301
|
-
__classPrivateFieldSet(this, _Client_initialDc, params?.initialDc ?? INITIAL_DC, "f");
|
|
302
|
-
__classPrivateFieldSet(this, _Client_storage_, params?.storage || new StorageMemory(), "f");
|
|
303
|
-
__classPrivateFieldSet(this, _Client_persistCache, params?.persistCache ?? false, "f");
|
|
304
|
-
if (!__classPrivateFieldGet(this, _Client_persistCache, "f")) {
|
|
305
|
-
__classPrivateFieldSet(this, _Client_messageStorage_, new StorageMemory(), "f");
|
|
159
|
+
this.#apiId = params?.apiId ?? 0;
|
|
160
|
+
this.#apiHash = params?.apiHash ?? "";
|
|
161
|
+
this.#transportProvider = params?.transportProvider;
|
|
162
|
+
this.#initialDc = params?.initialDc ?? INITIAL_DC;
|
|
163
|
+
this.#storage_ = params?.storage || new StorageMemory();
|
|
164
|
+
this.#persistCache = params?.persistCache ?? false;
|
|
165
|
+
if (!this.#persistCache) {
|
|
166
|
+
this.#messageStorage_ = new StorageMemory();
|
|
306
167
|
}
|
|
307
168
|
else {
|
|
308
|
-
|
|
169
|
+
this.#messageStorage_ = this.#storage_;
|
|
309
170
|
}
|
|
310
|
-
this.storage = new StorageOperations(
|
|
311
|
-
this.messageStorage = new StorageOperations(
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
171
|
+
this.storage = new StorageOperations(this.#storage_);
|
|
172
|
+
this.messageStorage = new StorageOperations(this.#messageStorage_);
|
|
173
|
+
this.#parseMode = params?.parseMode ?? null;
|
|
174
|
+
this.#disableUpdates = params?.disableUpdates ?? false;
|
|
175
|
+
this.#authString = params?.authString;
|
|
315
176
|
this.appVersion = params?.appVersion ?? APP_VERSION;
|
|
316
177
|
this.deviceModel = params?.deviceModel ?? DEVICE_MODEL;
|
|
317
178
|
this.language = params?.language ?? LANG_CODE;
|
|
318
179
|
this.platform = params?.platform ?? LANG_PACK;
|
|
319
180
|
this.systemLangCode = params?.systemLangCode ?? SYSTEM_LANG_CODE;
|
|
320
181
|
this.systemVersion = params?.systemVersion ?? SYSTEM_VERSION;
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const L =
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
182
|
+
this.#publicKeys = params?.publicKeys;
|
|
183
|
+
this.#outgoingMessages = params?.outgoingMessages ?? false;
|
|
184
|
+
this.#guaranteeUpdateDelivery = params?.guaranteeUpdateDelivery ?? false;
|
|
185
|
+
const L = this.#L = getLogger("Client").client(id++);
|
|
186
|
+
this.#LsignIn = L.branch("signIn");
|
|
187
|
+
this.#LupdateGapRecoveryLoop = L.branch("updateGapRecoveryLoop");
|
|
188
|
+
this.#LstorageWriteLoop = L.branch("storageWriteLoop");
|
|
189
|
+
this.#LhandleMigrationError = L.branch("[handleMigrationError]");
|
|
190
|
+
this.#Lmin = L.branch("min");
|
|
330
191
|
const c = {
|
|
331
192
|
id,
|
|
332
|
-
getUploadPoolSize:
|
|
193
|
+
getUploadPoolSize: this.#getUploadPoolSize.bind(this),
|
|
333
194
|
invoke: async (function_, params) => {
|
|
334
195
|
if (params?.businessConnectionId) {
|
|
335
196
|
if (Mtproto.is("ping", function_)) {
|
|
@@ -343,49 +204,49 @@ export class Client extends Composer {
|
|
|
343
204
|
},
|
|
344
205
|
storage: this.storage,
|
|
345
206
|
messageStorage: this.messageStorage,
|
|
346
|
-
guaranteeUpdateDelivery:
|
|
347
|
-
setConnectionState:
|
|
348
|
-
resetConnectionState: () =>
|
|
349
|
-
getSelfId:
|
|
350
|
-
getIsPremium:
|
|
207
|
+
guaranteeUpdateDelivery: this.#guaranteeUpdateDelivery,
|
|
208
|
+
setConnectionState: this.#propagateConnectionState.bind(this),
|
|
209
|
+
resetConnectionState: () => this.#stateChangeHandler(this.isConnected),
|
|
210
|
+
getSelfId: this.#getSelfId.bind(this),
|
|
211
|
+
getIsPremium: this.#getIsPremium.bind(this),
|
|
351
212
|
getInputPeer: this.getInputPeer.bind(this),
|
|
352
213
|
getInputChannel: this.getInputChannel.bind(this),
|
|
353
214
|
getInputUser: this.getInputUser.bind(this),
|
|
354
|
-
getInputPeerChatId:
|
|
215
|
+
getInputPeerChatId: this.#getInputPeerChatId.bind(this),
|
|
355
216
|
getPeer: this[mustGetPeer].bind(this),
|
|
356
|
-
handleUpdate:
|
|
357
|
-
parseMode:
|
|
358
|
-
outgoingMessages:
|
|
217
|
+
handleUpdate: this.#queueHandleCtxUpdate.bind(this),
|
|
218
|
+
parseMode: this.#parseMode,
|
|
219
|
+
outgoingMessages: this.#outgoingMessages,
|
|
359
220
|
dropPendingUpdates: params?.dropPendingUpdates,
|
|
360
221
|
isDisconnected: () => this.isDisconnected,
|
|
361
222
|
langPack: this.platform,
|
|
362
223
|
langCode: this.language,
|
|
363
224
|
};
|
|
364
225
|
// 2_
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
const fileManager =
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
226
|
+
this.#accountManager = new AccountManager(c);
|
|
227
|
+
this.#botInfoManager = new BotInfoManager(c);
|
|
228
|
+
this.#businessConnectionManager = new BusinessConnectionManager(c);
|
|
229
|
+
const fileManager = this.#fileManager = new FileManager(c);
|
|
230
|
+
this.#networkStatisticsManager = new NetworkStatisticsManager(c);
|
|
231
|
+
this.#paymentManager = new PaymentManager(c);
|
|
232
|
+
this.#reactionManager = new ReactionManager(c);
|
|
233
|
+
this.#translationsManager = new TranslationsManager(c);
|
|
234
|
+
this.#updateManager = new UpdateManager(c);
|
|
374
235
|
// 3_
|
|
375
|
-
const messageManager =
|
|
376
|
-
|
|
236
|
+
const messageManager = this.#messageManager = new MessageManager({ ...c, fileManager });
|
|
237
|
+
this.#videoChatManager = new VideoChatManager({ ...c, fileManager });
|
|
377
238
|
// 4_
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
239
|
+
this.#callbackQueryManager = new CallbackQueryManager({ ...c, messageManager });
|
|
240
|
+
this.#chatListManager = new ChatListManager({ ...c, fileManager, messageManager });
|
|
241
|
+
this.#chatManager = new ChatManager({ ...c, fileManager, messageManager });
|
|
242
|
+
this.#checklistManager = new ChecklistManager({ ...c, messageManager });
|
|
243
|
+
this.#forumManager = new ForumManager({ ...c, messageManager });
|
|
244
|
+
this.#giftManager = new GiftManager({ ...c, messageManager });
|
|
245
|
+
this.#inlineQueryManager = new InlineQueryManager({ ...c, messageManager });
|
|
246
|
+
this.#linkPreviewManager = new LinkPreviewManager({ ...c, messageManager });
|
|
247
|
+
this.#pollManager = new PollManager({ ...c, messageManager });
|
|
248
|
+
this.#storyManager = new StoryManager({ ...c, fileManager, messageManager });
|
|
249
|
+
this.#updateManager.setUpdateHandler(this.#handleUpdate.bind(this));
|
|
389
250
|
if (params?.defaultHandlers ?? true) {
|
|
390
251
|
this.invoke.use(async ({ error }, next) => {
|
|
391
252
|
if (error instanceof FloodWait && error.seconds <= 10) {
|
|
@@ -399,59 +260,127 @@ export class Client extends Composer {
|
|
|
399
260
|
});
|
|
400
261
|
}
|
|
401
262
|
}
|
|
263
|
+
#setMainClient(client) {
|
|
264
|
+
this.#disconnectAllClients();
|
|
265
|
+
this.#clients = [client];
|
|
266
|
+
client.handlers.onUpdate = (updates) => {
|
|
267
|
+
this.#updateManager.processUpdates(updates, true, null);
|
|
268
|
+
this.#lastUpdates = new Date();
|
|
269
|
+
};
|
|
270
|
+
client.handlers.onDeserializationError = async () => {
|
|
271
|
+
await this.#updateManager.recoverUpdateGap("deserialization error");
|
|
272
|
+
};
|
|
273
|
+
client.handlers.onNewServerSalt = async (serverSalt) => {
|
|
274
|
+
await this.storage.setServerSalt(serverSalt);
|
|
275
|
+
};
|
|
276
|
+
client.onConnectionStateChange = this.#onConnectionStateChange.bind(this);
|
|
277
|
+
}
|
|
278
|
+
#newClient(dc, main, isCdn) {
|
|
279
|
+
const client = new ClientEncrypted(dc, this.#apiId, {
|
|
280
|
+
appVersion: this.appVersion,
|
|
281
|
+
deviceModel: this.deviceModel,
|
|
282
|
+
langCode: this.language,
|
|
283
|
+
langPack: this.platform,
|
|
284
|
+
systemLangCode: this.systemLangCode,
|
|
285
|
+
systemVersion: this.systemVersion,
|
|
286
|
+
transportProvider: this.#transportProvider,
|
|
287
|
+
isCdn: isCdn,
|
|
288
|
+
disableUpdates: !main || isCdn,
|
|
289
|
+
publicKeys: this.#publicKeys,
|
|
290
|
+
});
|
|
291
|
+
client.connectionCallback = this.#networkStatisticsManager.getTransportReadWriteCallback(isCdn);
|
|
292
|
+
return client;
|
|
293
|
+
}
|
|
294
|
+
#disconnectAllClients() {
|
|
295
|
+
for (const client of this.#clients) {
|
|
296
|
+
client.disconnect();
|
|
297
|
+
}
|
|
298
|
+
for (const pool of Object.values(this.#downloadPools)) {
|
|
299
|
+
pool.disconnect();
|
|
300
|
+
}
|
|
301
|
+
for (const pool of Object.values(this.#uploadPools)) {
|
|
302
|
+
pool.disconnect();
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
get #client() {
|
|
306
|
+
return this.#clients[0];
|
|
307
|
+
}
|
|
402
308
|
// direct ClientEncrypted property proxies
|
|
403
309
|
get isConnected() {
|
|
404
|
-
return
|
|
310
|
+
return this.#client?.isConnected ?? false;
|
|
405
311
|
}
|
|
406
312
|
get isDisconnected() {
|
|
407
|
-
return
|
|
313
|
+
return this.#client?.isDisconnected ?? true;
|
|
314
|
+
}
|
|
315
|
+
#propagateConnectionState(connectionState) {
|
|
316
|
+
this.#queueHandleCtxUpdate({ connectionState });
|
|
317
|
+
this.#lastPropagatedConnectionState = connectionState;
|
|
318
|
+
}
|
|
319
|
+
#lastPropagatedConnectionState = null;
|
|
320
|
+
#stateChangeHandler = ((isConnected) => {
|
|
321
|
+
const connectionState = isConnected ? "ready" : "notConnected";
|
|
322
|
+
if (this.#lastPropagatedConnectionState !== connectionState) {
|
|
323
|
+
this.#propagateConnectionState(connectionState);
|
|
324
|
+
}
|
|
325
|
+
}).bind(this);
|
|
326
|
+
#storageInited = false;
|
|
327
|
+
async #initStorage() {
|
|
328
|
+
if (!this.#storageInited) {
|
|
329
|
+
await this.storage.initialize();
|
|
330
|
+
if (!this.#guaranteeUpdateDelivery) {
|
|
331
|
+
await this.storage.deleteUpdates();
|
|
332
|
+
await this.storage.commit(true);
|
|
333
|
+
}
|
|
334
|
+
this.#storageInited = true;
|
|
335
|
+
}
|
|
408
336
|
}
|
|
337
|
+
#connectMutex = new Mutex();
|
|
409
338
|
/**
|
|
410
339
|
* Loads the session if `setDc` was not called, initializes and connnects
|
|
411
340
|
* a `ClientPlain` to generate auth key if there was none, and connects the client.
|
|
412
341
|
* Before establishing the connection, the session is saved.
|
|
413
342
|
*/
|
|
414
343
|
async connect() {
|
|
415
|
-
const unlock = await
|
|
344
|
+
const unlock = await this.#connectMutex.lock();
|
|
416
345
|
try {
|
|
417
346
|
if (this.isConnected) {
|
|
418
347
|
return;
|
|
419
348
|
}
|
|
420
|
-
await
|
|
421
|
-
if (
|
|
422
|
-
await this.importAuthString(
|
|
349
|
+
await this.#initStorage();
|
|
350
|
+
if (this.#authString && !this.#authStringImported) {
|
|
351
|
+
await this.importAuthString(this.#authString);
|
|
423
352
|
}
|
|
424
353
|
const auth = this.storage.auth.mustGet();
|
|
425
354
|
if (auth.authKey !== null && auth.dc !== null) {
|
|
426
|
-
if (!
|
|
427
|
-
|
|
428
|
-
|
|
355
|
+
if (!this.#client || this.#client.dc !== auth.dc) {
|
|
356
|
+
this.#client?.disconnect();
|
|
357
|
+
this.#setMainClient(this.#newClient(auth.dc, true, false));
|
|
429
358
|
}
|
|
430
|
-
await
|
|
431
|
-
if (
|
|
432
|
-
|
|
359
|
+
await this.#client.setAuthKey(auth.authKey);
|
|
360
|
+
if (this.#client.serverSalt === 0n) {
|
|
361
|
+
this.#client.serverSalt = await this.storage.getServerSalt() ?? 0n;
|
|
433
362
|
}
|
|
434
363
|
}
|
|
435
364
|
else {
|
|
436
|
-
const dc = auth.dc ??
|
|
437
|
-
if (!
|
|
438
|
-
|
|
439
|
-
|
|
365
|
+
const dc = auth.dc ?? this.#initialDc;
|
|
366
|
+
if (!this.#client || this.#client.dc !== dc) {
|
|
367
|
+
this.#client?.disconnect();
|
|
368
|
+
this.#setMainClient(this.#newClient(dc, true, false));
|
|
440
369
|
}
|
|
441
370
|
}
|
|
442
|
-
await
|
|
371
|
+
await this.#client.connect();
|
|
443
372
|
await this.storage.auth.update((v) => {
|
|
444
|
-
v.authKey =
|
|
445
|
-
v.dc =
|
|
373
|
+
v.authKey = this.#client.authKey;
|
|
374
|
+
v.dc = this.#client.dc;
|
|
446
375
|
});
|
|
447
|
-
await this.storage.setServerSalt(
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
if (!
|
|
451
|
-
|
|
376
|
+
await this.storage.setServerSalt(this.#client.serverSalt);
|
|
377
|
+
this.#updateGapRecoveryLoop.start();
|
|
378
|
+
this.#clientDisconnectionLoop.start();
|
|
379
|
+
if (!this.#messageStorage_.isMemory) {
|
|
380
|
+
this.#storageWriteLoop.start();
|
|
452
381
|
}
|
|
453
382
|
else {
|
|
454
|
-
|
|
383
|
+
this.#L.debug("not starting storageWriteLoop");
|
|
455
384
|
}
|
|
456
385
|
await this.storage.commit(true);
|
|
457
386
|
}
|
|
@@ -459,62 +388,9 @@ export class Client extends Composer {
|
|
|
459
388
|
unlock();
|
|
460
389
|
}
|
|
461
390
|
}
|
|
462
|
-
async [(
|
|
463
|
-
__classPrivateFieldGet(this, _Client_instances, "m", _Client_disconnectAllClients).call(this);
|
|
464
|
-
__classPrivateFieldSet(this, _Client_clients, [client], "f");
|
|
465
|
-
client.handlers.onUpdate = (updates) => {
|
|
466
|
-
__classPrivateFieldGet(this, _Client_updateManager, "f").processUpdates(updates, true, null);
|
|
467
|
-
__classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
|
|
468
|
-
};
|
|
469
|
-
client.handlers.onDeserializationError = async () => {
|
|
470
|
-
await __classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("deserialization error");
|
|
471
|
-
};
|
|
472
|
-
client.handlers.onNewServerSalt = async (serverSalt) => {
|
|
473
|
-
await this.storage.setServerSalt(serverSalt);
|
|
474
|
-
};
|
|
475
|
-
client.onConnectionStateChange = __classPrivateFieldGet(this, _Client_instances, "m", _Client_onConnectionStateChange).bind(this);
|
|
476
|
-
}, _Client_newClient = function _Client_newClient(dc, main, isCdn) {
|
|
477
|
-
const client = new ClientEncrypted(dc, __classPrivateFieldGet(this, _Client_apiId, "f"), {
|
|
478
|
-
appVersion: this.appVersion,
|
|
479
|
-
deviceModel: this.deviceModel,
|
|
480
|
-
langCode: this.language,
|
|
481
|
-
langPack: this.platform,
|
|
482
|
-
systemLangCode: this.systemLangCode,
|
|
483
|
-
systemVersion: this.systemVersion,
|
|
484
|
-
transportProvider: __classPrivateFieldGet(this, _Client_transportProvider, "f"),
|
|
485
|
-
isCdn: isCdn,
|
|
486
|
-
disableUpdates: !main || isCdn,
|
|
487
|
-
publicKeys: __classPrivateFieldGet(this, _Client_publicKeys, "f"),
|
|
488
|
-
});
|
|
489
|
-
client.connectionCallback = __classPrivateFieldGet(this, _Client_networkStatisticsManager, "f").getTransportReadWriteCallback(isCdn);
|
|
490
|
-
return client;
|
|
491
|
-
}, _Client_disconnectAllClients = function _Client_disconnectAllClients() {
|
|
492
|
-
for (const client of __classPrivateFieldGet(this, _Client_clients, "f")) {
|
|
493
|
-
client.disconnect();
|
|
494
|
-
}
|
|
495
|
-
for (const pool of Object.values(__classPrivateFieldGet(this, _Client_downloadPools, "f"))) {
|
|
496
|
-
pool.disconnect();
|
|
497
|
-
}
|
|
498
|
-
for (const pool of Object.values(__classPrivateFieldGet(this, _Client_uploadPools, "f"))) {
|
|
499
|
-
pool.disconnect();
|
|
500
|
-
}
|
|
501
|
-
}, _Client_client_get = function _Client_client_get() {
|
|
502
|
-
return __classPrivateFieldGet(this, _Client_clients, "f")[0];
|
|
503
|
-
}, _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
|
|
504
|
-
__classPrivateFieldGet(this, _Client_instances, "m", _Client_queueHandleCtxUpdate).call(this, { connectionState });
|
|
505
|
-
__classPrivateFieldSet(this, _Client_lastPropagatedConnectionState, connectionState, "f");
|
|
506
|
-
}, _Client_initStorage = async function _Client_initStorage() {
|
|
507
|
-
if (!__classPrivateFieldGet(this, _Client_storageInited, "f")) {
|
|
508
|
-
await this.storage.initialize();
|
|
509
|
-
if (!__classPrivateFieldGet(this, _Client_guaranteeUpdateDelivery, "f")) {
|
|
510
|
-
await this.storage.deleteUpdates();
|
|
511
|
-
await this.storage.commit(true);
|
|
512
|
-
}
|
|
513
|
-
__classPrivateFieldSet(this, _Client_storageInited, true, "f");
|
|
514
|
-
}
|
|
515
|
-
}, handleMigrationError)](err) {
|
|
391
|
+
async [handleMigrationError](err) {
|
|
516
392
|
let newDc = String(err.dc);
|
|
517
|
-
if (Math.abs(getDcId(
|
|
393
|
+
if (Math.abs(getDcId(this.#client.dc, this.#client.isCdn)) >= 10_000) {
|
|
518
394
|
newDc += "-test";
|
|
519
395
|
}
|
|
520
396
|
this.disconnect();
|
|
@@ -523,17 +399,100 @@ export class Client extends Composer {
|
|
|
523
399
|
v.dc = newDc;
|
|
524
400
|
});
|
|
525
401
|
await this.connect();
|
|
526
|
-
|
|
402
|
+
this.#LhandleMigrationError.debug(`migrated to DC${newDc}`);
|
|
527
403
|
}
|
|
528
404
|
async disconnect() {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
405
|
+
this.#disconnectAllClients();
|
|
406
|
+
this.#clientDisconnectionLoop.abort();
|
|
407
|
+
this.#updateGapRecoveryLoop.abort();
|
|
408
|
+
this.#storageWriteLoop.abort();
|
|
409
|
+
this.#updateManager.closeAllChats();
|
|
534
410
|
await this.storage.commit(true);
|
|
535
411
|
await this.messageStorage.commit(true);
|
|
536
412
|
}
|
|
413
|
+
#lastPropagatedAuthorizationState = null;
|
|
414
|
+
async #propagateAuthorizationState(authorized) {
|
|
415
|
+
if (this.#lastPropagatedAuthorizationState !== authorized) {
|
|
416
|
+
await this.#handleCtxUpdate({ authorizationState: { isAuthorized: authorized } });
|
|
417
|
+
this.#lastPropagatedAuthorizationState = authorized;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
async #getSelfId() {
|
|
421
|
+
const id = await this.storage.getAccountId();
|
|
422
|
+
if (id === null) {
|
|
423
|
+
throw new Error("Unauthorized");
|
|
424
|
+
}
|
|
425
|
+
return id;
|
|
426
|
+
}
|
|
427
|
+
async #getIsPremium() {
|
|
428
|
+
const maybeIsPremium = await this.storage.getIsPremium();
|
|
429
|
+
if (maybeIsPremium !== null) {
|
|
430
|
+
return maybeIsPremium;
|
|
431
|
+
}
|
|
432
|
+
return this.#lastGetMe?.isPremium ?? false;
|
|
433
|
+
}
|
|
434
|
+
#lastUpdates = new Date();
|
|
435
|
+
#updateGapRecoveryLoop = new AbortableLoop(async (loop, signal) => {
|
|
436
|
+
await delay(60 * SECOND, { signal });
|
|
437
|
+
if (!this.isConnected) {
|
|
438
|
+
loop.abort();
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
if (Date.now() - this.#lastUpdates.getTime() >= 15 * MINUTE) {
|
|
442
|
+
drop(this.#updateManager.recoverUpdateGap("lastUpdates").then(() => {
|
|
443
|
+
this.#lastUpdates = new Date();
|
|
444
|
+
}));
|
|
445
|
+
}
|
|
446
|
+
}, (loop, err) => {
|
|
447
|
+
if (!this.isConnected) {
|
|
448
|
+
loop.abort();
|
|
449
|
+
}
|
|
450
|
+
else {
|
|
451
|
+
this.#LupdateGapRecoveryLoop.error(err);
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
#clientDisconnectionLoop = new AbortableLoop(async (loop, signal) => {
|
|
455
|
+
await delay(60 * SECOND, { signal });
|
|
456
|
+
if (!this.isConnected) {
|
|
457
|
+
loop.abort();
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
const now = Date.now();
|
|
461
|
+
const disconnectAfter = 5 * MINUTE;
|
|
462
|
+
for (const [i, client] of this.#clients.entries()) {
|
|
463
|
+
if (i > 0 && !client.isDisconnected && client.lastRequest && now - client.lastRequest.getTime() >= disconnectAfter) {
|
|
464
|
+
client?.disconnect();
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}, (loop) => {
|
|
468
|
+
if (!this.isConnected) {
|
|
469
|
+
loop.abort();
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
#storageWriteLoop = new AbortableLoop(async (_loop, signal) => {
|
|
473
|
+
await delay(5 * SECOND, { signal });
|
|
474
|
+
await this.messageStorage.commit();
|
|
475
|
+
await this.storage.commit();
|
|
476
|
+
}, (err) => {
|
|
477
|
+
this.#LstorageWriteLoop.error(err);
|
|
478
|
+
});
|
|
479
|
+
async #checkAuthorization() {
|
|
480
|
+
if (this.#lastGetMe) {
|
|
481
|
+
return this.#lastGetMe;
|
|
482
|
+
}
|
|
483
|
+
try {
|
|
484
|
+
await this.#updateManager.fetchState("#checkAuthorization");
|
|
485
|
+
const me = await this.#getMe();
|
|
486
|
+
await this.#propagateAuthorizationState(true);
|
|
487
|
+
drop(this.#updateManager.recoverUpdateGap("#checkAuthorization"));
|
|
488
|
+
return me;
|
|
489
|
+
}
|
|
490
|
+
catch (err) {
|
|
491
|
+
if (!(err instanceof AuthKeyUnregistered) && !(err instanceof SessionRevoked)) {
|
|
492
|
+
throw err;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
537
496
|
/**
|
|
538
497
|
* Send a user verification code.
|
|
539
498
|
*
|
|
@@ -541,17 +500,17 @@ export class Client extends Composer {
|
|
|
541
500
|
* @method ac
|
|
542
501
|
*/
|
|
543
502
|
async sendCode(phoneNumber) {
|
|
544
|
-
const me = await
|
|
503
|
+
const me = await this.#checkAuthorization();
|
|
545
504
|
if (me) {
|
|
546
505
|
return;
|
|
547
506
|
}
|
|
548
507
|
try {
|
|
549
|
-
await
|
|
508
|
+
await this.#accountManager.sendCode(phoneNumber, this.#apiId, this.#apiHash);
|
|
550
509
|
}
|
|
551
510
|
catch (err) {
|
|
552
511
|
if (err instanceof Migrate) {
|
|
553
512
|
await this[handleMigrationError](err);
|
|
554
|
-
await
|
|
513
|
+
await this.#accountManager.sendCode(phoneNumber, this.#apiId, this.#apiHash);
|
|
555
514
|
}
|
|
556
515
|
else {
|
|
557
516
|
throw err;
|
|
@@ -565,15 +524,15 @@ export class Client extends Composer {
|
|
|
565
524
|
* @method ac
|
|
566
525
|
*/
|
|
567
526
|
async checkCode(code) {
|
|
568
|
-
const result = await
|
|
527
|
+
const result = await this.#accountManager.checkCode(code);
|
|
569
528
|
if (result.type === "signedIn") {
|
|
570
529
|
await this.storage.auth.update((v) => {
|
|
571
530
|
v.userId = result.userId;
|
|
572
531
|
v.isBot = false;
|
|
573
532
|
});
|
|
574
|
-
|
|
575
|
-
await
|
|
576
|
-
await
|
|
533
|
+
this.#LsignIn.debug("signed in as user");
|
|
534
|
+
await this.#propagateAuthorizationState(true);
|
|
535
|
+
await this.#updateManager.fetchState("checkCode");
|
|
577
536
|
}
|
|
578
537
|
return result;
|
|
579
538
|
}
|
|
@@ -583,7 +542,7 @@ export class Client extends Composer {
|
|
|
583
542
|
* @method ac
|
|
584
543
|
*/
|
|
585
544
|
async getPasswordHint() {
|
|
586
|
-
return await
|
|
545
|
+
return await this.#accountManager.getPasswordHint();
|
|
587
546
|
}
|
|
588
547
|
/**
|
|
589
548
|
* Check whether a password entered by the user is the same as the account's one.
|
|
@@ -593,16 +552,16 @@ export class Client extends Composer {
|
|
|
593
552
|
* @method ac
|
|
594
553
|
*/
|
|
595
554
|
async checkPassword(password) {
|
|
596
|
-
const result = await
|
|
555
|
+
const result = await this.#accountManager.checkPassword(password);
|
|
597
556
|
if (result.type === "signedIn") {
|
|
598
557
|
await this.storage.auth.update((v) => {
|
|
599
558
|
v.userId = result.userId;
|
|
600
559
|
v.isBot = false;
|
|
601
560
|
});
|
|
602
561
|
await this.storage.commit(true);
|
|
603
|
-
|
|
604
|
-
await
|
|
605
|
-
await
|
|
562
|
+
this.#LsignIn.debug("signed in as user");
|
|
563
|
+
await this.#propagateAuthorizationState(true);
|
|
564
|
+
await this.#updateManager.fetchState("checkPassword");
|
|
606
565
|
}
|
|
607
566
|
return result;
|
|
608
567
|
}
|
|
@@ -614,7 +573,7 @@ export class Client extends Composer {
|
|
|
614
573
|
* @method ac
|
|
615
574
|
*/
|
|
616
575
|
async checkBotToken(botToken) {
|
|
617
|
-
const me = await
|
|
576
|
+
const me = await this.#checkAuthorization();
|
|
618
577
|
if (me) {
|
|
619
578
|
return {
|
|
620
579
|
type: "signedIn",
|
|
@@ -623,16 +582,16 @@ export class Client extends Composer {
|
|
|
623
582
|
}
|
|
624
583
|
while (true) {
|
|
625
584
|
try {
|
|
626
|
-
const result = await
|
|
585
|
+
const result = await this.#accountManager.checkBotToken(botToken, this.#apiId, this.#apiHash);
|
|
627
586
|
if (result.type === "signedIn") {
|
|
628
587
|
await this.storage.auth.update((v) => {
|
|
629
588
|
v.userId = result.userId;
|
|
630
589
|
v.isBot = true;
|
|
631
590
|
});
|
|
632
591
|
await this.storage.commit(true);
|
|
633
|
-
|
|
634
|
-
await
|
|
635
|
-
await
|
|
592
|
+
this.#LsignIn.debug("signed in as bot");
|
|
593
|
+
await this.#propagateAuthorizationState(true);
|
|
594
|
+
await this.#updateManager.fetchState("checkBotToken");
|
|
636
595
|
}
|
|
637
596
|
return result;
|
|
638
597
|
}
|
|
@@ -656,19 +615,19 @@ export class Client extends Composer {
|
|
|
656
615
|
* 3. Reconnects the client to the appropriate DC in case of MIGRATE_X errors.
|
|
657
616
|
*/
|
|
658
617
|
async signIn(params) {
|
|
659
|
-
await signIn(this,
|
|
618
|
+
await signIn(this, this.#LsignIn, params);
|
|
660
619
|
}
|
|
661
620
|
async signOut() {
|
|
662
621
|
try {
|
|
663
622
|
await Promise.all([
|
|
664
623
|
this.storage.reset(),
|
|
665
624
|
this.invoke({ _: "auth.logOut" }).then(() => {
|
|
666
|
-
|
|
625
|
+
this.#propagateAuthorizationState(false);
|
|
667
626
|
}),
|
|
668
627
|
]);
|
|
669
628
|
}
|
|
670
629
|
finally {
|
|
671
|
-
|
|
630
|
+
this.#lastGetMe = null;
|
|
672
631
|
this.disconnect();
|
|
673
632
|
await this.connect();
|
|
674
633
|
}
|
|
@@ -680,146 +639,55 @@ export class Client extends Composer {
|
|
|
680
639
|
await this.connect();
|
|
681
640
|
await this.signIn(params);
|
|
682
641
|
}
|
|
683
|
-
|
|
684
|
-
return this.storage.exportAuthString(__classPrivateFieldGet(this, _Client_apiId, "f"));
|
|
685
|
-
}
|
|
686
|
-
async importAuthString(authString) {
|
|
687
|
-
if (this.isConnected) {
|
|
688
|
-
throw new Error("Cannot import auth string while the client is connected");
|
|
689
|
-
}
|
|
690
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initStorage).call(this);
|
|
691
|
-
await this.storage.importAuthString(authString);
|
|
692
|
-
__classPrivateFieldSet(this, _Client_authStringImported, true, "f");
|
|
693
|
-
if (!__classPrivateFieldGet(this, _Client_apiId, "f")) {
|
|
694
|
-
__classPrivateFieldSet(this, _Client_apiId, this.storage.auth.mustGet().apiId, "f");
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
/**
|
|
698
|
-
* Get a chat's inputPeer. Useful when calling API functions directly.
|
|
699
|
-
*
|
|
700
|
-
* @param id The identifier of a chat.
|
|
701
|
-
*/
|
|
702
|
-
async getInputPeer(id) {
|
|
703
|
-
if (id === "me" || id === await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).call(this)) {
|
|
704
|
-
return { _: "inputPeerSelf" };
|
|
705
|
-
}
|
|
706
|
-
const inputPeer = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getInputPeerInner).call(this, id);
|
|
707
|
-
if (((Api.is("inputPeerUser", inputPeer) || Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash === 0n) && this.storage.isBot) {
|
|
708
|
-
if ("channel_id" in inputPeer) {
|
|
709
|
-
inputPeer.access_hash = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChannelAccessHash).call(this, inputPeer.channel_id);
|
|
710
|
-
}
|
|
711
|
-
else {
|
|
712
|
-
inputPeer.access_hash = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getUserAccessHash).call(this, inputPeer.user_id);
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
if ((Api.is("inputPeerUser", inputPeer) || Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash === 0n) {
|
|
716
|
-
throw new AccessError(`The chat ${id} cannot be accessed.`);
|
|
717
|
-
}
|
|
718
|
-
return inputPeer;
|
|
719
|
-
}
|
|
720
|
-
/**
|
|
721
|
-
* Get a channel or a supergroup's inputChannel. Useful when calling API functions directly.
|
|
722
|
-
*
|
|
723
|
-
* @param id The identifier of the channel or the supergroup.
|
|
724
|
-
*/
|
|
725
|
-
async getInputChannel(id) {
|
|
726
|
-
const inputPeer = await this.getInputPeer(id);
|
|
727
|
-
if (!canBeInputChannel(inputPeer)) {
|
|
728
|
-
throw new TypeError(`The chat ${id} is not a channel neither a supergroup.`);
|
|
729
|
-
}
|
|
730
|
-
return toInputChannel(inputPeer);
|
|
731
|
-
}
|
|
732
|
-
/**
|
|
733
|
-
* Get a user's inputUser. Useful when calling API functions directly.
|
|
734
|
-
*
|
|
735
|
-
* @param id The identifier of the user.
|
|
736
|
-
*/
|
|
737
|
-
async getInputUser(id) {
|
|
738
|
-
const inputPeer = await this.getInputPeer(id);
|
|
739
|
-
if (!canBeInputUser(inputPeer)) {
|
|
740
|
-
throw new TypeError(`The chat ${id} is not a private chat.`);
|
|
741
|
-
}
|
|
742
|
-
return toInputUser(inputPeer);
|
|
743
|
-
}
|
|
744
|
-
async [(_Client_propagateAuthorizationState = async function _Client_propagateAuthorizationState(authorized) {
|
|
745
|
-
if (__classPrivateFieldGet(this, _Client_lastPropagatedAuthorizationState, "f") !== authorized) {
|
|
746
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, { authorizationState: { isAuthorized: authorized } });
|
|
747
|
-
__classPrivateFieldSet(this, _Client_lastPropagatedAuthorizationState, authorized, "f");
|
|
748
|
-
}
|
|
749
|
-
}, _Client_getSelfId = async function _Client_getSelfId() {
|
|
750
|
-
const id = await this.storage.getAccountId();
|
|
751
|
-
if (id === null) {
|
|
752
|
-
throw new Error("Unauthorized");
|
|
753
|
-
}
|
|
754
|
-
return id;
|
|
755
|
-
}, _Client_getIsPremium = async function _Client_getIsPremium() {
|
|
756
|
-
const maybeIsPremium = await this.storage.getIsPremium();
|
|
757
|
-
if (maybeIsPremium !== null) {
|
|
758
|
-
return maybeIsPremium;
|
|
759
|
-
}
|
|
760
|
-
return __classPrivateFieldGet(this, _Client_lastGetMe, "f")?.isPremium ?? false;
|
|
761
|
-
}, _Client_checkAuthorization = async function _Client_checkAuthorization() {
|
|
762
|
-
if (__classPrivateFieldGet(this, _Client_lastGetMe, "f")) {
|
|
763
|
-
return __classPrivateFieldGet(this, _Client_lastGetMe, "f");
|
|
764
|
-
}
|
|
765
|
-
try {
|
|
766
|
-
await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("#checkAuthorization");
|
|
767
|
-
const me = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMe).call(this);
|
|
768
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
|
|
769
|
-
drop(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("#checkAuthorization"));
|
|
770
|
-
return me;
|
|
771
|
-
}
|
|
772
|
-
catch (err) {
|
|
773
|
-
if (!(err instanceof AuthKeyUnregistered) && !(err instanceof SessionRevoked)) {
|
|
774
|
-
throw err;
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
}, _Client_getClient = async function _Client_getClient(params) {
|
|
642
|
+
async #getClient(params) {
|
|
778
643
|
let client;
|
|
779
644
|
switch (params.type) {
|
|
780
645
|
case undefined:
|
|
781
|
-
client = await
|
|
646
|
+
client = await this.#getMainClient(params.dc);
|
|
782
647
|
break;
|
|
783
648
|
case "download":
|
|
784
|
-
client = await
|
|
649
|
+
client = await this.#getDownloadClient(params.dc);
|
|
785
650
|
break;
|
|
786
651
|
case "upload":
|
|
787
|
-
client = await
|
|
652
|
+
client = await this.#getUploadClient();
|
|
788
653
|
break;
|
|
789
654
|
}
|
|
790
|
-
if (client !==
|
|
655
|
+
if (client !== this.#client && !this.isDisconnected && client.isDisconnected) {
|
|
791
656
|
await client.connect();
|
|
792
657
|
}
|
|
793
658
|
return client;
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
|
|
659
|
+
}
|
|
660
|
+
#getMainClientMutex = new Mutex();
|
|
661
|
+
async #getMainClient(dc) {
|
|
662
|
+
if (dc === undefined || dc === this.#client?.dc) {
|
|
663
|
+
return this.#client;
|
|
797
664
|
}
|
|
798
|
-
let client =
|
|
665
|
+
let client = this.#clients.find((v) => v.dc === dc);
|
|
799
666
|
if (client) {
|
|
800
667
|
return client;
|
|
801
668
|
}
|
|
802
|
-
const unlock = await
|
|
803
|
-
client =
|
|
669
|
+
const unlock = await this.#getMainClientMutex.lock();
|
|
670
|
+
client = this.#clients.find((v) => v.dc === dc);
|
|
804
671
|
if (client) {
|
|
805
672
|
return client;
|
|
806
673
|
}
|
|
807
674
|
try {
|
|
808
|
-
client =
|
|
809
|
-
await
|
|
810
|
-
|
|
675
|
+
client = this.#newClient(dc, false, false);
|
|
676
|
+
await this.#setupClient(client);
|
|
677
|
+
this.#clients.push(client);
|
|
811
678
|
return client;
|
|
812
679
|
}
|
|
813
680
|
finally {
|
|
814
681
|
unlock();
|
|
815
682
|
}
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
|
|
683
|
+
}
|
|
684
|
+
async #getDownloadClient(dc) {
|
|
685
|
+
dc ??= this.#client.dc;
|
|
686
|
+
const pool = this.#downloadPools[dc] ??= new ClientEncryptedPool();
|
|
819
687
|
if (!pool.size) {
|
|
820
688
|
if (!pool.size) {
|
|
821
689
|
for (let i = 0; i < DOWNLOAD_POOL_SIZE; ++i) {
|
|
822
|
-
pool.add(
|
|
690
|
+
pool.add(this.#newClient(dc, false, true));
|
|
823
691
|
}
|
|
824
692
|
}
|
|
825
693
|
}
|
|
@@ -827,28 +695,31 @@ export class Client extends Composer {
|
|
|
827
695
|
if (client.authKey.length) {
|
|
828
696
|
return client;
|
|
829
697
|
}
|
|
830
|
-
await
|
|
698
|
+
await this.#setupClient(client);
|
|
831
699
|
return client;
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
const
|
|
700
|
+
}
|
|
701
|
+
async #getUploadPoolSize() {
|
|
702
|
+
const dc = this.#client.dc;
|
|
703
|
+
return (dc !== "2" && dc !== "4") || await this.#getIsPremium() ? 8 : 4;
|
|
704
|
+
}
|
|
705
|
+
async #getUploadClient() {
|
|
706
|
+
const dc = this.#client.dc;
|
|
707
|
+
const poolSize = await this.#getUploadPoolSize();
|
|
708
|
+
const pool = this.#uploadPools[dc] ??= new ClientEncryptedPool();
|
|
839
709
|
if (!pool.size) {
|
|
840
710
|
for (let i = 0; i < poolSize; ++i) {
|
|
841
|
-
pool.add(await
|
|
711
|
+
pool.add(await this.#newClient(dc, false, true));
|
|
842
712
|
}
|
|
843
713
|
}
|
|
844
714
|
const client = pool.nextClient();
|
|
845
715
|
if (client.authKey.length) {
|
|
846
716
|
return client;
|
|
847
717
|
}
|
|
848
|
-
await
|
|
718
|
+
await this.#setupClient(client);
|
|
849
719
|
return client;
|
|
850
|
-
}
|
|
851
|
-
|
|
720
|
+
}
|
|
721
|
+
async #setupClient(client) {
|
|
722
|
+
const storage = client.dc === this.#client.dc ? this.storage : new StorageOperations(this.storage.provider.branch(client.dc + (client.isCdn ? "_cdn" : "")));
|
|
852
723
|
await storage.initialize();
|
|
853
724
|
const auth = storage.auth.mustGet();
|
|
854
725
|
const serverSalt = await storage.getServerSalt();
|
|
@@ -860,17 +731,18 @@ export class Client extends Composer {
|
|
|
860
731
|
}
|
|
861
732
|
await client.connect();
|
|
862
733
|
if (auth.authKey === null) {
|
|
863
|
-
await
|
|
734
|
+
await this.#importAuthorization(client);
|
|
864
735
|
}
|
|
865
736
|
await storage.auth.update((v) => v.authKey = client.authKey);
|
|
866
|
-
if (client.dc !==
|
|
737
|
+
if (client.dc !== this.#client.dc) {
|
|
867
738
|
await storage.setServerSalt(client.serverSalt);
|
|
868
739
|
client.handlers.onNewServerSalt = async (serverSalt) => {
|
|
869
740
|
await storage.setServerSalt(serverSalt);
|
|
870
741
|
};
|
|
871
742
|
}
|
|
872
|
-
}
|
|
873
|
-
|
|
743
|
+
}
|
|
744
|
+
async #importAuthorization(client) {
|
|
745
|
+
if (this.#client.dc === client.dc && this.#client.isCdn === client.isCdn) {
|
|
874
746
|
const auth = this.storage.auth.mustGet();
|
|
875
747
|
const serverSalt = await this.storage.getServerSalt();
|
|
876
748
|
if (auth.authKey !== null) {
|
|
@@ -881,29 +753,30 @@ export class Client extends Composer {
|
|
|
881
753
|
}
|
|
882
754
|
return;
|
|
883
755
|
}
|
|
884
|
-
const exportedAuthorization = await
|
|
756
|
+
const exportedAuthorization = await this.#client.invoke({ _: "auth.exportAuthorization", dc_id: getDcId(client.dc, client.isCdn) });
|
|
885
757
|
await client.invoke({ ...exportedAuthorization, _: "auth.importAuthorization" });
|
|
886
|
-
}
|
|
887
|
-
|
|
758
|
+
}
|
|
759
|
+
async #invoke(function_, params) {
|
|
760
|
+
if (!this.#client) {
|
|
888
761
|
throw new ConnectionError("The connection is not open.");
|
|
889
762
|
}
|
|
890
763
|
let n = 1;
|
|
891
764
|
let client;
|
|
892
765
|
while (true) {
|
|
893
|
-
client = params ? await
|
|
894
|
-
const main = client ===
|
|
766
|
+
client = params ? await this.#getClient(params) : this.#client;
|
|
767
|
+
const main = client === this.#client;
|
|
895
768
|
try {
|
|
896
769
|
const result = await client.invoke(function_);
|
|
897
770
|
if (main) {
|
|
898
771
|
try {
|
|
899
|
-
await
|
|
772
|
+
await this.#updateManager.processResult(result);
|
|
900
773
|
}
|
|
901
774
|
catch (err) {
|
|
902
|
-
|
|
775
|
+
this.#L.error("failed to process result:", err);
|
|
903
776
|
}
|
|
904
777
|
if (Api.isOfEnum("Update", result) || Api.isOfEnum("Updates", result)) {
|
|
905
778
|
return new Promise((resolve) => {
|
|
906
|
-
|
|
779
|
+
this.#updateManager.processUpdates(result, true, Mtproto.is("ping", function_) ? null : function_, () => resolve(result));
|
|
907
780
|
});
|
|
908
781
|
}
|
|
909
782
|
}
|
|
@@ -911,13 +784,13 @@ export class Client extends Composer {
|
|
|
911
784
|
}
|
|
912
785
|
catch (err) {
|
|
913
786
|
if (err instanceof AuthKeyUnregistered && !main) {
|
|
914
|
-
await
|
|
787
|
+
await this.#importAuthorization(client);
|
|
915
788
|
continue;
|
|
916
789
|
}
|
|
917
790
|
else if (err instanceof ConnectionError && !main && !this.isDisconnected) {
|
|
918
791
|
continue;
|
|
919
792
|
}
|
|
920
|
-
else if (await
|
|
793
|
+
else if (await this.#handleInvokeError(Object.freeze({ client: this, error: err, function: function_, n: n++ }), () => Promise.resolve(false))) {
|
|
921
794
|
continue;
|
|
922
795
|
}
|
|
923
796
|
else {
|
|
@@ -925,17 +798,79 @@ export class Client extends Composer {
|
|
|
925
798
|
}
|
|
926
799
|
}
|
|
927
800
|
}
|
|
928
|
-
}
|
|
801
|
+
}
|
|
802
|
+
#handleInvokeError = skipInvoke();
|
|
803
|
+
/**
|
|
804
|
+
* Invokes a function waiting and returning its reply.
|
|
805
|
+
* Requires the client to be connected.
|
|
806
|
+
*
|
|
807
|
+
* @param function_ The function to invoke.
|
|
808
|
+
*/
|
|
809
|
+
invoke = Object.assign(this.#invoke, {
|
|
810
|
+
use: (handler) => {
|
|
811
|
+
const handle = this.#handleInvokeError;
|
|
812
|
+
this.#handleInvokeError = async (ctx, next) => {
|
|
813
|
+
let result = null;
|
|
814
|
+
return await handle(ctx, async () => {
|
|
815
|
+
if (result !== null)
|
|
816
|
+
return result;
|
|
817
|
+
result = await handler(ctx, next);
|
|
818
|
+
return result;
|
|
819
|
+
});
|
|
820
|
+
};
|
|
821
|
+
},
|
|
822
|
+
});
|
|
823
|
+
exportAuthString() {
|
|
824
|
+
return this.storage.exportAuthString(this.#apiId);
|
|
825
|
+
}
|
|
826
|
+
#authStringImported = false;
|
|
827
|
+
async importAuthString(authString) {
|
|
828
|
+
if (this.isConnected) {
|
|
829
|
+
throw new Error("Cannot import auth string while the client is connected");
|
|
830
|
+
}
|
|
831
|
+
await this.#initStorage();
|
|
832
|
+
await this.storage.importAuthString(authString);
|
|
833
|
+
this.#authStringImported = true;
|
|
834
|
+
if (!this.#apiId) {
|
|
835
|
+
this.#apiId = this.storage.auth.mustGet().apiId;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
async #getUserAccessHash(userId) {
|
|
929
839
|
const users = await this.invoke({ _: "users.getUsers", id: [{ _: "inputUser", user_id: userId, access_hash: 0n }] });
|
|
930
840
|
const user = Api.is("user", users[0]) ? users[0] : undefined;
|
|
931
841
|
return user?.access_hash ?? 0n;
|
|
932
|
-
}
|
|
842
|
+
}
|
|
843
|
+
async #getChannelAccessHash(channelId) {
|
|
933
844
|
const channels = await this.invoke({ _: "channels.getChannels", id: [{ _: "inputChannel", channel_id: channelId, access_hash: 0n }] });
|
|
934
845
|
const channel = Api.is("channel", channels.chats[0]) ? channels.chats[0] : undefined;
|
|
935
846
|
return channel?.access_hash ?? 0n;
|
|
936
|
-
}
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Get a chat's inputPeer. Useful when calling API functions directly.
|
|
850
|
+
*
|
|
851
|
+
* @param id The identifier of a chat.
|
|
852
|
+
*/
|
|
853
|
+
async getInputPeer(id) {
|
|
854
|
+
if (id === "me" || id === await this.#getSelfId()) {
|
|
855
|
+
return { _: "inputPeerSelf" };
|
|
856
|
+
}
|
|
857
|
+
const inputPeer = await this.#getInputPeerInner(id);
|
|
858
|
+
if (((Api.is("inputPeerUser", inputPeer) || Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash === 0n) && this.storage.isBot) {
|
|
859
|
+
if ("channel_id" in inputPeer) {
|
|
860
|
+
inputPeer.access_hash = await this.#getChannelAccessHash(inputPeer.channel_id);
|
|
861
|
+
}
|
|
862
|
+
else {
|
|
863
|
+
inputPeer.access_hash = await this.#getUserAccessHash(inputPeer.user_id);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
if ((Api.is("inputPeerUser", inputPeer) || Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash === 0n) {
|
|
867
|
+
throw new AccessError(`The chat ${id} cannot be accessed.`);
|
|
868
|
+
}
|
|
869
|
+
return inputPeer;
|
|
870
|
+
}
|
|
871
|
+
async #getInputPeerChatId(inputPeer) {
|
|
937
872
|
if (Api.isOneOf(["inputPeerSelf", "inputUserSelf"], inputPeer)) {
|
|
938
|
-
return await
|
|
873
|
+
return await this.#getSelfId();
|
|
939
874
|
}
|
|
940
875
|
else if (Api.isOneOf(["inputPeerEmpty", "inputUserEmpty", "inputChannelEmpty"], inputPeer)) {
|
|
941
876
|
unreachable();
|
|
@@ -943,7 +878,32 @@ export class Client extends Composer {
|
|
|
943
878
|
else {
|
|
944
879
|
return Api.peerToChatId(inputPeer);
|
|
945
880
|
}
|
|
946
|
-
}
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Get a channel or a supergroup's inputChannel. Useful when calling API functions directly.
|
|
884
|
+
*
|
|
885
|
+
* @param id The identifier of the channel or the supergroup.
|
|
886
|
+
*/
|
|
887
|
+
async getInputChannel(id) {
|
|
888
|
+
const inputPeer = await this.getInputPeer(id);
|
|
889
|
+
if (!canBeInputChannel(inputPeer)) {
|
|
890
|
+
throw new TypeError(`The chat ${id} is not a channel neither a supergroup.`);
|
|
891
|
+
}
|
|
892
|
+
return toInputChannel(inputPeer);
|
|
893
|
+
}
|
|
894
|
+
/**
|
|
895
|
+
* Get a user's inputUser. Useful when calling API functions directly.
|
|
896
|
+
*
|
|
897
|
+
* @param id The identifier of the user.
|
|
898
|
+
*/
|
|
899
|
+
async getInputUser(id) {
|
|
900
|
+
const inputPeer = await this.getInputPeer(id);
|
|
901
|
+
if (!canBeInputUser(inputPeer)) {
|
|
902
|
+
throw new TypeError(`The chat ${id} is not a private chat.`);
|
|
903
|
+
}
|
|
904
|
+
return toInputUser(inputPeer);
|
|
905
|
+
}
|
|
906
|
+
async #getInputPeerInner(id) {
|
|
947
907
|
const idn = Number(id);
|
|
948
908
|
if (!isNaN(idn)) {
|
|
949
909
|
id = idn;
|
|
@@ -959,8 +919,8 @@ export class Client extends Composer {
|
|
|
959
919
|
}
|
|
960
920
|
else {
|
|
961
921
|
const resolved = await this.invoke({ _: "contacts.resolveUsername", username: id });
|
|
962
|
-
|
|
963
|
-
|
|
922
|
+
this.#updateManager.processChats(resolved.chats, resolved);
|
|
923
|
+
this.#updateManager.processUsers(resolved.users, resolved);
|
|
964
924
|
if (Api.is("peerUser", resolved.peer)) {
|
|
965
925
|
resolvedId = Api.peerToChatId(resolved.peer);
|
|
966
926
|
}
|
|
@@ -1011,7 +971,8 @@ export class Client extends Composer {
|
|
|
1011
971
|
// }
|
|
1012
972
|
}
|
|
1013
973
|
return peer;
|
|
1014
|
-
}
|
|
974
|
+
}
|
|
975
|
+
async #getMinInputPeer(type, reference) {
|
|
1015
976
|
const peer_ = await this.messageStorage.peers.get([reference.chatId]);
|
|
1016
977
|
if (peer_ !== null && (peer_[0].type === "channel" || peer_[0].type === "supergroup")) {
|
|
1017
978
|
const peer = { _: "inputPeerChannel", channel_id: BigInt(peer_[0].id), access_hash: peer_[1] };
|
|
@@ -1025,7 +986,8 @@ export class Client extends Composer {
|
|
|
1025
986
|
else {
|
|
1026
987
|
return null;
|
|
1027
988
|
}
|
|
1028
|
-
}
|
|
989
|
+
}
|
|
990
|
+
async [getPeer](peer) {
|
|
1029
991
|
const id = Api.peerToChatId(peer);
|
|
1030
992
|
const entity = await this.messageStorage.peers.get([id]);
|
|
1031
993
|
if (entity === null) {
|
|
@@ -1041,6 +1003,163 @@ export class Client extends Composer {
|
|
|
1041
1003
|
[mustGetPeer](peer) {
|
|
1042
1004
|
return this.messageStorage.peers.mustGet([peerToChatId(peer)]);
|
|
1043
1005
|
}
|
|
1006
|
+
async #handleCtxUpdate(update) {
|
|
1007
|
+
if (this.#disableUpdates && !("authorizationState" in update) && !("connectionState" in update)) {
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
try {
|
|
1011
|
+
await this.handleUpdate(this, update);
|
|
1012
|
+
}
|
|
1013
|
+
catch (err) {
|
|
1014
|
+
this.#L.error("Failed to handle update:", err);
|
|
1015
|
+
throw err;
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
#queueHandleCtxUpdate(update) {
|
|
1019
|
+
this.#updateManager.getHandleUpdateQueue(UpdateManager.MAIN_BOX_ID).add(async () => {
|
|
1020
|
+
await this.#handleCtxUpdate(update);
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
async #handleUpdate(update) {
|
|
1024
|
+
const maybePromises = new Array();
|
|
1025
|
+
if (Api.is("updateUserName", update)) {
|
|
1026
|
+
const value = [Number(update.user_id), new Date()];
|
|
1027
|
+
for (const username_ of update.usernames) {
|
|
1028
|
+
const username = username_.username.toLowerCase();
|
|
1029
|
+
this.messageStorage.usernames.set([username], value);
|
|
1030
|
+
}
|
|
1031
|
+
const peer = { ...update, _: "peerUser" };
|
|
1032
|
+
const peer_ = await this[getPeer](peer);
|
|
1033
|
+
if (peer_ !== null) {
|
|
1034
|
+
const username = update.usernames[0];
|
|
1035
|
+
if (username !== undefined) {
|
|
1036
|
+
peer_[0].username = username.username;
|
|
1037
|
+
const also = update.usernames.filter((v) => v !== username);
|
|
1038
|
+
if (also.length) {
|
|
1039
|
+
peer_[0].also = also.map((v) => v.username);
|
|
1040
|
+
}
|
|
1041
|
+
else {
|
|
1042
|
+
delete peer_[0].also;
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
else {
|
|
1046
|
+
delete peer_[0].username;
|
|
1047
|
+
}
|
|
1048
|
+
this.messageStorage.setPeer2(peer_[0], peer_[1]);
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
if (this.#messageManager.canHandleUpdate(update)) {
|
|
1052
|
+
maybePromises.push(() => this.#messageManager.handleUpdate(update));
|
|
1053
|
+
}
|
|
1054
|
+
if (this.#chatManager.canHandleUpdate(update)) {
|
|
1055
|
+
maybePromises.push(() => this.#chatManager.handleUpdate(update));
|
|
1056
|
+
}
|
|
1057
|
+
if (this.#pollManager.canHandleUpdate(update)) {
|
|
1058
|
+
maybePromises.push(() => this.#pollManager.handleUpdate(update));
|
|
1059
|
+
}
|
|
1060
|
+
if (this.#videoChatManager.canHandleUpdate(update)) {
|
|
1061
|
+
maybePromises.push(() => this.#videoChatManager.handleUpdate(update));
|
|
1062
|
+
}
|
|
1063
|
+
if (this.#callbackQueryManager.canHandleUpdate(update)) {
|
|
1064
|
+
maybePromises.push(() => this.#callbackQueryManager.handleUpdate(update));
|
|
1065
|
+
}
|
|
1066
|
+
if (this.#inlineQueryManager.canHandleUpdate(update)) {
|
|
1067
|
+
maybePromises.push(() => this.#inlineQueryManager.handleUpdate(update));
|
|
1068
|
+
}
|
|
1069
|
+
if (this.#linkPreviewManager.canHandleUpdate(update)) {
|
|
1070
|
+
maybePromises.push(() => this.#linkPreviewManager.handleUpdate(update));
|
|
1071
|
+
}
|
|
1072
|
+
if (this.#reactionManager.canHandleUpdate(update)) {
|
|
1073
|
+
maybePromises.push(() => this.#reactionManager.handleUpdate(update));
|
|
1074
|
+
}
|
|
1075
|
+
if (this.#chatListManager.canHandleUpdate(update)) {
|
|
1076
|
+
maybePromises.push(() => this.#chatListManager.handleUpdate(update));
|
|
1077
|
+
}
|
|
1078
|
+
if (this.#storyManager.canHandleUpdate(update)) {
|
|
1079
|
+
maybePromises.push(() => this.#storyManager.handleUpdate(update));
|
|
1080
|
+
}
|
|
1081
|
+
if (this.#businessConnectionManager.canHandleUpdate(update)) {
|
|
1082
|
+
maybePromises.push(() => this.#businessConnectionManager.handleUpdate(update));
|
|
1083
|
+
}
|
|
1084
|
+
if (this.#storyManager.canHandleUpdate(update)) {
|
|
1085
|
+
maybePromises.push(() => this.#storyManager.handleUpdate(update));
|
|
1086
|
+
}
|
|
1087
|
+
if (this.#paymentManager.canHandleUpdate(update)) {
|
|
1088
|
+
maybePromises.push(() => this.#paymentManager.handleUpdate(update));
|
|
1089
|
+
}
|
|
1090
|
+
if (this.#translationsManager.canHandleUpdate(update)) {
|
|
1091
|
+
maybePromises.push(() => this.#translationsManager.handleUpdate(update));
|
|
1092
|
+
}
|
|
1093
|
+
if (this.#botInfoManager.canHandleUpdate(update)) {
|
|
1094
|
+
maybePromises.push(() => this.#botInfoManager.handleUpdate(update));
|
|
1095
|
+
}
|
|
1096
|
+
if (this.#accountManager.canHandleUpdate(update)) {
|
|
1097
|
+
maybePromises.push(() => this.#accountManager.handleUpdate(update));
|
|
1098
|
+
}
|
|
1099
|
+
return () => Promise.resolve().then(async () => {
|
|
1100
|
+
const updates = [{ update }];
|
|
1101
|
+
for (const maybePromise of maybePromises) {
|
|
1102
|
+
try {
|
|
1103
|
+
const value = maybePromise();
|
|
1104
|
+
const update = value instanceof Promise ? await value : value;
|
|
1105
|
+
if (update) {
|
|
1106
|
+
updates.push(update);
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
catch (err) {
|
|
1110
|
+
this.#L.error("failed to construct update:", err);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
for (const update of updates) {
|
|
1114
|
+
try {
|
|
1115
|
+
await this.#handleCtxUpdate(update);
|
|
1116
|
+
}
|
|
1117
|
+
finally {
|
|
1118
|
+
if ("deletedMessages" in update) {
|
|
1119
|
+
for (const { chatId, messageId } of update.deletedMessages) {
|
|
1120
|
+
await this.messageStorage.setMessage(chatId, messageId, null);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1127
|
+
#lastGetMe = null;
|
|
1128
|
+
async #getMe() {
|
|
1129
|
+
if (this.#lastGetMe !== null) {
|
|
1130
|
+
return this.#lastGetMe;
|
|
1131
|
+
}
|
|
1132
|
+
else {
|
|
1133
|
+
const user = await this.#getMeInner();
|
|
1134
|
+
this.#lastGetMe = user;
|
|
1135
|
+
return user;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
async #getMeInner() {
|
|
1139
|
+
let chatP = (await this[getPeer]({ _: "peerUser", user_id: BigInt(await this.#getSelfId()) }))?.[0] ?? null;
|
|
1140
|
+
if (chatP === null) {
|
|
1141
|
+
const users = await this.invoke({ _: "users.getUsers", id: [{ _: "inputUserSelf" }] });
|
|
1142
|
+
chatP = constructChatP(Api.as("user", users[0]));
|
|
1143
|
+
await this.storage.setIsPremium(chatP.isPremium);
|
|
1144
|
+
}
|
|
1145
|
+
const user = constructUser2(chatP);
|
|
1146
|
+
this.#lastGetMe = user;
|
|
1147
|
+
return user;
|
|
1148
|
+
}
|
|
1149
|
+
#previouslyConnected = false;
|
|
1150
|
+
#lastConnectionState = false;
|
|
1151
|
+
#onConnectionStateChange(isConnected) {
|
|
1152
|
+
if (this.#lastConnectionState !== isConnected) {
|
|
1153
|
+
if (isConnected) {
|
|
1154
|
+
if (this.#previouslyConnected) {
|
|
1155
|
+
drop(this.#updateManager.recoverUpdateGap("reconnect"));
|
|
1156
|
+
}
|
|
1157
|
+
this.#previouslyConnected = true;
|
|
1158
|
+
}
|
|
1159
|
+
const connectionState = isConnected ? "ready" : "notConnected";
|
|
1160
|
+
this.#queueHandleCtxUpdate({ connectionState });
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1044
1163
|
//
|
|
1045
1164
|
// ========================= ACCOUNT ========================= //
|
|
1046
1165
|
//
|
|
@@ -1051,8 +1170,8 @@ export class Client extends Composer {
|
|
|
1051
1170
|
* @returns Information on the currently authorized user.
|
|
1052
1171
|
*/
|
|
1053
1172
|
async getMe() {
|
|
1054
|
-
if (
|
|
1055
|
-
const me = await
|
|
1173
|
+
if (this.#lastGetMe === null) {
|
|
1174
|
+
const me = await this.#checkAuthorization();
|
|
1056
1175
|
if (!me) {
|
|
1057
1176
|
throw new InputError("Not signed in.");
|
|
1058
1177
|
}
|
|
@@ -1060,7 +1179,7 @@ export class Client extends Composer {
|
|
|
1060
1179
|
return me;
|
|
1061
1180
|
}
|
|
1062
1181
|
}
|
|
1063
|
-
return await
|
|
1182
|
+
return await this.#getMeInner();
|
|
1064
1183
|
}
|
|
1065
1184
|
/**
|
|
1066
1185
|
* Show a username in the current account, a bot account, a supergroup, or a channel's profile. User-only.
|
|
@@ -1070,7 +1189,7 @@ export class Client extends Composer {
|
|
|
1070
1189
|
* @param username The username to show.
|
|
1071
1190
|
*/
|
|
1072
1191
|
async showUsername(id, username) {
|
|
1073
|
-
await
|
|
1192
|
+
await this.#accountManager.showUsername(id, username);
|
|
1074
1193
|
}
|
|
1075
1194
|
/**
|
|
1076
1195
|
* Hide a username from the current account, a bot account, a supergroup, or a channel's profile. User-only.
|
|
@@ -1080,7 +1199,7 @@ export class Client extends Composer {
|
|
|
1080
1199
|
* @param username The username to hide.
|
|
1081
1200
|
*/
|
|
1082
1201
|
async hideUsername(id, username) {
|
|
1083
|
-
await
|
|
1202
|
+
await this.#accountManager.hideUsername(id, username);
|
|
1084
1203
|
}
|
|
1085
1204
|
/**
|
|
1086
1205
|
* Check the availability of a username. User-only.
|
|
@@ -1090,7 +1209,7 @@ export class Client extends Composer {
|
|
|
1090
1209
|
* @returns Whether the username is available.
|
|
1091
1210
|
*/
|
|
1092
1211
|
async checkUsername(username, params) {
|
|
1093
|
-
return await
|
|
1212
|
+
return await this.#accountManager.checkUsername(username, params);
|
|
1094
1213
|
}
|
|
1095
1214
|
/**
|
|
1096
1215
|
* Set the username of the current account. User-only.
|
|
@@ -1099,7 +1218,7 @@ export class Client extends Composer {
|
|
|
1099
1218
|
* @param username The username to set.
|
|
1100
1219
|
*/
|
|
1101
1220
|
async setUsername(username) {
|
|
1102
|
-
await
|
|
1221
|
+
await this.#accountManager.setUsername(username);
|
|
1103
1222
|
}
|
|
1104
1223
|
/**
|
|
1105
1224
|
* Remove the current account's username. User-only.
|
|
@@ -1107,7 +1226,7 @@ export class Client extends Composer {
|
|
|
1107
1226
|
* @method ac
|
|
1108
1227
|
*/
|
|
1109
1228
|
async removeUsername() {
|
|
1110
|
-
await
|
|
1229
|
+
await this.#accountManager.removeUsername();
|
|
1111
1230
|
}
|
|
1112
1231
|
/**
|
|
1113
1232
|
* Reorder the usernames of the current account, a bot account, a supergroup, or a channel's profile. User-only.
|
|
@@ -1118,7 +1237,7 @@ export class Client extends Composer {
|
|
|
1118
1237
|
* @returns Whether the order was changed.
|
|
1119
1238
|
*/
|
|
1120
1239
|
async reorderUsernames(id, order) {
|
|
1121
|
-
return await
|
|
1240
|
+
return await this.#accountManager.reorderUsernames(id, order);
|
|
1122
1241
|
}
|
|
1123
1242
|
/**
|
|
1124
1243
|
* Hide all usernames from a supergroup or a channel's profile. User-only.
|
|
@@ -1128,7 +1247,7 @@ export class Client extends Composer {
|
|
|
1128
1247
|
* @returns Whether any username was hidden.
|
|
1129
1248
|
*/
|
|
1130
1249
|
async hideUsernames(id) {
|
|
1131
|
-
return await
|
|
1250
|
+
return await this.#accountManager.hideUsernames(id);
|
|
1132
1251
|
}
|
|
1133
1252
|
/**
|
|
1134
1253
|
* Get a business connection. Bot-only.
|
|
@@ -1138,7 +1257,7 @@ export class Client extends Composer {
|
|
|
1138
1257
|
* @cache
|
|
1139
1258
|
*/
|
|
1140
1259
|
async getBusinessConnection(id) {
|
|
1141
|
-
return await
|
|
1260
|
+
return await this.#businessConnectionManager.getBusinessConnection(id);
|
|
1142
1261
|
}
|
|
1143
1262
|
/**
|
|
1144
1263
|
* Set the current account's online status. User-only.
|
|
@@ -1147,7 +1266,7 @@ export class Client extends Composer {
|
|
|
1147
1266
|
* @param isOnline The new online status.
|
|
1148
1267
|
*/
|
|
1149
1268
|
async setIsOnline(isOnline) {
|
|
1150
|
-
await
|
|
1269
|
+
await this.#accountManager.setIsOnline(isOnline);
|
|
1151
1270
|
}
|
|
1152
1271
|
/**
|
|
1153
1272
|
* Set the current account's emoji status. User-only.
|
|
@@ -1156,7 +1275,7 @@ export class Client extends Composer {
|
|
|
1156
1275
|
* @param emojiStatus The emoji or gift to set as the new emoji status.
|
|
1157
1276
|
*/
|
|
1158
1277
|
async setEmojiStatus(emojiStatus, params) {
|
|
1159
|
-
await
|
|
1278
|
+
await this.#accountManager.setEmojiStatus(emojiStatus, params);
|
|
1160
1279
|
}
|
|
1161
1280
|
/**
|
|
1162
1281
|
* Remove the current account's emoji status. User-only.
|
|
@@ -1164,7 +1283,7 @@ export class Client extends Composer {
|
|
|
1164
1283
|
* @method ac
|
|
1165
1284
|
*/
|
|
1166
1285
|
async removeEmojiStatus() {
|
|
1167
|
-
await
|
|
1286
|
+
await this.#accountManager.removeEmojiStatus();
|
|
1168
1287
|
}
|
|
1169
1288
|
/**
|
|
1170
1289
|
* Set the emoji status of a channel. User-only.
|
|
@@ -1174,7 +1293,7 @@ export class Client extends Composer {
|
|
|
1174
1293
|
* @param emojiStatus The emoji or gift to set as the new emoji status.
|
|
1175
1294
|
*/
|
|
1176
1295
|
async setChannelEmojiStatus(chatId, emojiStatus, params) {
|
|
1177
|
-
await
|
|
1296
|
+
await this.#accountManager.setChannelEmojiStatus(chatId, emojiStatus, params);
|
|
1178
1297
|
}
|
|
1179
1298
|
/**
|
|
1180
1299
|
* Remove the emoji status of a channel. User-only.
|
|
@@ -1183,7 +1302,7 @@ export class Client extends Composer {
|
|
|
1183
1302
|
* @param chatId The identifier of a channel.
|
|
1184
1303
|
*/
|
|
1185
1304
|
async removeChannelEmojiStatus(chatId) {
|
|
1186
|
-
await
|
|
1305
|
+
await this.#accountManager.removeChannelEmojiStatus(chatId);
|
|
1187
1306
|
}
|
|
1188
1307
|
/**
|
|
1189
1308
|
* Set the emoji status of a bot's user. Bot-only.
|
|
@@ -1193,7 +1312,7 @@ export class Client extends Composer {
|
|
|
1193
1312
|
* @param emojiStatus The emoji or gift to set as the new emoji status.
|
|
1194
1313
|
*/
|
|
1195
1314
|
async setUserEmojiStatus(userId, emojiStatus, params) {
|
|
1196
|
-
await
|
|
1315
|
+
await this.#accountManager.setUserEmojiStatus(userId, emojiStatus, params);
|
|
1197
1316
|
}
|
|
1198
1317
|
/**
|
|
1199
1318
|
* Remove the emoji status of a bot's user. Bot-only.
|
|
@@ -1202,7 +1321,7 @@ export class Client extends Composer {
|
|
|
1202
1321
|
* @param userId The identifier of a user of the bot.
|
|
1203
1322
|
*/
|
|
1204
1323
|
async removeUserEmojiStatus(userId) {
|
|
1205
|
-
await
|
|
1324
|
+
await this.#accountManager.removeUserEmojiStatus(userId);
|
|
1206
1325
|
}
|
|
1207
1326
|
/**
|
|
1208
1327
|
* Update the profile of the current user. At least one parameter must be specified. User-only.
|
|
@@ -1210,7 +1329,7 @@ export class Client extends Composer {
|
|
|
1210
1329
|
* @method ac
|
|
1211
1330
|
*/
|
|
1212
1331
|
async updateProfile(params) {
|
|
1213
|
-
await
|
|
1332
|
+
await this.#accountManager.updateProfile(params);
|
|
1214
1333
|
}
|
|
1215
1334
|
/**
|
|
1216
1335
|
* Set the birthday of the current user. User-only.
|
|
@@ -1218,7 +1337,7 @@ export class Client extends Composer {
|
|
|
1218
1337
|
* @method ac
|
|
1219
1338
|
*/
|
|
1220
1339
|
async setBirthday(params) {
|
|
1221
|
-
await
|
|
1340
|
+
await this.#accountManager.setBirthday(params);
|
|
1222
1341
|
}
|
|
1223
1342
|
/**
|
|
1224
1343
|
* Set the personal channel of the current user. User-only.
|
|
@@ -1226,7 +1345,7 @@ export class Client extends Composer {
|
|
|
1226
1345
|
* @method ac
|
|
1227
1346
|
*/
|
|
1228
1347
|
async setPersonalChannel(params) {
|
|
1229
|
-
await
|
|
1348
|
+
await this.#accountManager.setPersonalChannel(params);
|
|
1230
1349
|
}
|
|
1231
1350
|
/**
|
|
1232
1351
|
* Set the name color of the current user. User-only.
|
|
@@ -1235,7 +1354,7 @@ export class Client extends Composer {
|
|
|
1235
1354
|
* @param color The identifier of the color to set.
|
|
1236
1355
|
*/
|
|
1237
1356
|
async setNameColor(color, params) {
|
|
1238
|
-
await
|
|
1357
|
+
await this.#accountManager.setNameColor(color, params);
|
|
1239
1358
|
}
|
|
1240
1359
|
/**
|
|
1241
1360
|
* Set the profile color of the current user. User-only.
|
|
@@ -1244,7 +1363,7 @@ export class Client extends Composer {
|
|
|
1244
1363
|
* @param color The identifier of the color to set.
|
|
1245
1364
|
*/
|
|
1246
1365
|
async setProfileColor(color, params) {
|
|
1247
|
-
await
|
|
1366
|
+
await this.#accountManager.setProfileColor(color, params);
|
|
1248
1367
|
}
|
|
1249
1368
|
/**
|
|
1250
1369
|
* Set the location of the current user. User-only.
|
|
@@ -1252,7 +1371,7 @@ export class Client extends Composer {
|
|
|
1252
1371
|
* @method ac
|
|
1253
1372
|
*/
|
|
1254
1373
|
async setLocation(params) {
|
|
1255
|
-
await
|
|
1374
|
+
await this.#accountManager.setLocation(params);
|
|
1256
1375
|
}
|
|
1257
1376
|
/**
|
|
1258
1377
|
* Set the working hours of the current user. User-only.
|
|
@@ -1260,7 +1379,7 @@ export class Client extends Composer {
|
|
|
1260
1379
|
* @method ac
|
|
1261
1380
|
*/
|
|
1262
1381
|
async setWorkingHours(params) {
|
|
1263
|
-
await
|
|
1382
|
+
await this.#accountManager.setWorkingHours(params);
|
|
1264
1383
|
}
|
|
1265
1384
|
/**
|
|
1266
1385
|
* Enable sponsored messages on the current user. User-only.
|
|
@@ -1268,7 +1387,7 @@ export class Client extends Composer {
|
|
|
1268
1387
|
* @method ac
|
|
1269
1388
|
*/
|
|
1270
1389
|
async enableSponsoredMessages() {
|
|
1271
|
-
await
|
|
1390
|
+
await this.#accountManager.enableSponsoredMessages();
|
|
1272
1391
|
}
|
|
1273
1392
|
/**
|
|
1274
1393
|
* Disable sponsored messages on the current user. User-only.
|
|
@@ -1276,7 +1395,7 @@ export class Client extends Composer {
|
|
|
1276
1395
|
* @method ac
|
|
1277
1396
|
*/
|
|
1278
1397
|
async disableSponsoredMessages() {
|
|
1279
|
-
await
|
|
1398
|
+
await this.#accountManager.disableSponsoredMessages();
|
|
1280
1399
|
}
|
|
1281
1400
|
/**
|
|
1282
1401
|
* Pause the business bot in a chat. User-only.
|
|
@@ -1284,7 +1403,7 @@ export class Client extends Composer {
|
|
|
1284
1403
|
* @method ac
|
|
1285
1404
|
*/
|
|
1286
1405
|
async pauseBusinessBotConnection(chatId) {
|
|
1287
|
-
await
|
|
1406
|
+
await this.#accountManager.pauseBusinessBotConnection(chatId);
|
|
1288
1407
|
}
|
|
1289
1408
|
/**
|
|
1290
1409
|
* Resume the business bot in a chat. User-only.
|
|
@@ -1292,7 +1411,7 @@ export class Client extends Composer {
|
|
|
1292
1411
|
* @method ac
|
|
1293
1412
|
*/
|
|
1294
1413
|
async resumeBusinessBotConnection(chatId) {
|
|
1295
|
-
await
|
|
1414
|
+
await this.#accountManager.resumeBusinessBotConnection(chatId);
|
|
1296
1415
|
}
|
|
1297
1416
|
//
|
|
1298
1417
|
// ========================= MESSAGES ========================= //
|
|
@@ -1306,7 +1425,7 @@ export class Client extends Composer {
|
|
|
1306
1425
|
* @returns The sent text message.
|
|
1307
1426
|
*/
|
|
1308
1427
|
async sendMessage(chatId, text, params) {
|
|
1309
|
-
return await
|
|
1428
|
+
return await this.#messageManager.sendMessage(chatId, text, params);
|
|
1310
1429
|
}
|
|
1311
1430
|
/**
|
|
1312
1431
|
* Stream a drafted text message. Bot-only.
|
|
@@ -1317,7 +1436,7 @@ export class Client extends Composer {
|
|
|
1317
1436
|
* @param text The message's text.
|
|
1318
1437
|
*/
|
|
1319
1438
|
async sendMessageDraft(chatId, draftId, text, params) {
|
|
1320
|
-
await
|
|
1439
|
+
await this.#messageManager.sendMessageDraft(chatId, draftId, text, params);
|
|
1321
1440
|
}
|
|
1322
1441
|
/**
|
|
1323
1442
|
* Send a photo.
|
|
@@ -1328,7 +1447,7 @@ export class Client extends Composer {
|
|
|
1328
1447
|
* @returns The sent photo.
|
|
1329
1448
|
*/
|
|
1330
1449
|
async sendPhoto(chatId, photo, params) {
|
|
1331
|
-
return await
|
|
1450
|
+
return await this.#messageManager.sendPhoto(chatId, photo, params);
|
|
1332
1451
|
}
|
|
1333
1452
|
/**
|
|
1334
1453
|
* Send a document.
|
|
@@ -1339,7 +1458,7 @@ export class Client extends Composer {
|
|
|
1339
1458
|
* @returns The sent document.
|
|
1340
1459
|
*/
|
|
1341
1460
|
async sendDocument(chatId, document, params) {
|
|
1342
|
-
return await
|
|
1461
|
+
return await this.#messageManager.sendDocument(chatId, document, params);
|
|
1343
1462
|
}
|
|
1344
1463
|
/**
|
|
1345
1464
|
* Send a sticker.
|
|
@@ -1350,7 +1469,7 @@ export class Client extends Composer {
|
|
|
1350
1469
|
* @returns The sent sticker.
|
|
1351
1470
|
*/
|
|
1352
1471
|
async sendSticker(chatId, sticker, params) {
|
|
1353
|
-
return await
|
|
1472
|
+
return await this.#messageManager.sendSticker(chatId, sticker, params);
|
|
1354
1473
|
}
|
|
1355
1474
|
/**
|
|
1356
1475
|
* Send a video.
|
|
@@ -1361,7 +1480,7 @@ export class Client extends Composer {
|
|
|
1361
1480
|
* @returns The sent video.
|
|
1362
1481
|
*/
|
|
1363
1482
|
async sendVideo(chatId, video, params) {
|
|
1364
|
-
return await
|
|
1483
|
+
return await this.#messageManager.sendVideo(chatId, video, params);
|
|
1365
1484
|
}
|
|
1366
1485
|
/**
|
|
1367
1486
|
* Send an animation.
|
|
@@ -1372,7 +1491,7 @@ export class Client extends Composer {
|
|
|
1372
1491
|
* @returns The sent animation.
|
|
1373
1492
|
*/
|
|
1374
1493
|
async sendAnimation(chatId, animation, params) {
|
|
1375
|
-
return await
|
|
1494
|
+
return await this.#messageManager.sendAnimation(chatId, animation, params);
|
|
1376
1495
|
}
|
|
1377
1496
|
/**
|
|
1378
1497
|
* Send a voice message.
|
|
@@ -1383,7 +1502,7 @@ export class Client extends Composer {
|
|
|
1383
1502
|
* @returns The sent voice message.
|
|
1384
1503
|
*/
|
|
1385
1504
|
async sendVoice(chatId, voice, params) {
|
|
1386
|
-
return await
|
|
1505
|
+
return await this.#messageManager.sendVoice(chatId, voice, params);
|
|
1387
1506
|
}
|
|
1388
1507
|
/**
|
|
1389
1508
|
* Send an audio file.
|
|
@@ -1394,7 +1513,7 @@ export class Client extends Composer {
|
|
|
1394
1513
|
* @returns The sent audio filr.
|
|
1395
1514
|
*/
|
|
1396
1515
|
async sendAudio(chatId, audio, params) {
|
|
1397
|
-
return await
|
|
1516
|
+
return await this.#messageManager.sendAudio(chatId, audio, params);
|
|
1398
1517
|
}
|
|
1399
1518
|
/**
|
|
1400
1519
|
* Send a media group.
|
|
@@ -1405,7 +1524,7 @@ export class Client extends Composer {
|
|
|
1405
1524
|
* @returns The sent messages.
|
|
1406
1525
|
*/
|
|
1407
1526
|
async sendMediaGroup(chatId, media, params) {
|
|
1408
|
-
return await
|
|
1527
|
+
return await this.#messageManager.sendMediaGroup(chatId, media, params);
|
|
1409
1528
|
}
|
|
1410
1529
|
/**
|
|
1411
1530
|
* Send a video note.
|
|
@@ -1416,7 +1535,7 @@ export class Client extends Composer {
|
|
|
1416
1535
|
* @returns The sent video note.
|
|
1417
1536
|
*/
|
|
1418
1537
|
async sendVideoNote(chatId, videoNote, params) {
|
|
1419
|
-
return await
|
|
1538
|
+
return await this.#messageManager.sendVideoNote(chatId, videoNote, params);
|
|
1420
1539
|
}
|
|
1421
1540
|
/**
|
|
1422
1541
|
* Send a location.
|
|
@@ -1428,7 +1547,7 @@ export class Client extends Composer {
|
|
|
1428
1547
|
* @returns The sent location.
|
|
1429
1548
|
*/
|
|
1430
1549
|
async sendLocation(chatId, latitude, longitude, params) {
|
|
1431
|
-
return await
|
|
1550
|
+
return await this.#messageManager.sendLocation(chatId, latitude, longitude, params);
|
|
1432
1551
|
}
|
|
1433
1552
|
/**
|
|
1434
1553
|
* Send a contact.
|
|
@@ -1440,7 +1559,7 @@ export class Client extends Composer {
|
|
|
1440
1559
|
* @returns The sent contact.
|
|
1441
1560
|
*/
|
|
1442
1561
|
async sendContact(chatId, firstName, number, params) {
|
|
1443
|
-
return await
|
|
1562
|
+
return await this.#messageManager.sendContact(chatId, firstName, number, params);
|
|
1444
1563
|
}
|
|
1445
1564
|
/**
|
|
1446
1565
|
* Send a dice.
|
|
@@ -1450,7 +1569,7 @@ export class Client extends Composer {
|
|
|
1450
1569
|
* @returns The sent dice.
|
|
1451
1570
|
*/
|
|
1452
1571
|
async sendDice(chatId, params) {
|
|
1453
|
-
return await
|
|
1572
|
+
return await this.#messageManager.sendDice(chatId, params);
|
|
1454
1573
|
}
|
|
1455
1574
|
/**
|
|
1456
1575
|
* Send a venue.
|
|
@@ -1464,7 +1583,7 @@ export class Client extends Composer {
|
|
|
1464
1583
|
* @returns The sent venue.
|
|
1465
1584
|
*/
|
|
1466
1585
|
async sendVenue(chatId, latitude, longitude, title, address, params) {
|
|
1467
|
-
return await
|
|
1586
|
+
return await this.#messageManager.sendVenue(chatId, latitude, longitude, title, address, params);
|
|
1468
1587
|
}
|
|
1469
1588
|
/**
|
|
1470
1589
|
* Send a poll.
|
|
@@ -1476,7 +1595,7 @@ export class Client extends Composer {
|
|
|
1476
1595
|
* @returns The sent poll.
|
|
1477
1596
|
*/
|
|
1478
1597
|
async sendPoll(chatId, question, options, params) {
|
|
1479
|
-
return await
|
|
1598
|
+
return await this.#messageManager.sendPoll(chatId, question, options, params);
|
|
1480
1599
|
}
|
|
1481
1600
|
/**
|
|
1482
1601
|
* Send a checklist. User-only.
|
|
@@ -1488,7 +1607,7 @@ export class Client extends Composer {
|
|
|
1488
1607
|
* @returns The sent checklist.
|
|
1489
1608
|
*/
|
|
1490
1609
|
async sendChecklist(chatId, title, items, params) {
|
|
1491
|
-
return await
|
|
1610
|
+
return await this.#messageManager.sendChecklist(chatId, title, items, params);
|
|
1492
1611
|
}
|
|
1493
1612
|
/**
|
|
1494
1613
|
* Send an invoice. Bot-only.
|
|
@@ -1503,7 +1622,7 @@ export class Client extends Composer {
|
|
|
1503
1622
|
* @returns The sent invoice.
|
|
1504
1623
|
*/
|
|
1505
1624
|
async sendInvoice(chatId, title, description, payload, currency, prices, params) {
|
|
1506
|
-
return await
|
|
1625
|
+
return await this.#messageManager.sendInvoice(chatId, title, description, payload, currency, prices, params);
|
|
1507
1626
|
}
|
|
1508
1627
|
/**
|
|
1509
1628
|
* Edit a message's text.
|
|
@@ -1515,7 +1634,7 @@ export class Client extends Composer {
|
|
|
1515
1634
|
* @returns The edited text message.
|
|
1516
1635
|
*/
|
|
1517
1636
|
async editMessageText(chatId, messageId, text, params) {
|
|
1518
|
-
return await
|
|
1637
|
+
return await this.#messageManager.editMessageText(chatId, messageId, text, params);
|
|
1519
1638
|
}
|
|
1520
1639
|
/**
|
|
1521
1640
|
* Edit a message's caption.
|
|
@@ -1527,7 +1646,7 @@ export class Client extends Composer {
|
|
|
1527
1646
|
* @returns The edited message.
|
|
1528
1647
|
*/
|
|
1529
1648
|
async editMessageCaption(chatId, messageId, params) {
|
|
1530
|
-
return await
|
|
1649
|
+
return await this.#messageManager.editMessageCaption(chatId, messageId, params);
|
|
1531
1650
|
}
|
|
1532
1651
|
/**
|
|
1533
1652
|
* Edit a message's media.
|
|
@@ -1539,7 +1658,7 @@ export class Client extends Composer {
|
|
|
1539
1658
|
* @returns The edited message.
|
|
1540
1659
|
*/
|
|
1541
1660
|
async editMessageMedia(chatId, messageId, media, params) {
|
|
1542
|
-
return await
|
|
1661
|
+
return await this.#messageManager.editMessageMedia(chatId, messageId, media, params);
|
|
1543
1662
|
}
|
|
1544
1663
|
/**
|
|
1545
1664
|
* Edit an inline message's media.
|
|
@@ -1549,7 +1668,7 @@ export class Client extends Composer {
|
|
|
1549
1668
|
* @param media The new media of the message.
|
|
1550
1669
|
*/
|
|
1551
1670
|
async editInlineMessageMedia(inlineMessageId, media, params) {
|
|
1552
|
-
await
|
|
1671
|
+
await this.#messageManager.editInlineMessageMedia(inlineMessageId, media, params);
|
|
1553
1672
|
}
|
|
1554
1673
|
/**
|
|
1555
1674
|
* Edit an inline message's text. Bot-only.
|
|
@@ -1559,7 +1678,7 @@ export class Client extends Composer {
|
|
|
1559
1678
|
* @param text The new text of the message.
|
|
1560
1679
|
*/
|
|
1561
1680
|
async editInlineMessageText(inlineMessageId, text, params) {
|
|
1562
|
-
await
|
|
1681
|
+
await this.#messageManager.editInlineMessageText(inlineMessageId, text, params);
|
|
1563
1682
|
}
|
|
1564
1683
|
/**
|
|
1565
1684
|
* Edit an inline message's caption. Bot-only.
|
|
@@ -1568,7 +1687,7 @@ export class Client extends Composer {
|
|
|
1568
1687
|
* @param inlineMessageId The identifier of the inline message.
|
|
1569
1688
|
*/
|
|
1570
1689
|
async editInlineMessageCaption(inlineMessageId, params) {
|
|
1571
|
-
await
|
|
1690
|
+
await this.#messageManager.editInlineMessageCaption(inlineMessageId, params);
|
|
1572
1691
|
}
|
|
1573
1692
|
/**
|
|
1574
1693
|
* Edit a message's reply markup.
|
|
@@ -1579,7 +1698,7 @@ export class Client extends Composer {
|
|
|
1579
1698
|
* @returns The edited message.
|
|
1580
1699
|
*/
|
|
1581
1700
|
async editMessageReplyMarkup(chatId, messageId, params) {
|
|
1582
|
-
return await
|
|
1701
|
+
return await this.#messageManager.editMessageReplyMarkup(chatId, messageId, params);
|
|
1583
1702
|
}
|
|
1584
1703
|
/**
|
|
1585
1704
|
* Edit an inline message's reply markup. Bot-only.
|
|
@@ -1588,7 +1707,7 @@ export class Client extends Composer {
|
|
|
1588
1707
|
* @param inlineMessageId The identifier of the inline message.
|
|
1589
1708
|
*/
|
|
1590
1709
|
async editInlineMessageReplyMarkup(inlineMessageId, params) {
|
|
1591
|
-
await
|
|
1710
|
+
await this.#messageManager.editInlineMessageReplyMarkup(inlineMessageId, params);
|
|
1592
1711
|
}
|
|
1593
1712
|
/**
|
|
1594
1713
|
* Edit a message's live location.
|
|
@@ -1601,7 +1720,7 @@ export class Client extends Composer {
|
|
|
1601
1720
|
* @returns The edited location message.
|
|
1602
1721
|
*/
|
|
1603
1722
|
async editMessageLiveLocation(chatId, messageId, latitude, longitude, params) {
|
|
1604
|
-
return await
|
|
1723
|
+
return await this.#messageManager.editMessageLiveLocation(chatId, messageId, latitude, longitude, params);
|
|
1605
1724
|
}
|
|
1606
1725
|
/**
|
|
1607
1726
|
* Edit an inline message's live location. Bot-only.
|
|
@@ -1613,7 +1732,7 @@ export class Client extends Composer {
|
|
|
1613
1732
|
* @returns The edited location message.
|
|
1614
1733
|
*/
|
|
1615
1734
|
async editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params) {
|
|
1616
|
-
await
|
|
1735
|
+
await this.#messageManager.editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params);
|
|
1617
1736
|
}
|
|
1618
1737
|
/**
|
|
1619
1738
|
* Retrieve multiple messages.
|
|
@@ -1628,7 +1747,7 @@ export class Client extends Composer {
|
|
|
1628
1747
|
* @cache
|
|
1629
1748
|
*/
|
|
1630
1749
|
async getMessages(chatId, messageIds) {
|
|
1631
|
-
return await
|
|
1750
|
+
return await this.#messageManager.getMessages(chatId, messageIds);
|
|
1632
1751
|
}
|
|
1633
1752
|
/**
|
|
1634
1753
|
* Retrieve a single message.
|
|
@@ -1643,7 +1762,7 @@ export class Client extends Composer {
|
|
|
1643
1762
|
* @cache
|
|
1644
1763
|
*/
|
|
1645
1764
|
async getMessage(chatId, messageId) {
|
|
1646
|
-
return await
|
|
1765
|
+
return await this.#messageManager.getMessage(chatId, messageId);
|
|
1647
1766
|
}
|
|
1648
1767
|
/**
|
|
1649
1768
|
* Retrieve a message using its link.
|
|
@@ -1656,7 +1775,7 @@ export class Client extends Composer {
|
|
|
1656
1775
|
* @returns The message that was linked to.
|
|
1657
1776
|
*/
|
|
1658
1777
|
async resolveMessageLink(link) {
|
|
1659
|
-
return await
|
|
1778
|
+
return await this.#messageManager.resolveMessageLink(link);
|
|
1660
1779
|
}
|
|
1661
1780
|
/**
|
|
1662
1781
|
* Delete multiple messages.
|
|
@@ -1666,7 +1785,7 @@ export class Client extends Composer {
|
|
|
1666
1785
|
* @param messageIds The identifiers of the messages to delete.
|
|
1667
1786
|
*/
|
|
1668
1787
|
async deleteMessages(chatId, messageIds, params) {
|
|
1669
|
-
await
|
|
1788
|
+
await this.#messageManager.deleteMessages(chatId, messageIds, params);
|
|
1670
1789
|
}
|
|
1671
1790
|
/**
|
|
1672
1791
|
* Delete a single message.
|
|
@@ -1676,7 +1795,7 @@ export class Client extends Composer {
|
|
|
1676
1795
|
* @param messageId The identifier of the message to delete.
|
|
1677
1796
|
*/
|
|
1678
1797
|
async deleteMessage(chatId, messageId, params) {
|
|
1679
|
-
await
|
|
1798
|
+
await this.#messageManager.deleteMessages(chatId, [messageId], params);
|
|
1680
1799
|
}
|
|
1681
1800
|
/**
|
|
1682
1801
|
* Delete all messages sent by a specific member of a chat. User-only.
|
|
@@ -1686,7 +1805,7 @@ export class Client extends Composer {
|
|
|
1686
1805
|
* @param memberId The identifier of the member.
|
|
1687
1806
|
*/
|
|
1688
1807
|
async deleteChatMemberMessages(chatId, memberId) {
|
|
1689
|
-
await
|
|
1808
|
+
await this.#messageManager.deleteChatMemberMessages(chatId, memberId);
|
|
1690
1809
|
}
|
|
1691
1810
|
/**
|
|
1692
1811
|
* Delete multiple scheduled messages.
|
|
@@ -1696,7 +1815,7 @@ export class Client extends Composer {
|
|
|
1696
1815
|
* @param messageIds The identifiers of the scheduled messages to delete.
|
|
1697
1816
|
*/
|
|
1698
1817
|
async deleteScheduledMessages(chatId, messageIds) {
|
|
1699
|
-
await
|
|
1818
|
+
await this.#messageManager.deleteScheduledMessages(chatId, messageIds);
|
|
1700
1819
|
}
|
|
1701
1820
|
/**
|
|
1702
1821
|
* Delete a scheduled message.
|
|
@@ -1706,7 +1825,7 @@ export class Client extends Composer {
|
|
|
1706
1825
|
* @param messageId The identifier of the scheduled message to delete.
|
|
1707
1826
|
*/
|
|
1708
1827
|
async deleteScheduledMessage(chatId, messageId) {
|
|
1709
|
-
await
|
|
1828
|
+
await this.#messageManager.deleteScheduledMessage(chatId, messageId);
|
|
1710
1829
|
}
|
|
1711
1830
|
/**
|
|
1712
1831
|
* Send multiple scheduled messages before their schedule.
|
|
@@ -1716,7 +1835,7 @@ export class Client extends Composer {
|
|
|
1716
1835
|
* @param messageIds The identifiers of the scheduled messages to send.
|
|
1717
1836
|
*/
|
|
1718
1837
|
async sendScheduledMessages(chatId, messageIds) {
|
|
1719
|
-
return await
|
|
1838
|
+
return await this.#messageManager.sendScheduledMessages(chatId, messageIds);
|
|
1720
1839
|
}
|
|
1721
1840
|
/**
|
|
1722
1841
|
* Send a scheduled message before its schedule.
|
|
@@ -1726,7 +1845,7 @@ export class Client extends Composer {
|
|
|
1726
1845
|
* @param messageId The identifier of the scheduled message to send.
|
|
1727
1846
|
*/
|
|
1728
1847
|
async sendScheduledMessage(chatId, messageId) {
|
|
1729
|
-
return await
|
|
1848
|
+
return await this.#messageManager.sendScheduledMessage(chatId, messageId);
|
|
1730
1849
|
}
|
|
1731
1850
|
/**
|
|
1732
1851
|
* Pin a message in a chat.
|
|
@@ -1736,7 +1855,7 @@ export class Client extends Composer {
|
|
|
1736
1855
|
* @param messageId The identifier of the message.
|
|
1737
1856
|
*/
|
|
1738
1857
|
async pinMessage(chatId, messageId, params) {
|
|
1739
|
-
await
|
|
1858
|
+
await this.#messageManager.pinMessage(chatId, messageId, params);
|
|
1740
1859
|
}
|
|
1741
1860
|
/**
|
|
1742
1861
|
* Unpin a pinned message.
|
|
@@ -1746,7 +1865,7 @@ export class Client extends Composer {
|
|
|
1746
1865
|
* @param messageId The identifier of the message.
|
|
1747
1866
|
*/
|
|
1748
1867
|
async unpinMessage(chatId, messageId, params) {
|
|
1749
|
-
await
|
|
1868
|
+
await this.#messageManager.unpinMessage(chatId, messageId, params);
|
|
1750
1869
|
}
|
|
1751
1870
|
/**
|
|
1752
1871
|
* Unpin all pinned messages.
|
|
@@ -1755,7 +1874,7 @@ export class Client extends Composer {
|
|
|
1755
1874
|
* @param chatId The identifier of a chat.
|
|
1756
1875
|
*/
|
|
1757
1876
|
async unpinMessages(chatId, params) {
|
|
1758
|
-
await
|
|
1877
|
+
await this.#messageManager.unpinMessages(chatId, params);
|
|
1759
1878
|
}
|
|
1760
1879
|
/**
|
|
1761
1880
|
* Forward multiple messages.
|
|
@@ -1767,7 +1886,7 @@ export class Client extends Composer {
|
|
|
1767
1886
|
* @returns The forwarded messages.
|
|
1768
1887
|
*/
|
|
1769
1888
|
async forwardMessages(from, to, messageIds, params) {
|
|
1770
|
-
return await
|
|
1889
|
+
return await this.#messageManager.forwardMessages(from, to, messageIds, params);
|
|
1771
1890
|
}
|
|
1772
1891
|
/**
|
|
1773
1892
|
* Forward a single message.
|
|
@@ -1790,7 +1909,7 @@ export class Client extends Composer {
|
|
|
1790
1909
|
* @returns The new state of the poll.
|
|
1791
1910
|
*/
|
|
1792
1911
|
async stopPoll(chatId, messageId, params) {
|
|
1793
|
-
return await
|
|
1912
|
+
return await this.#messageManager.stopPoll(chatId, messageId, params);
|
|
1794
1913
|
}
|
|
1795
1914
|
/**
|
|
1796
1915
|
* Send a chat action.
|
|
@@ -1801,7 +1920,7 @@ export class Client extends Composer {
|
|
|
1801
1920
|
* @param messageThreadId The thread to send the chat action to.
|
|
1802
1921
|
*/
|
|
1803
1922
|
async sendChatAction(chatId, action, params) {
|
|
1804
|
-
await
|
|
1923
|
+
await this.#messageManager.sendChatAction(chatId, action, params);
|
|
1805
1924
|
}
|
|
1806
1925
|
/**
|
|
1807
1926
|
* Search for messages. User-only.
|
|
@@ -1809,7 +1928,7 @@ export class Client extends Composer {
|
|
|
1809
1928
|
* @method ms
|
|
1810
1929
|
*/
|
|
1811
1930
|
async searchMessages(params) {
|
|
1812
|
-
return await
|
|
1931
|
+
return await this.#messageManager.searchMessages(params);
|
|
1813
1932
|
}
|
|
1814
1933
|
/**
|
|
1815
1934
|
* Mark messages as read. User-only.
|
|
@@ -1819,7 +1938,7 @@ export class Client extends Composer {
|
|
|
1819
1938
|
* @param untilMessageId The identifier of the message that will be marked as read, along with any other unread messages before it.
|
|
1820
1939
|
*/
|
|
1821
1940
|
async readMessages(chatId, untilMessageId) {
|
|
1822
|
-
await
|
|
1941
|
+
await this.#messageManager.readMessages(chatId, untilMessageId);
|
|
1823
1942
|
}
|
|
1824
1943
|
/**
|
|
1825
1944
|
* Start a bot. User-only.
|
|
@@ -1829,7 +1948,7 @@ export class Client extends Composer {
|
|
|
1829
1948
|
* @returns The start message.
|
|
1830
1949
|
*/
|
|
1831
1950
|
async startBot(botId, params) {
|
|
1832
|
-
return await
|
|
1951
|
+
return await this.#messageManager.startBot(botId, params);
|
|
1833
1952
|
}
|
|
1834
1953
|
/**
|
|
1835
1954
|
* Transcribe a voice message. User-only.
|
|
@@ -1840,7 +1959,7 @@ export class Client extends Composer {
|
|
|
1840
1959
|
* @cache
|
|
1841
1960
|
*/
|
|
1842
1961
|
async transcribeVoice(chatId, messageId) {
|
|
1843
|
-
return await
|
|
1962
|
+
return await this.#messageManager.transcribeVoice(chatId, messageId);
|
|
1844
1963
|
}
|
|
1845
1964
|
/**
|
|
1846
1965
|
* Get a sticker set.
|
|
@@ -1849,7 +1968,7 @@ export class Client extends Composer {
|
|
|
1849
1968
|
* @param name The name of the sticker set or its link.
|
|
1850
1969
|
*/
|
|
1851
1970
|
async getStickerSet(name) {
|
|
1852
|
-
return await
|
|
1971
|
+
return await this.#messageManager.getStickerSet(name);
|
|
1853
1972
|
}
|
|
1854
1973
|
/*
|
|
1855
1974
|
* Get the link preview for a message that is about to be sent. User-only.
|
|
@@ -1858,7 +1977,7 @@ export class Client extends Composer {
|
|
|
1858
1977
|
* @param text The message's text.
|
|
1859
1978
|
*/
|
|
1860
1979
|
async getLinkPreview(text, params) {
|
|
1861
|
-
return await
|
|
1980
|
+
return await this.#linkPreviewManager.getLinkPreview(text, params);
|
|
1862
1981
|
}
|
|
1863
1982
|
/**
|
|
1864
1983
|
* Open a mini app. User-only.
|
|
@@ -1869,7 +1988,7 @@ export class Client extends Composer {
|
|
|
1869
1988
|
* @cache
|
|
1870
1989
|
*/
|
|
1871
1990
|
async openMiniApp(botId, chatId, params) {
|
|
1872
|
-
return await
|
|
1991
|
+
return await this.#messageManager.openMiniApp(botId, chatId, params);
|
|
1873
1992
|
}
|
|
1874
1993
|
/**
|
|
1875
1994
|
* Get a progress ID that can be passed to relevant send* methods to receive upload progress updates for them.
|
|
@@ -1878,7 +1997,7 @@ export class Client extends Composer {
|
|
|
1878
1997
|
* @cache
|
|
1879
1998
|
*/
|
|
1880
1999
|
async getProgressId() {
|
|
1881
|
-
return await
|
|
2000
|
+
return await this.#fileManager.getProgressId();
|
|
1882
2001
|
}
|
|
1883
2002
|
/**
|
|
1884
2003
|
* Get messages saved from a specific chat.
|
|
@@ -1887,7 +2006,7 @@ export class Client extends Composer {
|
|
|
1887
2006
|
* @param chatId The identifier of a chat.
|
|
1888
2007
|
*/
|
|
1889
2008
|
async getSavedMessages(chatId, params) {
|
|
1890
|
-
return await
|
|
2009
|
+
return await this.#messageManager.getSavedMessages(chatId, params);
|
|
1891
2010
|
}
|
|
1892
2011
|
/**
|
|
1893
2012
|
* Get a list of saved chats.
|
|
@@ -1895,7 +2014,7 @@ export class Client extends Composer {
|
|
|
1895
2014
|
* @method ms
|
|
1896
2015
|
*/
|
|
1897
2016
|
async getSavedChats(params) {
|
|
1898
|
-
return await
|
|
2017
|
+
return await this.#messageManager.getSavedChats(params);
|
|
1899
2018
|
}
|
|
1900
2019
|
/**
|
|
1901
2020
|
* Get a list of reactions made to a message. User-only.
|
|
@@ -1905,7 +2024,7 @@ export class Client extends Composer {
|
|
|
1905
2024
|
* @method ms
|
|
1906
2025
|
*/
|
|
1907
2026
|
async getMessageReactions(chatId, messageId, params) {
|
|
1908
|
-
return await
|
|
2027
|
+
return await this.#messageManager.getMessageReactions(chatId, messageId, params);
|
|
1909
2028
|
}
|
|
1910
2029
|
//
|
|
1911
2030
|
// ========================= POLLS ========================= //
|
|
@@ -1919,7 +2038,7 @@ export class Client extends Composer {
|
|
|
1919
2038
|
* @param optionIndexes The indexes of the options to cast for.
|
|
1920
2039
|
*/
|
|
1921
2040
|
async vote(chatId, messageId, optionIndexes) {
|
|
1922
|
-
await
|
|
2041
|
+
await this.#pollManager.vote(chatId, messageId, optionIndexes);
|
|
1923
2042
|
}
|
|
1924
2043
|
/**
|
|
1925
2044
|
* Retract a vote. User-only.
|
|
@@ -1929,7 +2048,7 @@ export class Client extends Composer {
|
|
|
1929
2048
|
* @param messageId The identifier of the message that includes the poll.
|
|
1930
2049
|
*/
|
|
1931
2050
|
async retractVote(chatId, messageId) {
|
|
1932
|
-
await
|
|
2051
|
+
await this.#pollManager.retractVote(chatId, messageId);
|
|
1933
2052
|
}
|
|
1934
2053
|
//
|
|
1935
2054
|
// ========================= CHECKLISTS ========================= //
|
|
@@ -1943,7 +2062,7 @@ export class Client extends Composer {
|
|
|
1943
2062
|
* @method cl
|
|
1944
2063
|
*/
|
|
1945
2064
|
async addToChecklist(chatId, messageId, items) {
|
|
1946
|
-
await
|
|
2065
|
+
await this.#checklistManager.addToChecklist(chatId, messageId, items);
|
|
1947
2066
|
}
|
|
1948
2067
|
/**
|
|
1949
2068
|
* Update a checklist. User-only.
|
|
@@ -1953,7 +2072,7 @@ export class Client extends Composer {
|
|
|
1953
2072
|
* @method cl
|
|
1954
2073
|
*/
|
|
1955
2074
|
async updateChecklist(chatId, messageId, params) {
|
|
1956
|
-
await
|
|
2075
|
+
await this.#checklistManager.updateChecklist(chatId, messageId, params);
|
|
1957
2076
|
}
|
|
1958
2077
|
/**
|
|
1959
2078
|
* Check multiple items of a checklist. User-only.
|
|
@@ -1964,7 +2083,7 @@ export class Client extends Composer {
|
|
|
1964
2083
|
* @method cl
|
|
1965
2084
|
*/
|
|
1966
2085
|
async checkChecklistItems(chatId, messageId, items) {
|
|
1967
|
-
await
|
|
2086
|
+
await this.#checklistManager.checkChecklistItems(chatId, messageId, items);
|
|
1968
2087
|
}
|
|
1969
2088
|
/**
|
|
1970
2089
|
* Uncheck multiple items of a checklist. User-only.
|
|
@@ -1975,7 +2094,7 @@ export class Client extends Composer {
|
|
|
1975
2094
|
* @method cl
|
|
1976
2095
|
*/
|
|
1977
2096
|
async uncheckChecklistItems(chatId, messageId, items) {
|
|
1978
|
-
await
|
|
2097
|
+
await this.#checklistManager.uncheckChecklistItems(chatId, messageId, items);
|
|
1979
2098
|
}
|
|
1980
2099
|
/**
|
|
1981
2100
|
* Check a single item of a checklist. User-only.
|
|
@@ -1986,7 +2105,7 @@ export class Client extends Composer {
|
|
|
1986
2105
|
* @method cl
|
|
1987
2106
|
*/
|
|
1988
2107
|
async checkChecklistItem(chatId, messageId, item) {
|
|
1989
|
-
await
|
|
2108
|
+
await this.#checklistManager.checkChecklistItem(chatId, messageId, item);
|
|
1990
2109
|
}
|
|
1991
2110
|
/**
|
|
1992
2111
|
* Uncheck a single item of a checklist. User-only.
|
|
@@ -1997,7 +2116,7 @@ export class Client extends Composer {
|
|
|
1997
2116
|
* @method cl
|
|
1998
2117
|
*/
|
|
1999
2118
|
async uncheckChecklistItem(chatId, messageId, item) {
|
|
2000
|
-
await
|
|
2119
|
+
await this.#checklistManager.uncheckChecklistItem(chatId, messageId, item);
|
|
2001
2120
|
}
|
|
2002
2121
|
//
|
|
2003
2122
|
// ========================= FILES ========================= //
|
|
@@ -2015,7 +2134,7 @@ export class Client extends Composer {
|
|
|
2015
2134
|
*/
|
|
2016
2135
|
async downloadChunk(fileId, params) {
|
|
2017
2136
|
const controller = new AbortController();
|
|
2018
|
-
for await (const chunk of
|
|
2137
|
+
for await (const chunk of this.#fileManager.download(fileId, { ...params, signal: controller.signal })) {
|
|
2019
2138
|
controller.abort();
|
|
2020
2139
|
return chunk;
|
|
2021
2140
|
}
|
|
@@ -2035,7 +2154,7 @@ export class Client extends Composer {
|
|
|
2035
2154
|
* @cache file
|
|
2036
2155
|
*/
|
|
2037
2156
|
async *download(fileId, params) {
|
|
2038
|
-
for await (const chunk of
|
|
2157
|
+
for await (const chunk of this.#fileManager.download(fileId, params)) {
|
|
2039
2158
|
yield chunk;
|
|
2040
2159
|
}
|
|
2041
2160
|
}
|
|
@@ -2048,7 +2167,7 @@ export class Client extends Composer {
|
|
|
2048
2167
|
* @cache
|
|
2049
2168
|
*/
|
|
2050
2169
|
async getCustomEmojiStickers(id) {
|
|
2051
|
-
return await
|
|
2170
|
+
return await this.#fileManager.getCustomEmojiStickers(id);
|
|
2052
2171
|
}
|
|
2053
2172
|
//
|
|
2054
2173
|
// ========================= CHATS ========================= //
|
|
@@ -2059,7 +2178,7 @@ export class Client extends Composer {
|
|
|
2059
2178
|
* @method ch
|
|
2060
2179
|
*/
|
|
2061
2180
|
async getChats(params) {
|
|
2062
|
-
return await
|
|
2181
|
+
return await this.#chatListManager.getChats(params?.from, params?.after, params?.limit);
|
|
2063
2182
|
}
|
|
2064
2183
|
/**
|
|
2065
2184
|
* Get pinned chats from a chat list. User-only.
|
|
@@ -2068,7 +2187,7 @@ export class Client extends Composer {
|
|
|
2068
2187
|
* @param from The chat list to get the pinned chats from. Defaults to main.
|
|
2069
2188
|
*/
|
|
2070
2189
|
async getPinnedChats(from) {
|
|
2071
|
-
return await
|
|
2190
|
+
return await this.#chatListManager.getPinnedChats(from);
|
|
2072
2191
|
}
|
|
2073
2192
|
/**
|
|
2074
2193
|
* Get a chat.
|
|
@@ -2077,7 +2196,7 @@ export class Client extends Composer {
|
|
|
2077
2196
|
* @cache
|
|
2078
2197
|
*/
|
|
2079
2198
|
async getChat(chatId) {
|
|
2080
|
-
return await
|
|
2199
|
+
return await this.#chatListManager.getChat(chatId);
|
|
2081
2200
|
}
|
|
2082
2201
|
/**
|
|
2083
2202
|
* Get chat history. User-only.
|
|
@@ -2086,7 +2205,7 @@ export class Client extends Composer {
|
|
|
2086
2205
|
* @param chatId The identifier of a chat.
|
|
2087
2206
|
*/
|
|
2088
2207
|
async getHistory(chatId, params) {
|
|
2089
|
-
return await
|
|
2208
|
+
return await this.#messageManager.getHistory(chatId, params);
|
|
2090
2209
|
}
|
|
2091
2210
|
/**
|
|
2092
2211
|
* Set a chat's available reactions. User-only.
|
|
@@ -2096,7 +2215,7 @@ export class Client extends Composer {
|
|
|
2096
2215
|
* @param availableReactions The new available reactions.
|
|
2097
2216
|
*/
|
|
2098
2217
|
async setAvailableReactions(chatId, availableReactions) {
|
|
2099
|
-
await
|
|
2218
|
+
await this.#chatManager.setAvailableReactions(chatId, availableReactions);
|
|
2100
2219
|
}
|
|
2101
2220
|
/**
|
|
2102
2221
|
* Set a chat's photo.
|
|
@@ -2106,7 +2225,7 @@ export class Client extends Composer {
|
|
|
2106
2225
|
* @param photo A photo to set as the chat's photo.
|
|
2107
2226
|
*/
|
|
2108
2227
|
async setChatPhoto(chatId, photo, params) {
|
|
2109
|
-
await
|
|
2228
|
+
await this.#chatManager.setChatPhoto(chatId, photo, params);
|
|
2110
2229
|
}
|
|
2111
2230
|
/**
|
|
2112
2231
|
* Delete a chat's photo.
|
|
@@ -2115,7 +2234,7 @@ export class Client extends Composer {
|
|
|
2115
2234
|
* @param chatId The identifier of a chat.
|
|
2116
2235
|
*/
|
|
2117
2236
|
async deleteChatPhoto(chatId) {
|
|
2118
|
-
await
|
|
2237
|
+
await this.#chatManager.deleteChatPhoto(chatId);
|
|
2119
2238
|
}
|
|
2120
2239
|
/**
|
|
2121
2240
|
* Ban a member from a chat.
|
|
@@ -2125,7 +2244,7 @@ export class Client extends Composer {
|
|
|
2125
2244
|
* @param memberId The identifier of the member.
|
|
2126
2245
|
*/
|
|
2127
2246
|
async banChatMember(chatId, memberId, params) {
|
|
2128
|
-
await
|
|
2247
|
+
await this.#chatManager.banChatMember(chatId, memberId, params);
|
|
2129
2248
|
}
|
|
2130
2249
|
/**
|
|
2131
2250
|
* Unban a member from a chat.
|
|
@@ -2135,7 +2254,7 @@ export class Client extends Composer {
|
|
|
2135
2254
|
* @param memberId The identifier of the member.
|
|
2136
2255
|
*/
|
|
2137
2256
|
async unbanChatMember(chatId, memberId) {
|
|
2138
|
-
await
|
|
2257
|
+
await this.#chatManager.unbanChatMember(chatId, memberId);
|
|
2139
2258
|
}
|
|
2140
2259
|
/**
|
|
2141
2260
|
* Kick a member from a chat. Same as a banChatMember call followed by unbanChatMember.
|
|
@@ -2145,8 +2264,8 @@ export class Client extends Composer {
|
|
|
2145
2264
|
* @param memberId The identifier of the member.
|
|
2146
2265
|
*/
|
|
2147
2266
|
async kickChatMember(chatId, memberId) {
|
|
2148
|
-
await
|
|
2149
|
-
await
|
|
2267
|
+
await this.#chatManager.banChatMember(chatId, memberId);
|
|
2268
|
+
await this.#chatManager.unbanChatMember(chatId, memberId);
|
|
2150
2269
|
}
|
|
2151
2270
|
/**
|
|
2152
2271
|
* Set the rights of a chat member.
|
|
@@ -2156,7 +2275,7 @@ export class Client extends Composer {
|
|
|
2156
2275
|
* @param memberId The identifier of the member.
|
|
2157
2276
|
*/
|
|
2158
2277
|
async setChatMemberRights(chatId, memberId, params) {
|
|
2159
|
-
await
|
|
2278
|
+
await this.#chatManager.setChatMemberRights(chatId, memberId, params);
|
|
2160
2279
|
}
|
|
2161
2280
|
/**
|
|
2162
2281
|
* Get the administrators of a chat.
|
|
@@ -2166,7 +2285,7 @@ export class Client extends Composer {
|
|
|
2166
2285
|
* @returns The chat's administrators.
|
|
2167
2286
|
*/
|
|
2168
2287
|
async getChatAdministrators(chatId) {
|
|
2169
|
-
return await
|
|
2288
|
+
return await this.#chatListManager.getChatAdministrators(chatId);
|
|
2170
2289
|
}
|
|
2171
2290
|
/**
|
|
2172
2291
|
* Enable join requests in a chat. User-only.
|
|
@@ -2175,7 +2294,7 @@ export class Client extends Composer {
|
|
|
2175
2294
|
* @param chatId The identifier of a chat. Must be a channel or a supergroup.
|
|
2176
2295
|
*/
|
|
2177
2296
|
async enableJoinRequests(chatId) {
|
|
2178
|
-
await
|
|
2297
|
+
await this.#chatManager.enableJoinRequests(chatId);
|
|
2179
2298
|
}
|
|
2180
2299
|
/**
|
|
2181
2300
|
* Disable join requests in a chat. User-only.
|
|
@@ -2184,7 +2303,7 @@ export class Client extends Composer {
|
|
|
2184
2303
|
* @param chatId The identifier of a chat. Must be a channel or a supergroup.
|
|
2185
2304
|
*/
|
|
2186
2305
|
async disableJoinRequests(chatId) {
|
|
2187
|
-
await
|
|
2306
|
+
await this.#chatManager.disableJoinRequests(chatId);
|
|
2188
2307
|
}
|
|
2189
2308
|
/**
|
|
2190
2309
|
* Get inactive chats. User-only.
|
|
@@ -2193,7 +2312,7 @@ export class Client extends Composer {
|
|
|
2193
2312
|
* @retuns A list of inactive chats the current user is member of.
|
|
2194
2313
|
*/
|
|
2195
2314
|
async getInactiveChats() {
|
|
2196
|
-
return await
|
|
2315
|
+
return await this.#accountManager.getInactiveChats();
|
|
2197
2316
|
}
|
|
2198
2317
|
/**
|
|
2199
2318
|
* Get the invite links created for a chat. User-only.
|
|
@@ -2203,7 +2322,7 @@ export class Client extends Composer {
|
|
|
2203
2322
|
* @returns The invite links created for the chat. This might be a subset of the results if they were less than `limit`. The parameters `afterDate` and `afterInviteLink` can be used for pagination.
|
|
2204
2323
|
*/
|
|
2205
2324
|
async getCreatedInviteLinks(chatId, params) {
|
|
2206
|
-
return await
|
|
2325
|
+
return await this.#chatManager.getCreatedInviteLinks(chatId, params);
|
|
2207
2326
|
}
|
|
2208
2327
|
/**
|
|
2209
2328
|
* Join a chat. User-only.
|
|
@@ -2212,7 +2331,7 @@ export class Client extends Composer {
|
|
|
2212
2331
|
* @param chatId The identifier of a chat.
|
|
2213
2332
|
*/
|
|
2214
2333
|
async joinChat(chatId) {
|
|
2215
|
-
await
|
|
2334
|
+
await this.#chatManager.joinChat(chatId);
|
|
2216
2335
|
}
|
|
2217
2336
|
/**
|
|
2218
2337
|
* Leave a chat.
|
|
@@ -2221,7 +2340,7 @@ export class Client extends Composer {
|
|
|
2221
2340
|
* @param chatId The identifier of a chat.
|
|
2222
2341
|
*/
|
|
2223
2342
|
async leaveChat(chatId) {
|
|
2224
|
-
await
|
|
2343
|
+
await this.#chatManager.leaveChat(chatId);
|
|
2225
2344
|
}
|
|
2226
2345
|
/**
|
|
2227
2346
|
* Get information on a user's chat membership.
|
|
@@ -2231,7 +2350,7 @@ export class Client extends Composer {
|
|
|
2231
2350
|
* @param userId The identifier of the user.
|
|
2232
2351
|
*/
|
|
2233
2352
|
async getChatMember(chatId, userId) {
|
|
2234
|
-
return await
|
|
2353
|
+
return await this.#chatListManager.getChatMember(chatId, userId);
|
|
2235
2354
|
}
|
|
2236
2355
|
/**
|
|
2237
2356
|
* Get the members of a chat.
|
|
@@ -2240,7 +2359,7 @@ export class Client extends Composer {
|
|
|
2240
2359
|
* @param chatId The identifier of a chat.
|
|
2241
2360
|
*/
|
|
2242
2361
|
async getChatMembers(chatId, params) {
|
|
2243
|
-
return await
|
|
2362
|
+
return await this.#chatListManager.getChatMembers(chatId, params);
|
|
2244
2363
|
}
|
|
2245
2364
|
/**
|
|
2246
2365
|
* Set a chat's sticker set.
|
|
@@ -2250,7 +2369,7 @@ export class Client extends Composer {
|
|
|
2250
2369
|
* @param setName The name of the set.
|
|
2251
2370
|
*/
|
|
2252
2371
|
async setChatStickerSet(chatId, setName) {
|
|
2253
|
-
await
|
|
2372
|
+
await this.#messageManager.setChatStickerSet(chatId, setName);
|
|
2254
2373
|
}
|
|
2255
2374
|
/**
|
|
2256
2375
|
* Delete a chat's sticker set.
|
|
@@ -2259,7 +2378,7 @@ export class Client extends Composer {
|
|
|
2259
2378
|
* @param chatId The identifier of a chat. Must be a supergroup.
|
|
2260
2379
|
*/
|
|
2261
2380
|
async deleteChatStickerSet(chatId) {
|
|
2262
|
-
await
|
|
2381
|
+
await this.#messageManager.deleteChatStickerSet(chatId);
|
|
2263
2382
|
}
|
|
2264
2383
|
/**
|
|
2265
2384
|
* Set the number of boosts required to circument a chat's default restrictions. User-only.
|
|
@@ -2269,7 +2388,7 @@ export class Client extends Composer {
|
|
|
2269
2388
|
* @param boosts The number of boosts required to circumvent its restrictions.
|
|
2270
2389
|
*/
|
|
2271
2390
|
async setBoostsRequiredToCircumventRestrictions(chatId, boosts) {
|
|
2272
|
-
await
|
|
2391
|
+
await this.#chatManager.setBoostsRequiredToCircumventRestrictions(chatId, boosts);
|
|
2273
2392
|
}
|
|
2274
2393
|
/**
|
|
2275
2394
|
* Create an invite link.
|
|
@@ -2279,7 +2398,7 @@ export class Client extends Composer {
|
|
|
2279
2398
|
* @returns The newly created invite link.
|
|
2280
2399
|
*/
|
|
2281
2400
|
async createInviteLink(chatId, params) {
|
|
2282
|
-
return await
|
|
2401
|
+
return await this.#chatManager.createInviteLink(chatId, params);
|
|
2283
2402
|
}
|
|
2284
2403
|
/**
|
|
2285
2404
|
* Approve a join request.
|
|
@@ -2289,7 +2408,7 @@ export class Client extends Composer {
|
|
|
2289
2408
|
* @param userId The user who made the join request.
|
|
2290
2409
|
*/
|
|
2291
2410
|
async approveJoinRequest(chatId, userId) {
|
|
2292
|
-
await
|
|
2411
|
+
await this.#chatManager.approveJoinRequest(chatId, userId);
|
|
2293
2412
|
}
|
|
2294
2413
|
/**
|
|
2295
2414
|
* Decline a join request.
|
|
@@ -2299,7 +2418,7 @@ export class Client extends Composer {
|
|
|
2299
2418
|
* @param userId The user who made the join request.
|
|
2300
2419
|
*/
|
|
2301
2420
|
async declineJoinRequest(chatId, userId) {
|
|
2302
|
-
await
|
|
2421
|
+
await this.#chatManager.declineJoinRequest(chatId, userId);
|
|
2303
2422
|
}
|
|
2304
2423
|
/**
|
|
2305
2424
|
* Approve all join requests. User-only.
|
|
@@ -2308,7 +2427,7 @@ export class Client extends Composer {
|
|
|
2308
2427
|
* @param chatId The identifier of a chat with the join requests.
|
|
2309
2428
|
*/
|
|
2310
2429
|
async approveJoinRequests(chatId, params) {
|
|
2311
|
-
await
|
|
2430
|
+
await this.#chatManager.approveJoinRequests(chatId, params);
|
|
2312
2431
|
}
|
|
2313
2432
|
/**
|
|
2314
2433
|
* Decline all join requests. User-only.
|
|
@@ -2317,7 +2436,7 @@ export class Client extends Composer {
|
|
|
2317
2436
|
* @param chatId The identifier of a chat with the join requests.
|
|
2318
2437
|
*/
|
|
2319
2438
|
async declineJoinRequests(chatId, params) {
|
|
2320
|
-
await
|
|
2439
|
+
await this.#chatManager.declineJoinRequests(chatId, params);
|
|
2321
2440
|
}
|
|
2322
2441
|
/**
|
|
2323
2442
|
* Get pending join requests in a chat. User-only.
|
|
@@ -2326,7 +2445,7 @@ export class Client extends Composer {
|
|
|
2326
2445
|
* @param chatId The identifier of a chat with the join requests.
|
|
2327
2446
|
*/
|
|
2328
2447
|
async getJoinRequests(chatId, params) {
|
|
2329
|
-
return await
|
|
2448
|
+
return await this.#chatManager.getJoinRequests(chatId, params);
|
|
2330
2449
|
}
|
|
2331
2450
|
/**
|
|
2332
2451
|
* Add a single user to a chat.
|
|
@@ -2337,7 +2456,7 @@ export class Client extends Composer {
|
|
|
2337
2456
|
* @returns An array of FailedInvitation that has at most a length of 1. If empty, it means that the user was added.
|
|
2338
2457
|
*/
|
|
2339
2458
|
async addChatMember(chatId, userId, params) {
|
|
2340
|
-
return await
|
|
2459
|
+
return await this.#chatManager.addChatMember(chatId, userId, params);
|
|
2341
2460
|
}
|
|
2342
2461
|
/**
|
|
2343
2462
|
* Add multiple users at once to a channel or a supergroup.
|
|
@@ -2348,7 +2467,7 @@ export class Client extends Composer {
|
|
|
2348
2467
|
* @returns An array of FailedInvitation that has at most a length that is the same as that of the parameter userIds. If empty, it means that all the provided users were added.
|
|
2349
2468
|
*/
|
|
2350
2469
|
async addChatMembers(chatId, userIds) {
|
|
2351
|
-
return await
|
|
2470
|
+
return await this.#chatManager.addChatMembers(chatId, userIds);
|
|
2352
2471
|
}
|
|
2353
2472
|
/**
|
|
2354
2473
|
* Open a chat.
|
|
@@ -2357,7 +2476,7 @@ export class Client extends Composer {
|
|
|
2357
2476
|
* @param chatId The identifier of a chat to open.
|
|
2358
2477
|
*/
|
|
2359
2478
|
async openChat(chatId, params) {
|
|
2360
|
-
await
|
|
2479
|
+
await this.#updateManager.openChat(chatId, params);
|
|
2361
2480
|
}
|
|
2362
2481
|
/**
|
|
2363
2482
|
* Close a chat previously opened by openChat.
|
|
@@ -2366,7 +2485,7 @@ export class Client extends Composer {
|
|
|
2366
2485
|
* @param chatId The identifier of a chat to close.
|
|
2367
2486
|
*/
|
|
2368
2487
|
async closeChat(chatId) {
|
|
2369
|
-
await
|
|
2488
|
+
await this.#updateManager.closeChat(chatId);
|
|
2370
2489
|
}
|
|
2371
2490
|
/**
|
|
2372
2491
|
* Create a group. User-only.
|
|
@@ -2376,7 +2495,7 @@ export class Client extends Composer {
|
|
|
2376
2495
|
* @returns The created group.
|
|
2377
2496
|
*/
|
|
2378
2497
|
async createGroup(title, params) {
|
|
2379
|
-
return await
|
|
2498
|
+
return await this.#chatListManager.createGroup(title, params);
|
|
2380
2499
|
}
|
|
2381
2500
|
/**
|
|
2382
2501
|
* Create a supergroup. User-only.
|
|
@@ -2386,7 +2505,7 @@ export class Client extends Composer {
|
|
|
2386
2505
|
* @returns The created supergroup.
|
|
2387
2506
|
*/
|
|
2388
2507
|
async createSupergroup(title, params) {
|
|
2389
|
-
return await
|
|
2508
|
+
return await this.#chatListManager.createSupergroup(title, params);
|
|
2390
2509
|
}
|
|
2391
2510
|
/**
|
|
2392
2511
|
* Create a channel. User-only.
|
|
@@ -2396,7 +2515,7 @@ export class Client extends Composer {
|
|
|
2396
2515
|
* @returns The created channel.
|
|
2397
2516
|
*/
|
|
2398
2517
|
async createChannel(title, params) {
|
|
2399
|
-
return await
|
|
2518
|
+
return await this.#chatListManager.createChannel(title, params);
|
|
2400
2519
|
}
|
|
2401
2520
|
/**
|
|
2402
2521
|
* Set the time to live of the messages of a chat. User-only.
|
|
@@ -2406,7 +2525,7 @@ export class Client extends Composer {
|
|
|
2406
2525
|
* @param messageTtl The time to live of the messages in seconds.
|
|
2407
2526
|
*/
|
|
2408
2527
|
async setMessageTtl(chatId, messageTtl) {
|
|
2409
|
-
await
|
|
2528
|
+
await this.#chatListManager.setMessageTtl(chatId, messageTtl);
|
|
2410
2529
|
}
|
|
2411
2530
|
/**
|
|
2412
2531
|
* Archive multiple chats. User-only.
|
|
@@ -2415,7 +2534,7 @@ export class Client extends Composer {
|
|
|
2415
2534
|
* @param chatIds The identifiers of the chats to archive.
|
|
2416
2535
|
*/
|
|
2417
2536
|
async archiveChats(chatIds) {
|
|
2418
|
-
await
|
|
2537
|
+
await this.#chatListManager.archiveChats(chatIds);
|
|
2419
2538
|
}
|
|
2420
2539
|
/**
|
|
2421
2540
|
* Archive a single chat. User-only.
|
|
@@ -2424,7 +2543,7 @@ export class Client extends Composer {
|
|
|
2424
2543
|
* @param chatId The identifier of a chat.
|
|
2425
2544
|
*/
|
|
2426
2545
|
async archiveChat(chatId) {
|
|
2427
|
-
await
|
|
2546
|
+
await this.#chatListManager.archiveChat(chatId);
|
|
2428
2547
|
}
|
|
2429
2548
|
/**
|
|
2430
2549
|
* Unarchive multiple chats. User-only.
|
|
@@ -2433,7 +2552,7 @@ export class Client extends Composer {
|
|
|
2433
2552
|
* @param chatIds The identifiers of the chats to unarchive.
|
|
2434
2553
|
*/
|
|
2435
2554
|
async unarchiveChats(chatIds) {
|
|
2436
|
-
await
|
|
2555
|
+
await this.#chatListManager.unarchiveChats(chatIds);
|
|
2437
2556
|
}
|
|
2438
2557
|
/**
|
|
2439
2558
|
* Unarchive a single chat. User-only.
|
|
@@ -2442,7 +2561,7 @@ export class Client extends Composer {
|
|
|
2442
2561
|
* @param chatId The identifier of a chat.
|
|
2443
2562
|
*/
|
|
2444
2563
|
async unarchiveChat(chatId) {
|
|
2445
|
-
await
|
|
2564
|
+
await this.#chatListManager.unarchiveChat(chatId);
|
|
2446
2565
|
}
|
|
2447
2566
|
/**
|
|
2448
2567
|
* Get common chats between a user and the current one. User-only.
|
|
@@ -2451,7 +2570,7 @@ export class Client extends Composer {
|
|
|
2451
2570
|
* @param userId The identifier of the user to get the common chats with them.
|
|
2452
2571
|
*/
|
|
2453
2572
|
async getCommonChats(userId, params) {
|
|
2454
|
-
return await
|
|
2573
|
+
return await this.#chatListManager.getCommonChats(userId, params);
|
|
2455
2574
|
}
|
|
2456
2575
|
/**
|
|
2457
2576
|
* Get the settings of a chat. User-only.
|
|
@@ -2460,7 +2579,7 @@ export class Client extends Composer {
|
|
|
2460
2579
|
* @param chatId The identifier of a chat.
|
|
2461
2580
|
*/
|
|
2462
2581
|
async getChatSettings(chatId) {
|
|
2463
|
-
return await
|
|
2582
|
+
return await this.#chatListManager.getChatSettings(chatId);
|
|
2464
2583
|
}
|
|
2465
2584
|
/**
|
|
2466
2585
|
* Disable business bots in a private chat. User-only.
|
|
@@ -2469,7 +2588,7 @@ export class Client extends Composer {
|
|
|
2469
2588
|
* @param chatId The identifier of the private chat to disable business bots in.
|
|
2470
2589
|
*/
|
|
2471
2590
|
async disableBusinessBots(chatId) {
|
|
2472
|
-
await
|
|
2591
|
+
await this.#chatListManager.disableBusinessBots(chatId);
|
|
2473
2592
|
}
|
|
2474
2593
|
/**
|
|
2475
2594
|
* Enable business bots in a private chat. User-only.
|
|
@@ -2478,7 +2597,7 @@ export class Client extends Composer {
|
|
|
2478
2597
|
* @param chatId The identifier of the private chat to enable business bots in.
|
|
2479
2598
|
*/
|
|
2480
2599
|
async enableBusinessBots(chatId) {
|
|
2481
|
-
await
|
|
2600
|
+
await this.#chatListManager.enableBusinessBots(chatId);
|
|
2482
2601
|
}
|
|
2483
2602
|
/**
|
|
2484
2603
|
* Disable slow mode in a group. User-only.
|
|
@@ -2487,7 +2606,7 @@ export class Client extends Composer {
|
|
|
2487
2606
|
* @param chatId The identifier of the group to disable slow mode in.
|
|
2488
2607
|
*/
|
|
2489
2608
|
async disableSlowMode(chatId) {
|
|
2490
|
-
await
|
|
2609
|
+
await this.#chatManager.disableSlowMode(chatId);
|
|
2491
2610
|
}
|
|
2492
2611
|
/**
|
|
2493
2612
|
* Change slow mode in a group. User-only.
|
|
@@ -2497,7 +2616,7 @@ export class Client extends Composer {
|
|
|
2497
2616
|
* @param duration New slow mode duration.
|
|
2498
2617
|
*/
|
|
2499
2618
|
async setSlowMode(chatId, duration) {
|
|
2500
|
-
await
|
|
2619
|
+
await this.#chatManager.setSlowMode(chatId, duration);
|
|
2501
2620
|
}
|
|
2502
2621
|
/**
|
|
2503
2622
|
* Change the title of a chat.
|
|
@@ -2507,7 +2626,7 @@ export class Client extends Composer {
|
|
|
2507
2626
|
* @param title The new title.
|
|
2508
2627
|
*/
|
|
2509
2628
|
async setChatTitle(chatId, title) {
|
|
2510
|
-
await
|
|
2629
|
+
await this.#chatManager.setChatTitle(chatId, title);
|
|
2511
2630
|
}
|
|
2512
2631
|
/**
|
|
2513
2632
|
* Change the description of a chat.
|
|
@@ -2517,7 +2636,7 @@ export class Client extends Composer {
|
|
|
2517
2636
|
* @param description The new description.
|
|
2518
2637
|
*/
|
|
2519
2638
|
async setChatDescription(chatId, description) {
|
|
2520
|
-
await
|
|
2639
|
+
await this.#chatManager.setChatDescription(chatId, description);
|
|
2521
2640
|
}
|
|
2522
2641
|
/**
|
|
2523
2642
|
* Hide the member list of a group to non-admins. User-only.
|
|
@@ -2526,7 +2645,7 @@ export class Client extends Composer {
|
|
|
2526
2645
|
* @param chatId The identifier of the group.
|
|
2527
2646
|
*/
|
|
2528
2647
|
async hideMemberList(chatId) {
|
|
2529
|
-
await
|
|
2648
|
+
await this.#chatManager.hideMemberList(chatId);
|
|
2530
2649
|
}
|
|
2531
2650
|
/**
|
|
2532
2651
|
* Show the member list of a group to non-admins. User-only.
|
|
@@ -2535,7 +2654,7 @@ export class Client extends Composer {
|
|
|
2535
2654
|
* @param chatId The identifier of the group.
|
|
2536
2655
|
*/
|
|
2537
2656
|
async showMemberList(chatId) {
|
|
2538
|
-
await
|
|
2657
|
+
await this.#chatManager.showMemberList(chatId);
|
|
2539
2658
|
}
|
|
2540
2659
|
/**
|
|
2541
2660
|
* Enable topics in a group. User-only.
|
|
@@ -2545,7 +2664,7 @@ export class Client extends Composer {
|
|
|
2545
2664
|
* @param isShownAsTabs Whether topics should be displayed as tabs.
|
|
2546
2665
|
*/
|
|
2547
2666
|
async enableTopics(chatId, isShownAsTabs) {
|
|
2548
|
-
await
|
|
2667
|
+
await this.#chatManager.enableTopics(chatId, isShownAsTabs);
|
|
2549
2668
|
}
|
|
2550
2669
|
/**
|
|
2551
2670
|
* Disable topics in a group. User-only.
|
|
@@ -2554,7 +2673,7 @@ export class Client extends Composer {
|
|
|
2554
2673
|
* @param chatId The identifier of the group.
|
|
2555
2674
|
*/
|
|
2556
2675
|
async disableTopics(chatId) {
|
|
2557
|
-
await
|
|
2676
|
+
await this.#chatManager.disableTopics(chatId);
|
|
2558
2677
|
}
|
|
2559
2678
|
/**
|
|
2560
2679
|
* Enable automatic anti-spam in a group. User-only.
|
|
@@ -2563,7 +2682,7 @@ export class Client extends Composer {
|
|
|
2563
2682
|
* @param chatId The identifier of the group.
|
|
2564
2683
|
*/
|
|
2565
2684
|
async enableAntispam(chatId) {
|
|
2566
|
-
await
|
|
2685
|
+
await this.#chatManager.enableAntispam(chatId);
|
|
2567
2686
|
}
|
|
2568
2687
|
/**
|
|
2569
2688
|
* Disable automatic anti-spam in a group. User-only.
|
|
@@ -2572,7 +2691,7 @@ export class Client extends Composer {
|
|
|
2572
2691
|
* @param chatId The identifier of the group.
|
|
2573
2692
|
*/
|
|
2574
2693
|
async disableAntispam(chatId) {
|
|
2575
|
-
await
|
|
2694
|
+
await this.#chatManager.disableAntispam(chatId);
|
|
2576
2695
|
}
|
|
2577
2696
|
/**
|
|
2578
2697
|
* Enable post signatures in a channel. User-only.
|
|
@@ -2581,7 +2700,7 @@ export class Client extends Composer {
|
|
|
2581
2700
|
* @param chatId The identifier of the channel.
|
|
2582
2701
|
*/
|
|
2583
2702
|
async enableSignatures(chatId, params) {
|
|
2584
|
-
await
|
|
2703
|
+
await this.#chatManager.enableSignatures(chatId, params);
|
|
2585
2704
|
}
|
|
2586
2705
|
/**
|
|
2587
2706
|
* Disable post signatures in a channel. User-only.
|
|
@@ -2590,7 +2709,7 @@ export class Client extends Composer {
|
|
|
2590
2709
|
* @param chatId The identifier of the channel.
|
|
2591
2710
|
*/
|
|
2592
2711
|
async disableSignatures(chatId) {
|
|
2593
|
-
await
|
|
2712
|
+
await this.#chatManager.disableSignatures(chatId);
|
|
2594
2713
|
}
|
|
2595
2714
|
/**
|
|
2596
2715
|
* Delete a chat. User-only.
|
|
@@ -2599,7 +2718,7 @@ export class Client extends Composer {
|
|
|
2599
2718
|
* @param chatId The identifier of a chat.
|
|
2600
2719
|
*/
|
|
2601
2720
|
async deleteChat(chatId) {
|
|
2602
|
-
await
|
|
2721
|
+
await this.#chatManager.deleteChat(chatId);
|
|
2603
2722
|
}
|
|
2604
2723
|
/**
|
|
2605
2724
|
* Get discussion chat suggestions. User-only.
|
|
@@ -2607,7 +2726,7 @@ export class Client extends Composer {
|
|
|
2607
2726
|
* @method ch
|
|
2608
2727
|
*/
|
|
2609
2728
|
async getDiscussionChatSuggestions() {
|
|
2610
|
-
return await
|
|
2729
|
+
return await this.#chatManager.getDiscussionChatSuggestions();
|
|
2611
2730
|
}
|
|
2612
2731
|
/**
|
|
2613
2732
|
* Set a channel's discussion chat. User-only.
|
|
@@ -2617,7 +2736,7 @@ export class Client extends Composer {
|
|
|
2617
2736
|
* @param discussionChatId The identifier of a chat to use as discussion for the channel.
|
|
2618
2737
|
*/
|
|
2619
2738
|
async setDiscussionChat(chatId, discussionChatId) {
|
|
2620
|
-
await
|
|
2739
|
+
await this.#chatManager.setDiscussionChat(chatId, discussionChatId);
|
|
2621
2740
|
}
|
|
2622
2741
|
/**
|
|
2623
2742
|
* Transfer the ownership of a chat. User-only.
|
|
@@ -2628,7 +2747,7 @@ export class Client extends Composer {
|
|
|
2628
2747
|
* @param password The password of the current account.
|
|
2629
2748
|
*/
|
|
2630
2749
|
async transferChatOwnership(chatId, userId, password) {
|
|
2631
|
-
await
|
|
2750
|
+
await this.#chatManager.transferChatOwnership(chatId, userId, password);
|
|
2632
2751
|
}
|
|
2633
2752
|
/**
|
|
2634
2753
|
* Create a forum topic.
|
|
@@ -2639,7 +2758,7 @@ export class Client extends Composer {
|
|
|
2639
2758
|
* @returns The created topic.
|
|
2640
2759
|
*/
|
|
2641
2760
|
async createTopic(chatId, title, params) {
|
|
2642
|
-
return await
|
|
2761
|
+
return await this.#forumManager.createTopic(chatId, title, params);
|
|
2643
2762
|
}
|
|
2644
2763
|
/**
|
|
2645
2764
|
* Edit a forum topic.
|
|
@@ -2651,7 +2770,7 @@ export class Client extends Composer {
|
|
|
2651
2770
|
* @returns The new topic.
|
|
2652
2771
|
*/
|
|
2653
2772
|
async editTopic(chatId, topicId, title, params) {
|
|
2654
|
-
return await
|
|
2773
|
+
return await this.#forumManager.editTopic(chatId, topicId, title, params);
|
|
2655
2774
|
}
|
|
2656
2775
|
/**
|
|
2657
2776
|
* Hide the general forum topic.
|
|
@@ -2660,7 +2779,7 @@ export class Client extends Composer {
|
|
|
2660
2779
|
* @param chatId The identifier of a chat.
|
|
2661
2780
|
*/
|
|
2662
2781
|
async hideGeneralTopic(chatId) {
|
|
2663
|
-
await
|
|
2782
|
+
await this.#forumManager.hideGeneralTopic(chatId);
|
|
2664
2783
|
}
|
|
2665
2784
|
/**
|
|
2666
2785
|
* Show the general forum topic.
|
|
@@ -2669,7 +2788,7 @@ export class Client extends Composer {
|
|
|
2669
2788
|
* @param chatId The identifier of a chat.
|
|
2670
2789
|
*/
|
|
2671
2790
|
async showGeneralTopic(chatId) {
|
|
2672
|
-
await
|
|
2791
|
+
await this.#forumManager.showGeneralTopic(chatId);
|
|
2673
2792
|
}
|
|
2674
2793
|
/**
|
|
2675
2794
|
* Close a forum topic.
|
|
@@ -2679,7 +2798,7 @@ export class Client extends Composer {
|
|
|
2679
2798
|
* @param topicId The identifier of the topic.
|
|
2680
2799
|
*/
|
|
2681
2800
|
async closeTopic(chatId, topicId) {
|
|
2682
|
-
await
|
|
2801
|
+
await this.#forumManager.closeTopic(chatId, topicId);
|
|
2683
2802
|
}
|
|
2684
2803
|
/**
|
|
2685
2804
|
* Reopen a forum topic.
|
|
@@ -2689,7 +2808,7 @@ export class Client extends Composer {
|
|
|
2689
2808
|
* @param topicId The identifier of the topic.
|
|
2690
2809
|
*/
|
|
2691
2810
|
async reopenTopic(chatId, topicId) {
|
|
2692
|
-
await
|
|
2811
|
+
await this.#forumManager.reopenTopic(chatId, topicId);
|
|
2693
2812
|
}
|
|
2694
2813
|
/**
|
|
2695
2814
|
* Pin a forum topic.
|
|
@@ -2699,7 +2818,7 @@ export class Client extends Composer {
|
|
|
2699
2818
|
* @param topicId The identifier of the topic.
|
|
2700
2819
|
*/
|
|
2701
2820
|
async pinTopic(chatId, topicId) {
|
|
2702
|
-
await
|
|
2821
|
+
await this.#forumManager.pinTopic(chatId, topicId);
|
|
2703
2822
|
}
|
|
2704
2823
|
/**
|
|
2705
2824
|
* Unpin a forum topic.
|
|
@@ -2709,7 +2828,7 @@ export class Client extends Composer {
|
|
|
2709
2828
|
* @param topicId The identifier of the topic.
|
|
2710
2829
|
*/
|
|
2711
2830
|
async unpinTopic(chatId, topicId) {
|
|
2712
|
-
await
|
|
2831
|
+
await this.#forumManager.unpinTopic(chatId, topicId);
|
|
2713
2832
|
}
|
|
2714
2833
|
/**
|
|
2715
2834
|
* Promote a chat member.
|
|
@@ -2719,7 +2838,7 @@ export class Client extends Composer {
|
|
|
2719
2838
|
* @param userId The identifier of the user to promote.
|
|
2720
2839
|
*/
|
|
2721
2840
|
async promoteChatMember(chatId, userId, params) {
|
|
2722
|
-
await
|
|
2841
|
+
await this.#chatManager.promoteChatMember(chatId, userId, params);
|
|
2723
2842
|
}
|
|
2724
2843
|
/**
|
|
2725
2844
|
* Change the tag of a chat member.
|
|
@@ -2729,7 +2848,7 @@ export class Client extends Composer {
|
|
|
2729
2848
|
* @param userId The identifier of the user that is a member of the chat.
|
|
2730
2849
|
*/
|
|
2731
2850
|
async setChatMemberTag(chatId, userId, params) {
|
|
2732
|
-
await
|
|
2851
|
+
await this.#chatManager.setChatMemberTag(chatId, userId, params);
|
|
2733
2852
|
}
|
|
2734
2853
|
/**
|
|
2735
2854
|
* Enable sharing in a chat. User-only.
|
|
@@ -2738,7 +2857,7 @@ export class Client extends Composer {
|
|
|
2738
2857
|
* @param chatId The identifier of a chat.
|
|
2739
2858
|
*/
|
|
2740
2859
|
async enableSharing(chatId) {
|
|
2741
|
-
await
|
|
2860
|
+
await this.#chatManager.enableSharing(chatId);
|
|
2742
2861
|
}
|
|
2743
2862
|
/**
|
|
2744
2863
|
* Disable sharing in a chat. User-only.
|
|
@@ -2747,7 +2866,7 @@ export class Client extends Composer {
|
|
|
2747
2866
|
* @param chatId The identifier of a chat.
|
|
2748
2867
|
*/
|
|
2749
2868
|
async disableSharing(chatId) {
|
|
2750
|
-
await
|
|
2869
|
+
await this.#chatManager.disableSharing(chatId);
|
|
2751
2870
|
}
|
|
2752
2871
|
/**
|
|
2753
2872
|
* Get recommended channels. User-only.
|
|
@@ -2756,7 +2875,7 @@ export class Client extends Composer {
|
|
|
2756
2875
|
* @returns A list of recommended channels.
|
|
2757
2876
|
*/
|
|
2758
2877
|
async getRecommendedChannels() {
|
|
2759
|
-
return await
|
|
2878
|
+
return await this.#chatManager.getRecommendedChannels();
|
|
2760
2879
|
}
|
|
2761
2880
|
/**
|
|
2762
2881
|
* Get similar channels. User-only.
|
|
@@ -2766,7 +2885,7 @@ export class Client extends Composer {
|
|
|
2766
2885
|
* @returns A list of similar channels.
|
|
2767
2886
|
*/
|
|
2768
2887
|
async getSimilarChannels(chatId) {
|
|
2769
|
-
return await
|
|
2888
|
+
return await this.#chatManager.getSimilarChannels(chatId);
|
|
2770
2889
|
}
|
|
2771
2890
|
/**
|
|
2772
2891
|
* Get similar bots. User-only.
|
|
@@ -2776,7 +2895,7 @@ export class Client extends Composer {
|
|
|
2776
2895
|
* @returns A list of similar bots.
|
|
2777
2896
|
*/
|
|
2778
2897
|
async getSimilarBots(chatId) {
|
|
2779
|
-
return await
|
|
2898
|
+
return await this.#chatManager.getSimilarBots(chatId);
|
|
2780
2899
|
}
|
|
2781
2900
|
//
|
|
2782
2901
|
// ========================= CALLBACK QUERIES ========================= //
|
|
@@ -2792,7 +2911,7 @@ export class Client extends Composer {
|
|
|
2792
2911
|
* @cache
|
|
2793
2912
|
*/
|
|
2794
2913
|
async sendCallbackQuery(botId, messageId, question) {
|
|
2795
|
-
return await
|
|
2914
|
+
return await this.#callbackQueryManager.sendCallbackQuery(botId, messageId, question);
|
|
2796
2915
|
}
|
|
2797
2916
|
/**
|
|
2798
2917
|
* Answer a callback query. Bot-only.
|
|
@@ -2801,7 +2920,7 @@ export class Client extends Composer {
|
|
|
2801
2920
|
* @param id ID of the callback query to answer.
|
|
2802
2921
|
*/
|
|
2803
2922
|
async answerCallbackQuery(id, params) {
|
|
2804
|
-
await
|
|
2923
|
+
await this.#callbackQueryManager.answerCallbackQuery(id, params);
|
|
2805
2924
|
}
|
|
2806
2925
|
//
|
|
2807
2926
|
// ========================= INLINE QUERIES ========================= //
|
|
@@ -2816,7 +2935,7 @@ export class Client extends Composer {
|
|
|
2816
2935
|
* @cache
|
|
2817
2936
|
*/
|
|
2818
2937
|
async sendInlineQuery(botId, chatId, params) {
|
|
2819
|
-
return await
|
|
2938
|
+
return await this.#inlineQueryManager.sendInlineQuery(botId, chatId, params);
|
|
2820
2939
|
}
|
|
2821
2940
|
/**
|
|
2822
2941
|
* Answer an inline query. Bot-only.
|
|
@@ -2826,7 +2945,7 @@ export class Client extends Composer {
|
|
|
2826
2945
|
* @param results The results to answer with.
|
|
2827
2946
|
*/
|
|
2828
2947
|
async answerInlineQuery(id, results, params) {
|
|
2829
|
-
await
|
|
2948
|
+
await this.#inlineQueryManager.answerInlineQuery(id, results, params);
|
|
2830
2949
|
}
|
|
2831
2950
|
//
|
|
2832
2951
|
// ========================= BOTS ========================= //
|
|
@@ -2837,7 +2956,7 @@ export class Client extends Composer {
|
|
|
2837
2956
|
* @method bs
|
|
2838
2957
|
*/
|
|
2839
2958
|
async setMyDescription(params) {
|
|
2840
|
-
await
|
|
2959
|
+
await this.#botInfoManager.setMyDescription(params);
|
|
2841
2960
|
}
|
|
2842
2961
|
/**
|
|
2843
2962
|
* Set the bot's name in the given language. Bot-only.
|
|
@@ -2845,7 +2964,7 @@ export class Client extends Composer {
|
|
|
2845
2964
|
* @method bs
|
|
2846
2965
|
*/
|
|
2847
2966
|
async setMyName(params) {
|
|
2848
|
-
await
|
|
2967
|
+
await this.#botInfoManager.setMyName(params);
|
|
2849
2968
|
}
|
|
2850
2969
|
/**
|
|
2851
2970
|
* Set the bot's short description in the given language. Bot-only.
|
|
@@ -2853,7 +2972,7 @@ export class Client extends Composer {
|
|
|
2853
2972
|
* @method bs
|
|
2854
2973
|
*/
|
|
2855
2974
|
async setMyShortDescription(params) {
|
|
2856
|
-
await
|
|
2975
|
+
await this.#botInfoManager.setMyShortDescription(params);
|
|
2857
2976
|
}
|
|
2858
2977
|
/**
|
|
2859
2978
|
* Get the bot's description in the given language. Bot-only.
|
|
@@ -2862,7 +2981,7 @@ export class Client extends Composer {
|
|
|
2862
2981
|
* @returns The current bot's description in the specified language.
|
|
2863
2982
|
*/
|
|
2864
2983
|
async getMyDescription(params) {
|
|
2865
|
-
return await
|
|
2984
|
+
return await this.#botInfoManager.getMyDescription(params);
|
|
2866
2985
|
}
|
|
2867
2986
|
/**
|
|
2868
2987
|
* Get the bot's name in the given language. Bot-only.
|
|
@@ -2871,7 +2990,7 @@ export class Client extends Composer {
|
|
|
2871
2990
|
* @returns The current bot's name in the specified language.
|
|
2872
2991
|
*/
|
|
2873
2992
|
async getMyName(params) {
|
|
2874
|
-
return await
|
|
2993
|
+
return await this.#botInfoManager.getMyName(params);
|
|
2875
2994
|
}
|
|
2876
2995
|
/**
|
|
2877
2996
|
* Get the bot's short description in the given language. Bot-only.
|
|
@@ -2880,7 +2999,7 @@ export class Client extends Composer {
|
|
|
2880
2999
|
* @returns The current bot's short description in the specified language.
|
|
2881
3000
|
*/
|
|
2882
3001
|
async getMyShortDescription(params) {
|
|
2883
|
-
return await
|
|
3002
|
+
return await this.#botInfoManager.getMyShortDescription(params);
|
|
2884
3003
|
}
|
|
2885
3004
|
/**
|
|
2886
3005
|
* Set the bot's commands in the given scope and/or language. Bot-only.
|
|
@@ -2889,7 +3008,7 @@ export class Client extends Composer {
|
|
|
2889
3008
|
* @param commands The commands to set.
|
|
2890
3009
|
*/
|
|
2891
3010
|
async setMyCommands(commands, params) {
|
|
2892
|
-
await
|
|
3011
|
+
await this.#botInfoManager.setMyCommands(commands, params);
|
|
2893
3012
|
}
|
|
2894
3013
|
/**
|
|
2895
3014
|
* Get the bot's commands in the given scope and/or language. Bot-only.
|
|
@@ -2898,7 +3017,7 @@ export class Client extends Composer {
|
|
|
2898
3017
|
* @returns The current bot's commands in the specified language.
|
|
2899
3018
|
*/
|
|
2900
3019
|
async getMyCommands(params) {
|
|
2901
|
-
return await
|
|
3020
|
+
return await this.#botInfoManager.getMyCommands(params);
|
|
2902
3021
|
}
|
|
2903
3022
|
//
|
|
2904
3023
|
// ========================= REACTIONS ========================= //
|
|
@@ -2912,7 +3031,7 @@ export class Client extends Composer {
|
|
|
2912
3031
|
* @param reactions The new reactions.
|
|
2913
3032
|
*/
|
|
2914
3033
|
async setReactions(chatId, messageId, reactions, params) {
|
|
2915
|
-
await
|
|
3034
|
+
await this.#messageManager.setReactions(chatId, messageId, reactions, params);
|
|
2916
3035
|
}
|
|
2917
3036
|
/**
|
|
2918
3037
|
* Make a reaction to a message.
|
|
@@ -2923,7 +3042,7 @@ export class Client extends Composer {
|
|
|
2923
3042
|
* @param reaction The reaction to add.
|
|
2924
3043
|
*/
|
|
2925
3044
|
async addReaction(chatId, messageId, reaction, params) {
|
|
2926
|
-
await
|
|
3045
|
+
await this.#messageManager.addReaction(chatId, messageId, reaction, params);
|
|
2927
3046
|
}
|
|
2928
3047
|
/**
|
|
2929
3048
|
* Undo a reaction made to a message.
|
|
@@ -2934,7 +3053,7 @@ export class Client extends Composer {
|
|
|
2934
3053
|
* @param reaction The reaction to remove.
|
|
2935
3054
|
*/
|
|
2936
3055
|
async removeReaction(chatId, messageId, reaction) {
|
|
2937
|
-
await
|
|
3056
|
+
await this.#messageManager.removeReaction(chatId, messageId, reaction);
|
|
2938
3057
|
}
|
|
2939
3058
|
//
|
|
2940
3059
|
// ========================= STORIES ========================= //
|
|
@@ -2947,7 +3066,7 @@ export class Client extends Composer {
|
|
|
2947
3066
|
* @returns The created story.
|
|
2948
3067
|
*/
|
|
2949
3068
|
async createStory(chatId, content, params) {
|
|
2950
|
-
return await
|
|
3069
|
+
return await this.#storyManager.createStory(chatId, content, params);
|
|
2951
3070
|
}
|
|
2952
3071
|
/**
|
|
2953
3072
|
* Retrieve multiple stories. User-only.
|
|
@@ -2961,7 +3080,7 @@ export class Client extends Composer {
|
|
|
2961
3080
|
if (!storyIds.length) {
|
|
2962
3081
|
return [];
|
|
2963
3082
|
}
|
|
2964
|
-
return await
|
|
3083
|
+
return await this.#storyManager.getStories(chatId, storyIds);
|
|
2965
3084
|
}
|
|
2966
3085
|
/**
|
|
2967
3086
|
* Retrieve a single story. User-only.
|
|
@@ -2972,7 +3091,7 @@ export class Client extends Composer {
|
|
|
2972
3091
|
* @returns The retrieved story.
|
|
2973
3092
|
*/
|
|
2974
3093
|
async getStory(chatId, storyId) {
|
|
2975
|
-
return await
|
|
3094
|
+
return await this.#storyManager.getStory(chatId, storyId);
|
|
2976
3095
|
}
|
|
2977
3096
|
/**
|
|
2978
3097
|
* Delete multiple stories. User-only.
|
|
@@ -2982,7 +3101,7 @@ export class Client extends Composer {
|
|
|
2982
3101
|
* @param storyIds The identifiers of the stories to delete.
|
|
2983
3102
|
*/
|
|
2984
3103
|
async deleteStories(chatId, storyIds) {
|
|
2985
|
-
await
|
|
3104
|
+
await this.#storyManager.deleteStories(chatId, storyIds);
|
|
2986
3105
|
}
|
|
2987
3106
|
/**
|
|
2988
3107
|
* Delete a single story. User-only.
|
|
@@ -2992,7 +3111,7 @@ export class Client extends Composer {
|
|
|
2992
3111
|
* @param storyId The identifier of the story to delete.
|
|
2993
3112
|
*/
|
|
2994
3113
|
async deleteStory(chatId, storyId) {
|
|
2995
|
-
await
|
|
3114
|
+
await this.#storyManager.deleteStory(chatId, storyId);
|
|
2996
3115
|
}
|
|
2997
3116
|
/**
|
|
2998
3117
|
* Add multiple stories to highlights. User-only.
|
|
@@ -3002,7 +3121,7 @@ export class Client extends Composer {
|
|
|
3002
3121
|
* @param storyIds The identifiers of the stories to add to highlights.
|
|
3003
3122
|
*/
|
|
3004
3123
|
async addStoriesToHighlights(chatId, storyIds) {
|
|
3005
|
-
await
|
|
3124
|
+
await this.#storyManager.addStoriesToHighlights(chatId, storyIds);
|
|
3006
3125
|
}
|
|
3007
3126
|
/**
|
|
3008
3127
|
* Add a single story to highlights. User-only.
|
|
@@ -3012,7 +3131,7 @@ export class Client extends Composer {
|
|
|
3012
3131
|
* @param storyId The identifier of the story to add to highlights.
|
|
3013
3132
|
*/
|
|
3014
3133
|
async addStoryToHighlights(chatId, storyId) {
|
|
3015
|
-
await
|
|
3134
|
+
await this.#storyManager.addStoryToHighlights(chatId, storyId);
|
|
3016
3135
|
}
|
|
3017
3136
|
/**
|
|
3018
3137
|
* Remove multiple stories from highlights. User-only.
|
|
@@ -3022,7 +3141,7 @@ export class Client extends Composer {
|
|
|
3022
3141
|
* @param storyIds The identifiers of the stories to remove from highlights.
|
|
3023
3142
|
*/
|
|
3024
3143
|
async removeStoriesFromHighlights(chatId, storyIds) {
|
|
3025
|
-
await
|
|
3144
|
+
await this.#storyManager.removeStoriesFromHighlights(chatId, storyIds);
|
|
3026
3145
|
}
|
|
3027
3146
|
/**
|
|
3028
3147
|
* Remove a single story from highlights. User-only.
|
|
@@ -3032,7 +3151,7 @@ export class Client extends Composer {
|
|
|
3032
3151
|
* @param storyId The identifier of the story to remove from highlights.
|
|
3033
3152
|
*/
|
|
3034
3153
|
async removeStoryFromHighlights(chatId, storyId) {
|
|
3035
|
-
await
|
|
3154
|
+
await this.#storyManager.removeStoryFromHighlights(chatId, storyId);
|
|
3036
3155
|
}
|
|
3037
3156
|
//
|
|
3038
3157
|
// ========================= MISC ========================= //
|
|
@@ -3043,7 +3162,7 @@ export class Client extends Composer {
|
|
|
3043
3162
|
* @method mc
|
|
3044
3163
|
*/
|
|
3045
3164
|
async getNetworkStatistics() {
|
|
3046
|
-
return await
|
|
3165
|
+
return await this.#networkStatisticsManager.getNetworkStatistics();
|
|
3047
3166
|
}
|
|
3048
3167
|
/**
|
|
3049
3168
|
* Block a user. User-only.
|
|
@@ -3052,7 +3171,7 @@ export class Client extends Composer {
|
|
|
3052
3171
|
* @param userId The identifier of the user to block.
|
|
3053
3172
|
*/
|
|
3054
3173
|
async blockUser(userId) {
|
|
3055
|
-
await
|
|
3174
|
+
await this.#messageManager.blockUser(userId);
|
|
3056
3175
|
}
|
|
3057
3176
|
/**
|
|
3058
3177
|
* Unblock a user. User-only.
|
|
@@ -3061,7 +3180,7 @@ export class Client extends Composer {
|
|
|
3061
3180
|
* @param userId The identifier of the user to unblock.
|
|
3062
3181
|
*/
|
|
3063
3182
|
async unblockUser(userId) {
|
|
3064
|
-
await
|
|
3183
|
+
await this.#messageManager.unblockUser(userId);
|
|
3065
3184
|
}
|
|
3066
3185
|
//
|
|
3067
3186
|
// ========================= VIDEO CHATS ========================= //
|
|
@@ -3074,7 +3193,7 @@ export class Client extends Composer {
|
|
|
3074
3193
|
* @returns The started video chat.
|
|
3075
3194
|
*/
|
|
3076
3195
|
async startVideoChat(chatId, params) {
|
|
3077
|
-
return await
|
|
3196
|
+
return await this.#videoChatManager.startVideoChat(chatId, params);
|
|
3078
3197
|
}
|
|
3079
3198
|
/**
|
|
3080
3199
|
* Schedule a video chat. User-only.
|
|
@@ -3085,7 +3204,7 @@ export class Client extends Composer {
|
|
|
3085
3204
|
* @returns The scheduled video chat.
|
|
3086
3205
|
*/
|
|
3087
3206
|
async scheduleVideoChat(chatId, startAt, params) {
|
|
3088
|
-
return await
|
|
3207
|
+
return await this.#videoChatManager.scheduleVideoChat(chatId, startAt, params);
|
|
3089
3208
|
}
|
|
3090
3209
|
/**
|
|
3091
3210
|
* Join a video chat. User-only.
|
|
@@ -3096,7 +3215,7 @@ export class Client extends Composer {
|
|
|
3096
3215
|
* @returns Parameters to be passed to the used WebRTC library.
|
|
3097
3216
|
*/
|
|
3098
3217
|
async joinVideoChat(id, params_, params) {
|
|
3099
|
-
return await
|
|
3218
|
+
return await this.#videoChatManager.joinVideoChat(id, params_, params);
|
|
3100
3219
|
}
|
|
3101
3220
|
/**
|
|
3102
3221
|
* Leave a video chat. User-only.
|
|
@@ -3105,7 +3224,7 @@ export class Client extends Composer {
|
|
|
3105
3224
|
* @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
|
|
3106
3225
|
*/
|
|
3107
3226
|
async leaveVideoChat(id) {
|
|
3108
|
-
await
|
|
3227
|
+
await this.#videoChatManager.leaveVideoChat(id);
|
|
3109
3228
|
}
|
|
3110
3229
|
/**
|
|
3111
3230
|
* Join a live stream. User-only.
|
|
@@ -3114,7 +3233,7 @@ export class Client extends Composer {
|
|
|
3114
3233
|
* @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
|
|
3115
3234
|
*/
|
|
3116
3235
|
async joinLiveStream(id) {
|
|
3117
|
-
await
|
|
3236
|
+
await this.#videoChatManager.joinLiveStream(id);
|
|
3118
3237
|
}
|
|
3119
3238
|
/**
|
|
3120
3239
|
* Get a video chat. User-only.
|
|
@@ -3124,7 +3243,7 @@ export class Client extends Composer {
|
|
|
3124
3243
|
* @cache
|
|
3125
3244
|
*/
|
|
3126
3245
|
async getVideoChat(id) {
|
|
3127
|
-
return await
|
|
3246
|
+
return await this.#videoChatManager.getVideoChat(id);
|
|
3128
3247
|
}
|
|
3129
3248
|
/**
|
|
3130
3249
|
* Get live stream channels. User-only.
|
|
@@ -3133,7 +3252,7 @@ export class Client extends Composer {
|
|
|
3133
3252
|
* @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
|
|
3134
3253
|
*/
|
|
3135
3254
|
async getLiveStreamChannels(id) {
|
|
3136
|
-
return await
|
|
3255
|
+
return await this.#videoChatManager.getLiveStreamChannels(id);
|
|
3137
3256
|
}
|
|
3138
3257
|
/**
|
|
3139
3258
|
* Download a live stream segment. User-only.
|
|
@@ -3145,7 +3264,7 @@ export class Client extends Composer {
|
|
|
3145
3264
|
* @param timestamp Millisecond timestamp of the chunk to download.
|
|
3146
3265
|
*/
|
|
3147
3266
|
async downloadLiveStreamSegment(id, channelId, scale, timestamp, params) {
|
|
3148
|
-
return await
|
|
3267
|
+
return await this.#videoChatManager.downloadLiveStreamSegment(id, channelId, scale, timestamp, params);
|
|
3149
3268
|
}
|
|
3150
3269
|
//
|
|
3151
3270
|
// ========================= PAYMENTS ========================= //
|
|
@@ -3158,7 +3277,7 @@ export class Client extends Composer {
|
|
|
3158
3277
|
* @param ok Whether the checkout is going to be processed.
|
|
3159
3278
|
*/
|
|
3160
3279
|
async answerPreCheckoutQuery(preCheckoutQueryId, ok, params) {
|
|
3161
|
-
await
|
|
3280
|
+
await this.#paymentManager.answerPreCheckoutQuery(preCheckoutQueryId, ok, params);
|
|
3162
3281
|
}
|
|
3163
3282
|
/**
|
|
3164
3283
|
* Refund a star payment. Bot-only.
|
|
@@ -3168,7 +3287,7 @@ export class Client extends Composer {
|
|
|
3168
3287
|
* @param telegramPaymentChargeId The identifier of the charge.
|
|
3169
3288
|
*/
|
|
3170
3289
|
async refundStarPayment(userId, telegramPaymentChargeId) {
|
|
3171
|
-
await
|
|
3290
|
+
await this.#paymentManager.refundStarPayment(userId, telegramPaymentChargeId);
|
|
3172
3291
|
}
|
|
3173
3292
|
//
|
|
3174
3293
|
// ========================= CONTACTS ========================= //
|
|
@@ -3179,7 +3298,7 @@ export class Client extends Composer {
|
|
|
3179
3298
|
* @method co
|
|
3180
3299
|
*/
|
|
3181
3300
|
async getContacts() {
|
|
3182
|
-
return await
|
|
3301
|
+
return await this.#accountManager.getContacts();
|
|
3183
3302
|
}
|
|
3184
3303
|
/**
|
|
3185
3304
|
* Delete multiple contacts. User-only.
|
|
@@ -3188,7 +3307,7 @@ export class Client extends Composer {
|
|
|
3188
3307
|
* @param userIds The identifiers of contacts to delete.
|
|
3189
3308
|
*/
|
|
3190
3309
|
async deleteContacts(userIds) {
|
|
3191
|
-
await
|
|
3310
|
+
await this.#accountManager.deleteContacts(userIds);
|
|
3192
3311
|
}
|
|
3193
3312
|
/**
|
|
3194
3313
|
* Delete a single contact. User-only.
|
|
@@ -3197,7 +3316,7 @@ export class Client extends Composer {
|
|
|
3197
3316
|
* @param userId The identifier of the contact to delete.
|
|
3198
3317
|
*/
|
|
3199
3318
|
async deleteContact(userId) {
|
|
3200
|
-
await
|
|
3319
|
+
await this.#accountManager.deleteContact(userId);
|
|
3201
3320
|
}
|
|
3202
3321
|
/**
|
|
3203
3322
|
* Add a contact. User-only.
|
|
@@ -3206,7 +3325,7 @@ export class Client extends Composer {
|
|
|
3206
3325
|
* @param userId The identifier of the user to add as contact.
|
|
3207
3326
|
*/
|
|
3208
3327
|
async addContact(userId, params) {
|
|
3209
|
-
await
|
|
3328
|
+
await this.#accountManager.addContact(userId, params);
|
|
3210
3329
|
}
|
|
3211
3330
|
//
|
|
3212
3331
|
// ========================= TRANSLATIONS ========================= //
|
|
@@ -3218,7 +3337,7 @@ export class Client extends Composer {
|
|
|
3218
3337
|
* @cache
|
|
3219
3338
|
*/
|
|
3220
3339
|
async getTranslations(params) {
|
|
3221
|
-
return await
|
|
3340
|
+
return await this.#translationsManager.getTranslations(params);
|
|
3222
3341
|
}
|
|
3223
3342
|
//
|
|
3224
3343
|
// ========================= GIFTS ========================= //
|
|
@@ -3229,7 +3348,7 @@ export class Client extends Composer {
|
|
|
3229
3348
|
* @method gf
|
|
3230
3349
|
*/
|
|
3231
3350
|
async getGifts() {
|
|
3232
|
-
return await
|
|
3351
|
+
return await this.#giftManager.getGifts();
|
|
3233
3352
|
}
|
|
3234
3353
|
/**
|
|
3235
3354
|
* Get gifts claimed by a user or a channel. User-only.
|
|
@@ -3238,7 +3357,7 @@ export class Client extends Composer {
|
|
|
3238
3357
|
* @param chatId The identifier of a user or a channel to get gifts for.
|
|
3239
3358
|
*/
|
|
3240
3359
|
async getClaimedGifts(chatId, params) {
|
|
3241
|
-
return await
|
|
3360
|
+
return await this.#giftManager.getClaimedGifts(chatId, params);
|
|
3242
3361
|
}
|
|
3243
3362
|
/**
|
|
3244
3363
|
* Send a gift.
|
|
@@ -3248,7 +3367,7 @@ export class Client extends Composer {
|
|
|
3248
3367
|
* @param giftId The identifier of the gift to send.
|
|
3249
3368
|
*/
|
|
3250
3369
|
async sendGift(chatId, giftId, params) {
|
|
3251
|
-
await
|
|
3370
|
+
await this.#giftManager.sendGift(chatId, giftId, params);
|
|
3252
3371
|
}
|
|
3253
3372
|
/**
|
|
3254
3373
|
* Sell a gift.
|
|
@@ -3257,7 +3376,7 @@ export class Client extends Composer {
|
|
|
3257
3376
|
* @param gift The gift to sell.
|
|
3258
3377
|
*/
|
|
3259
3378
|
async sellGift(gift) {
|
|
3260
|
-
await
|
|
3379
|
+
await this.#giftManager.sellGift(gift);
|
|
3261
3380
|
}
|
|
3262
3381
|
/**
|
|
3263
3382
|
* Craft gifts.
|
|
@@ -3266,7 +3385,7 @@ export class Client extends Composer {
|
|
|
3266
3385
|
* @param gift The gifts to craft.
|
|
3267
3386
|
*/
|
|
3268
3387
|
async craftGifts(gifts) {
|
|
3269
|
-
await
|
|
3388
|
+
await this.#giftManager.craftGifts(gifts);
|
|
3270
3389
|
}
|
|
3271
3390
|
/**
|
|
3272
3391
|
* Get a gift using its slug.
|
|
@@ -3275,7 +3394,7 @@ export class Client extends Composer {
|
|
|
3275
3394
|
* @param slug The slug of a gift.
|
|
3276
3395
|
*/
|
|
3277
3396
|
async getGift(slug) {
|
|
3278
|
-
return await
|
|
3397
|
+
return await this.#giftManager.getGift(slug);
|
|
3279
3398
|
}
|
|
3280
3399
|
/**
|
|
3281
3400
|
* Transfer a gift. User-only.
|
|
@@ -3285,155 +3404,6 @@ export class Client extends Composer {
|
|
|
3285
3404
|
* @param gift The gift to transfer.
|
|
3286
3405
|
*/
|
|
3287
3406
|
async transferGift(chatId, gift) {
|
|
3288
|
-
return await
|
|
3407
|
+
return await this.#giftManager.transferGift(chatId, gift);
|
|
3289
3408
|
}
|
|
3290
3409
|
}
|
|
3291
|
-
_Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
|
|
3292
|
-
if (__classPrivateFieldGet(this, _Client_disableUpdates, "f") && !("authorizationState" in update) && !("connectionState" in update)) {
|
|
3293
|
-
return;
|
|
3294
|
-
}
|
|
3295
|
-
try {
|
|
3296
|
-
await this.handleUpdate(this, update);
|
|
3297
|
-
}
|
|
3298
|
-
catch (err) {
|
|
3299
|
-
__classPrivateFieldGet(this, _Client_L, "f").error("Failed to handle update:", err);
|
|
3300
|
-
throw err;
|
|
3301
|
-
}
|
|
3302
|
-
}, _Client_queueHandleCtxUpdate = function _Client_queueHandleCtxUpdate(update) {
|
|
3303
|
-
__classPrivateFieldGet(this, _Client_updateManager, "f").getHandleUpdateQueue(UpdateManager.MAIN_BOX_ID).add(async () => {
|
|
3304
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, update);
|
|
3305
|
-
});
|
|
3306
|
-
}, _Client_handleUpdate = async function _Client_handleUpdate(update) {
|
|
3307
|
-
const maybePromises = new Array();
|
|
3308
|
-
if (Api.is("updateUserName", update)) {
|
|
3309
|
-
const value = [Number(update.user_id), new Date()];
|
|
3310
|
-
for (const username_ of update.usernames) {
|
|
3311
|
-
const username = username_.username.toLowerCase();
|
|
3312
|
-
this.messageStorage.usernames.set([username], value);
|
|
3313
|
-
}
|
|
3314
|
-
const peer = { ...update, _: "peerUser" };
|
|
3315
|
-
const peer_ = await this[getPeer](peer);
|
|
3316
|
-
if (peer_ !== null) {
|
|
3317
|
-
const username = update.usernames[0];
|
|
3318
|
-
if (username !== undefined) {
|
|
3319
|
-
peer_[0].username = username.username;
|
|
3320
|
-
const also = update.usernames.filter((v) => v !== username);
|
|
3321
|
-
if (also.length) {
|
|
3322
|
-
peer_[0].also = also.map((v) => v.username);
|
|
3323
|
-
}
|
|
3324
|
-
else {
|
|
3325
|
-
delete peer_[0].also;
|
|
3326
|
-
}
|
|
3327
|
-
}
|
|
3328
|
-
else {
|
|
3329
|
-
delete peer_[0].username;
|
|
3330
|
-
}
|
|
3331
|
-
this.messageStorage.setPeer2(peer_[0], peer_[1]);
|
|
3332
|
-
}
|
|
3333
|
-
}
|
|
3334
|
-
if (__classPrivateFieldGet(this, _Client_messageManager, "f").canHandleUpdate(update)) {
|
|
3335
|
-
maybePromises.push(() => __classPrivateFieldGet(this, _Client_messageManager, "f").handleUpdate(update));
|
|
3336
|
-
}
|
|
3337
|
-
if (__classPrivateFieldGet(this, _Client_chatManager, "f").canHandleUpdate(update)) {
|
|
3338
|
-
maybePromises.push(() => __classPrivateFieldGet(this, _Client_chatManager, "f").handleUpdate(update));
|
|
3339
|
-
}
|
|
3340
|
-
if (__classPrivateFieldGet(this, _Client_pollManager, "f").canHandleUpdate(update)) {
|
|
3341
|
-
maybePromises.push(() => __classPrivateFieldGet(this, _Client_pollManager, "f").handleUpdate(update));
|
|
3342
|
-
}
|
|
3343
|
-
if (__classPrivateFieldGet(this, _Client_videoChatManager, "f").canHandleUpdate(update)) {
|
|
3344
|
-
maybePromises.push(() => __classPrivateFieldGet(this, _Client_videoChatManager, "f").handleUpdate(update));
|
|
3345
|
-
}
|
|
3346
|
-
if (__classPrivateFieldGet(this, _Client_callbackQueryManager, "f").canHandleUpdate(update)) {
|
|
3347
|
-
maybePromises.push(() => __classPrivateFieldGet(this, _Client_callbackQueryManager, "f").handleUpdate(update));
|
|
3348
|
-
}
|
|
3349
|
-
if (__classPrivateFieldGet(this, _Client_inlineQueryManager, "f").canHandleUpdate(update)) {
|
|
3350
|
-
maybePromises.push(() => __classPrivateFieldGet(this, _Client_inlineQueryManager, "f").handleUpdate(update));
|
|
3351
|
-
}
|
|
3352
|
-
if (__classPrivateFieldGet(this, _Client_linkPreviewManager, "f").canHandleUpdate(update)) {
|
|
3353
|
-
maybePromises.push(() => __classPrivateFieldGet(this, _Client_linkPreviewManager, "f").handleUpdate(update));
|
|
3354
|
-
}
|
|
3355
|
-
if (__classPrivateFieldGet(this, _Client_reactionManager, "f").canHandleUpdate(update)) {
|
|
3356
|
-
maybePromises.push(() => __classPrivateFieldGet(this, _Client_reactionManager, "f").handleUpdate(update));
|
|
3357
|
-
}
|
|
3358
|
-
if (__classPrivateFieldGet(this, _Client_chatListManager, "f").canHandleUpdate(update)) {
|
|
3359
|
-
maybePromises.push(() => __classPrivateFieldGet(this, _Client_chatListManager, "f").handleUpdate(update));
|
|
3360
|
-
}
|
|
3361
|
-
if (__classPrivateFieldGet(this, _Client_storyManager, "f").canHandleUpdate(update)) {
|
|
3362
|
-
maybePromises.push(() => __classPrivateFieldGet(this, _Client_storyManager, "f").handleUpdate(update));
|
|
3363
|
-
}
|
|
3364
|
-
if (__classPrivateFieldGet(this, _Client_businessConnectionManager, "f").canHandleUpdate(update)) {
|
|
3365
|
-
maybePromises.push(() => __classPrivateFieldGet(this, _Client_businessConnectionManager, "f").handleUpdate(update));
|
|
3366
|
-
}
|
|
3367
|
-
if (__classPrivateFieldGet(this, _Client_storyManager, "f").canHandleUpdate(update)) {
|
|
3368
|
-
maybePromises.push(() => __classPrivateFieldGet(this, _Client_storyManager, "f").handleUpdate(update));
|
|
3369
|
-
}
|
|
3370
|
-
if (__classPrivateFieldGet(this, _Client_paymentManager, "f").canHandleUpdate(update)) {
|
|
3371
|
-
maybePromises.push(() => __classPrivateFieldGet(this, _Client_paymentManager, "f").handleUpdate(update));
|
|
3372
|
-
}
|
|
3373
|
-
if (__classPrivateFieldGet(this, _Client_translationsManager, "f").canHandleUpdate(update)) {
|
|
3374
|
-
maybePromises.push(() => __classPrivateFieldGet(this, _Client_translationsManager, "f").handleUpdate(update));
|
|
3375
|
-
}
|
|
3376
|
-
if (__classPrivateFieldGet(this, _Client_botInfoManager, "f").canHandleUpdate(update)) {
|
|
3377
|
-
maybePromises.push(() => __classPrivateFieldGet(this, _Client_botInfoManager, "f").handleUpdate(update));
|
|
3378
|
-
}
|
|
3379
|
-
if (__classPrivateFieldGet(this, _Client_accountManager, "f").canHandleUpdate(update)) {
|
|
3380
|
-
maybePromises.push(() => __classPrivateFieldGet(this, _Client_accountManager, "f").handleUpdate(update));
|
|
3381
|
-
}
|
|
3382
|
-
return () => Promise.resolve().then(async () => {
|
|
3383
|
-
const updates = [{ update }];
|
|
3384
|
-
for (const maybePromise of maybePromises) {
|
|
3385
|
-
try {
|
|
3386
|
-
const value = maybePromise();
|
|
3387
|
-
const update = value instanceof Promise ? await value : value;
|
|
3388
|
-
if (update) {
|
|
3389
|
-
updates.push(update);
|
|
3390
|
-
}
|
|
3391
|
-
}
|
|
3392
|
-
catch (err) {
|
|
3393
|
-
__classPrivateFieldGet(this, _Client_L, "f").error("failed to construct update:", err);
|
|
3394
|
-
}
|
|
3395
|
-
}
|
|
3396
|
-
for (const update of updates) {
|
|
3397
|
-
try {
|
|
3398
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, update);
|
|
3399
|
-
}
|
|
3400
|
-
finally {
|
|
3401
|
-
if ("deletedMessages" in update) {
|
|
3402
|
-
for (const { chatId, messageId } of update.deletedMessages) {
|
|
3403
|
-
await this.messageStorage.setMessage(chatId, messageId, null);
|
|
3404
|
-
}
|
|
3405
|
-
}
|
|
3406
|
-
}
|
|
3407
|
-
}
|
|
3408
|
-
});
|
|
3409
|
-
}, _Client_getMe = async function _Client_getMe() {
|
|
3410
|
-
if (__classPrivateFieldGet(this, _Client_lastGetMe, "f") !== null) {
|
|
3411
|
-
return __classPrivateFieldGet(this, _Client_lastGetMe, "f");
|
|
3412
|
-
}
|
|
3413
|
-
else {
|
|
3414
|
-
const user = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMeInner).call(this);
|
|
3415
|
-
__classPrivateFieldSet(this, _Client_lastGetMe, user, "f");
|
|
3416
|
-
return user;
|
|
3417
|
-
}
|
|
3418
|
-
}, _Client_getMeInner = async function _Client_getMeInner() {
|
|
3419
|
-
let chatP = (await this[getPeer]({ _: "peerUser", user_id: BigInt(await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).call(this)) }))?.[0] ?? null;
|
|
3420
|
-
if (chatP === null) {
|
|
3421
|
-
const users = await this.invoke({ _: "users.getUsers", id: [{ _: "inputUserSelf" }] });
|
|
3422
|
-
chatP = constructChatP(Api.as("user", users[0]));
|
|
3423
|
-
await this.storage.setIsPremium(chatP.isPremium);
|
|
3424
|
-
}
|
|
3425
|
-
const user = constructUser2(chatP);
|
|
3426
|
-
__classPrivateFieldSet(this, _Client_lastGetMe, user, "f");
|
|
3427
|
-
return user;
|
|
3428
|
-
}, _Client_onConnectionStateChange = function _Client_onConnectionStateChange(isConnected) {
|
|
3429
|
-
if (__classPrivateFieldGet(this, _Client_lastConnectionState, "f") !== isConnected) {
|
|
3430
|
-
if (isConnected) {
|
|
3431
|
-
if (__classPrivateFieldGet(this, _Client_previouslyConnected, "f")) {
|
|
3432
|
-
drop(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("reconnect"));
|
|
3433
|
-
}
|
|
3434
|
-
__classPrivateFieldSet(this, _Client_previouslyConnected, true, "f");
|
|
3435
|
-
}
|
|
3436
|
-
const connectionState = isConnected ? "ready" : "notConnected";
|
|
3437
|
-
__classPrivateFieldGet(this, _Client_instances, "m", _Client_queueHandleCtxUpdate).call(this, { connectionState });
|
|
3438
|
-
}
|
|
3439
|
-
};
|