@mtkruto/node 0.1.129 → 0.1.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/0_deps.d.ts +1 -0
- package/esm/0_deps.js +9 -0
- package/esm/4_constants.d.ts +1 -1
- package/esm/4_constants.js +1 -1
- package/esm/client/5_client.d.ts +17 -3
- package/esm/client/5_client.js +229 -73
- package/esm/deps/deno.land/std@0.209.0/media_types/extension.d.ts +17 -0
- package/esm/deps/deno.land/std@0.209.0/media_types/extension.js +26 -0
- package/esm/deps/deno.land/std@0.209.0/media_types/extensions_by_type.d.ts +20 -0
- package/esm/deps/deno.land/std@0.209.0/media_types/extensions_by_type.js +31 -0
- package/esm/storage/0_storage.d.ts +3 -1
- package/esm/storage/0_storage.js +18 -5
- package/esm/tl/0_tl_raw_reader.js +1 -1
- package/esm/tl/3_utilities.d.ts +1 -0
- package/esm/tl/3_utilities.js +11 -0
- package/esm/types/1__getters.d.ts +1 -0
- package/esm/types/1_sticker.js +5 -4
- package/esm/types/4_chat.d.ts +3 -2
- package/esm/types/4_chat.js +16 -27
- package/package.json +1 -1
- package/script/0_deps.d.ts +1 -0
- package/script/0_deps.js +11 -1
- package/script/4_constants.d.ts +1 -1
- package/script/4_constants.js +1 -1
- package/script/client/5_client.d.ts +17 -3
- package/script/client/5_client.js +226 -70
- package/script/deps/deno.land/std@0.209.0/media_types/extension.d.ts +17 -0
- package/script/deps/deno.land/std@0.209.0/media_types/extension.js +30 -0
- package/script/deps/deno.land/std@0.209.0/media_types/extensions_by_type.d.ts +20 -0
- package/script/deps/deno.land/std@0.209.0/media_types/extensions_by_type.js +35 -0
- package/script/storage/0_storage.d.ts +3 -1
- package/script/storage/0_storage.js +18 -5
- package/script/tl/0_tl_raw_reader.js +1 -1
- package/script/tl/3_utilities.d.ts +1 -0
- package/script/tl/3_utilities.js +13 -1
- package/script/types/1__getters.d.ts +1 -0
- package/script/types/1_sticker.js +4 -3
- package/script/types/4_chat.d.ts +3 -2
- package/script/types/4_chat.js +17 -27
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _Client_instances, _a, _Client_auth, _Client_sessionId, _Client_state, _Client_promises, _Client_toAcknowledge, _Client_updateState, _Client_publicKeys, _Client_autoStart, _Client_ignoreOutgoing, _Client_prefixes, _Client_namespaceProxies, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_storageInited, _Client_setAuth, _Client_authKeyWasCreated, _Client_connectMutex, _Client_assertUser, _Client_assertBot, _Client_fetchState, _Client_connectionInited, _Client_initConnection, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_selfId, _Client_getSelfId, _Client_receiveLoop, _Client_pingLoopAbortSignal, _Client_pingInterval, _Client_pingLoop, _Client_pingLoopStarted, _Client_autoStarted, _Client_lastMsgId, _Client_invoke, _Client_handleInvokeError, _Client_processChats, _Client_processUsers, _Client_handleUpdateQueue, _Client_processUpdatesQueue, _Client_checkGap, _Client_checkChannelGap, _Client_lastUpdates, _Client_processUpdates, _Client_setUpdateStateDate, _Client_setUpdatePts, _Client_getLocalState, _Client_recoverUpdateGap, _Client_recoverChannelUpdateGap, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_updatesToMessages, _Client_resolveSendAs, _Client_parseText, _Client_getMessagesInner, _Client_downloadInner, _Client_lastGetMe, _Client_getMe, _Client_handleUpdate, _Client_usernameResolver, _Client_constructReplyMarkup, _Client_assertMsgHas, _Client_handle, _Client_setMyInfo, _Client_getMyInfo, _Client_resolveFileId, _Client_sendMedia, _Client_sendChatUpdate, _Client_reassignChatLastMessage, _Client_chats, _Client_archivedChats, _Client_chatsLoadedFromStorage, _Client_getChatAnywhere, _Client_getChatList, _Client_loadChatsFromStorage, _Client_getLoadedChats, _Client_pinnedChats, _Client_pinnedArchiveChats, _Client_storageHadPinnedChats, _Client_pinnedChatsLoaded, _Client_loadPinnedChats, _Client_fetchPinnedChats, _Client_getPinnedChats, _Client_updateOrAddChat, _Client_removeChat, _Client_updatePinnedChats, _Client_fetchChats;
|
|
13
|
+
var _Client_instances, _a, _Client_auth, _Client_sessionId, _Client_state, _Client_promises, _Client_toAcknowledge, _Client_updateState, _Client_publicKeys, _Client_autoStart, _Client_ignoreOutgoing, _Client_prefixes, _Client_namespaceProxies, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_storageInited, _Client_setAuth, _Client_authKeyWasCreated, _Client_connectMutex, _Client_assertUser, _Client_assertBot, _Client_fetchState, _Client_connectionInited, _Client_initConnection, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_selfId, _Client_getSelfId, _Client_receiveLoop, _Client_pingLoopAbortSignal, _Client_pingInterval, _Client_pingLoop, _Client_pingLoopStarted, _Client_autoStarted, _Client_lastMsgId, _Client_invoke, _Client_handleInvokeError, _Client_processChats, _Client_processUsers, _Client_handleUpdateQueue, _Client_processUpdatesQueue, _Client_checkGap, _Client_checkChannelGap, _Client_lastUpdates, _Client_processUpdates, _Client_setUpdateStateDate, _Client_setUpdatePts, _Client_getLocalState, _Client_recoverUpdateGap, _Client_recoverChannelUpdateGap, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_updatesToMessages, _Client_resolveSendAs, _Client_parseText, _Client_getMessagesInner, _Client_downloadInner, _Client_lastGetMe, _Client_getMe, _Client_handleUpdate, _Client_usernameResolver, _Client_constructReplyMarkup, _Client_assertMsgHas, _Client_handle, _Client_setMyInfo, _Client_getMyInfo, _Client_resolveFileId, _Client_sendMedia, _Client_sendChatUpdate, _Client_reassignChatLastMessage, _Client_chats, _Client_archivedChats, _Client_chatsLoadedFromStorage, _Client_tryGetChatId, _Client_getChatAnywhere, _Client_getChatList, _Client_loadChatsFromStorage, _Client_getLoadedChats, _Client_pinnedChats, _Client_pinnedArchiveChats, _Client_storageHadPinnedChats, _Client_pinnedChatsLoaded, _Client_loadPinnedChats, _Client_fetchPinnedChats, _Client_getPinnedChats, _Client_updateOrAddChat, _Client_removeChat, _Client_updatePinnedChats, _Client_fetchChats;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.Client = exports.ConnectionError = exports.restartAuth = exports.skipInvoke = exports.handleMigrationError = void 0;
|
|
16
16
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
@@ -522,7 +522,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
522
522
|
throw new Error(`${source}: not a bot client`);
|
|
523
523
|
}
|
|
524
524
|
}, _Client_fetchState = async function _Client_fetchState(source) {
|
|
525
|
-
const state = await this.
|
|
525
|
+
const state = await this.api.updates.getState();
|
|
526
526
|
__classPrivateFieldSet(this, _Client_updateState, state, "f");
|
|
527
527
|
d("state fetched [%s]", source);
|
|
528
528
|
}, exports.handleMigrationError)](err) {
|
|
@@ -588,7 +588,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
588
588
|
if (typeof params === "string") {
|
|
589
589
|
while (true) {
|
|
590
590
|
try {
|
|
591
|
-
const auth = await this.
|
|
591
|
+
const auth = await this.api.auth.importBotAuthorization({ api_id: this.apiId, api_hash: this.apiHash, bot_auth_token: params, flags: 0 });
|
|
592
592
|
__classPrivateFieldSet(this, _Client_selfId, Number(auth[_2_tl_js_1.as](_2_tl_js_1.types.auth.Authorization).user.id), "f");
|
|
593
593
|
await this.storage.setAccountType("bot");
|
|
594
594
|
break;
|
|
@@ -610,7 +610,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
610
610
|
return;
|
|
611
611
|
}
|
|
612
612
|
if (params instanceof _2_tl_js_1.types.auth.ExportedAuthorization) {
|
|
613
|
-
await this.
|
|
613
|
+
await this.api.auth.importAuthorization({ id: params.id, bytes: params.bytes });
|
|
614
614
|
dAuth("authorization imported");
|
|
615
615
|
return;
|
|
616
616
|
}
|
|
@@ -621,12 +621,12 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
621
621
|
while (true) {
|
|
622
622
|
try {
|
|
623
623
|
phone = typeof params.phone === "string" ? params.phone : await params.phone();
|
|
624
|
-
const sendCode = () => this.
|
|
624
|
+
const sendCode = () => this.api.auth.sendCode({
|
|
625
625
|
phone_number: phone,
|
|
626
626
|
api_id: this.apiId,
|
|
627
627
|
api_hash: this.apiHash,
|
|
628
628
|
settings: new _2_tl_js_1.types.CodeSettings(),
|
|
629
|
-
})
|
|
629
|
+
}).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.auth.SentCode));
|
|
630
630
|
try {
|
|
631
631
|
sentCode = await sendCode();
|
|
632
632
|
}
|
|
@@ -656,11 +656,11 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
656
656
|
code: while (true) {
|
|
657
657
|
const code = typeof params.code === "string" ? params.code : await params.code();
|
|
658
658
|
try {
|
|
659
|
-
const auth = await this.
|
|
659
|
+
const auth = await this.api.auth.signIn({
|
|
660
660
|
phone_number: phone,
|
|
661
661
|
phone_code: code,
|
|
662
662
|
phone_code_hash: sentCode.phone_code_hash,
|
|
663
|
-
})
|
|
663
|
+
});
|
|
664
664
|
__classPrivateFieldSet(this, _Client_selfId, Number(auth[_2_tl_js_1.as](_2_tl_js_1.types.auth.Authorization).user.id), "f");
|
|
665
665
|
await this.storage.setAccountType("user");
|
|
666
666
|
dAuth("authorized as user");
|
|
@@ -682,14 +682,14 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
682
682
|
throw err;
|
|
683
683
|
}
|
|
684
684
|
password: while (true) {
|
|
685
|
-
const ap = await this.
|
|
685
|
+
const ap = await this.api.account.getPassword();
|
|
686
686
|
if (!(ap.current_algo instanceof _2_tl_js_1.types.PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow)) {
|
|
687
687
|
throw new Error(`Handling ${ap.current_algo?.[_2_tl_js_1.name]} not implemented`);
|
|
688
688
|
}
|
|
689
689
|
try {
|
|
690
690
|
const password = typeof params.password === "string" ? params.password : await params.password(ap.hint ?? null);
|
|
691
691
|
const input = await (0, _0_password_js_1.checkPassword)(password, ap);
|
|
692
|
-
const auth = await this.
|
|
692
|
+
const auth = await this.api.auth.checkPassword({ password: input });
|
|
693
693
|
__classPrivateFieldSet(this, _Client_selfId, Number(auth[_2_tl_js_1.as](_2_tl_js_1.types.auth.Authorization).user.id), "f");
|
|
694
694
|
await this.storage.setAccountType("user");
|
|
695
695
|
dAuth("authorized as user");
|
|
@@ -737,7 +737,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
737
737
|
return this.invoke(function_, true);
|
|
738
738
|
}
|
|
739
739
|
async getUserAccessHash(userId) {
|
|
740
|
-
const users = await this.
|
|
740
|
+
const users = await this.api.users.getUsers({ id: [new _2_tl_js_1.types.InputUser({ user_id: userId, access_hash: 0n })] });
|
|
741
741
|
return users[0]?.[_2_tl_js_1.as](_2_tl_js_1.types.User).access_hash ?? 0n;
|
|
742
742
|
}
|
|
743
743
|
async getInputPeer(id) {
|
|
@@ -755,7 +755,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
755
755
|
}
|
|
756
756
|
[(_Client_initConnection = async function _Client_initConnection() {
|
|
757
757
|
if (!__classPrivateFieldGet(this, _Client_connectionInited, "f")) {
|
|
758
|
-
await this.
|
|
758
|
+
await this.api.initConnection({
|
|
759
759
|
api_id: this.apiId,
|
|
760
760
|
app_version: this.appVersion,
|
|
761
761
|
device_model: this.deviceModel,
|
|
@@ -767,7 +767,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
767
767
|
}),
|
|
768
768
|
system_lang_code: this.systemLangCode,
|
|
769
769
|
system_version: this.systemVersion,
|
|
770
|
-
})
|
|
770
|
+
});
|
|
771
771
|
__classPrivateFieldSet(this, _Client_connectionInited, true, "f");
|
|
772
772
|
d("connection inited");
|
|
773
773
|
}
|
|
@@ -910,7 +910,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
910
910
|
reject(__classPrivateFieldGet(this, _Client_pingLoopAbortSignal, "f")?.signal.reason);
|
|
911
911
|
};
|
|
912
912
|
});
|
|
913
|
-
await this.
|
|
913
|
+
await this.api.ping_delay_disconnect({ ping_id: (0, _1_utilities_js_1.getRandomId)(), disconnect_delay: __classPrivateFieldGet(this, _Client_pingInterval, "f") / 1000 + 15 });
|
|
914
914
|
if (Date.now() - __classPrivateFieldGet(this, _Client_lastUpdates, "f").getTime() >= 15 * 60 * 1000) {
|
|
915
915
|
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "lastUpdates"));
|
|
916
916
|
}
|
|
@@ -920,20 +920,20 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
920
920
|
}
|
|
921
921
|
}
|
|
922
922
|
}, _Client_invoke = async function _Client_invoke(function_, noWait) {
|
|
923
|
-
if (!__classPrivateFieldGet(this, _Client_auth, "f") || !this.transport) {
|
|
924
|
-
if (__classPrivateFieldGet(this, _Client_autoStart, "f") && !__classPrivateFieldGet(this, _Client_autoStarted, "f")) {
|
|
925
|
-
await this.start();
|
|
926
|
-
}
|
|
927
|
-
else {
|
|
928
|
-
throw new ConnectionError("Not connected");
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
if (!__classPrivateFieldGet(this, _Client_auth, "f") || !this.transport) {
|
|
932
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
933
|
-
}
|
|
934
923
|
let n = 1;
|
|
935
924
|
while (true) {
|
|
936
925
|
try {
|
|
926
|
+
if (!__classPrivateFieldGet(this, _Client_auth, "f") || !this.transport) {
|
|
927
|
+
if (__classPrivateFieldGet(this, _Client_autoStart, "f") && !__classPrivateFieldGet(this, _Client_autoStarted, "f")) {
|
|
928
|
+
await this.start();
|
|
929
|
+
}
|
|
930
|
+
else {
|
|
931
|
+
throw new ConnectionError("Not connected");
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
if (!__classPrivateFieldGet(this, _Client_auth, "f") || !this.transport) {
|
|
935
|
+
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
936
|
+
}
|
|
937
937
|
let seqNo = __classPrivateFieldGet(this, _Client_state, "f").seqNo * 2;
|
|
938
938
|
if (!(function_ instanceof _2_tl_js_1.functions.ping) && !(function_ instanceof _2_tl_js_1.types.Msgs_ack)) {
|
|
939
939
|
seqNo++;
|
|
@@ -1236,7 +1236,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1236
1236
|
try {
|
|
1237
1237
|
let state = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
|
|
1238
1238
|
while (true) {
|
|
1239
|
-
const difference = await this.
|
|
1239
|
+
const difference = await this.api.updates.getDifference({ pts: state.pts, date: state.date, qts: state.qts ?? 0 });
|
|
1240
1240
|
if (difference instanceof _2_tl_js_1.types.updates.Difference || difference instanceof _2_tl_js_1.types.updates.DifferenceSlice) {
|
|
1241
1241
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, difference.chats);
|
|
1242
1242
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUsers).call(this, difference.users);
|
|
@@ -1285,12 +1285,12 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1285
1285
|
let pts = pts_ == null ? 1 : pts_;
|
|
1286
1286
|
while (true) {
|
|
1287
1287
|
const { access_hash } = await this.getInputPeer(_1_utilities_js_1.ZERO_CHANNEL_ID + -Number(channelId)).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.InputPeerChannel));
|
|
1288
|
-
const difference = await this.
|
|
1288
|
+
const difference = await this.api.updates.getChannelDifference({
|
|
1289
1289
|
pts,
|
|
1290
1290
|
channel: new _2_tl_js_1.types.InputChannel({ channel_id: channelId, access_hash }),
|
|
1291
1291
|
filter: new _2_tl_js_1.types.ChannelMessagesFilterEmpty(),
|
|
1292
1292
|
limit: await this.storage.getAccountType() == "user" ? _4_constants_js_1.CHANNEL_DIFFERENCE_LIMIT_USER : _4_constants_js_1.CHANNEL_DIFFERENCE_LIMIT_BOT,
|
|
1293
|
-
})
|
|
1293
|
+
});
|
|
1294
1294
|
if (difference instanceof _2_tl_js_1.types.updates.ChannelDifference) {
|
|
1295
1295
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, difference.chats);
|
|
1296
1296
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUsers).call(this, difference.users);
|
|
@@ -1327,7 +1327,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1327
1327
|
}
|
|
1328
1328
|
}
|
|
1329
1329
|
}, _Client_getChannelAccessHash = async function _Client_getChannelAccessHash(channelId) {
|
|
1330
|
-
const channels = await this.
|
|
1330
|
+
const channels = await this.api.channels.getChannels({ id: [new _2_tl_js_1.types.InputChannel({ channel_id: channelId, access_hash: 0n })] });
|
|
1331
1331
|
return channels.chats[0][_2_tl_js_1.as](_2_tl_js_1.types.Channel).access_hash ?? 0n;
|
|
1332
1332
|
}, _Client_getInputPeerInner = async function _Client_getInputPeerInner(id) {
|
|
1333
1333
|
if (typeof id === "string") {
|
|
@@ -1345,7 +1345,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1345
1345
|
}
|
|
1346
1346
|
}
|
|
1347
1347
|
else {
|
|
1348
|
-
const resolved = await this.
|
|
1348
|
+
const resolved = await this.api.contacts.resolveUsername({ username: id });
|
|
1349
1349
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, resolved.chats);
|
|
1350
1350
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUsers).call(this, resolved.users);
|
|
1351
1351
|
if (resolved.peer instanceof _2_tl_js_1.types.PeerUser) {
|
|
@@ -1467,7 +1467,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1467
1467
|
const replyToMsgId = params?.replyToMessageId;
|
|
1468
1468
|
const topMsgId = params?.messageThreadId;
|
|
1469
1469
|
const sendAs = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_resolveSendAs).call(this, params);
|
|
1470
|
-
const result = await this.
|
|
1470
|
+
const result = await this.api.messages.sendMessage({
|
|
1471
1471
|
peer,
|
|
1472
1472
|
random_id: randomId,
|
|
1473
1473
|
message,
|
|
@@ -1478,7 +1478,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1478
1478
|
send_as: sendAs,
|
|
1479
1479
|
entities,
|
|
1480
1480
|
reply_markup: replyMarkup,
|
|
1481
|
-
})
|
|
1481
|
+
});
|
|
1482
1482
|
const message_ = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
|
|
1483
1483
|
return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message_, "text");
|
|
1484
1484
|
}
|
|
@@ -1493,14 +1493,14 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1493
1493
|
*/
|
|
1494
1494
|
async editMessageText(chatId, messageId, text, params) {
|
|
1495
1495
|
const [message, entities] = __classPrivateFieldGet(this, _Client_instances, "m", _Client_parseText).call(this, text, params);
|
|
1496
|
-
const result = await this.
|
|
1496
|
+
const result = await this.api.messages.editMessage({
|
|
1497
1497
|
id: messageId,
|
|
1498
1498
|
peer: await this.getInputPeer(chatId),
|
|
1499
1499
|
entities,
|
|
1500
1500
|
message,
|
|
1501
1501
|
no_webpage: params?.disableWebPagePreview ? true : undefined,
|
|
1502
1502
|
reply_markup: await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params),
|
|
1503
|
-
})
|
|
1503
|
+
});
|
|
1504
1504
|
const message_ = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
|
|
1505
1505
|
return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message_, "text");
|
|
1506
1506
|
}
|
|
@@ -1583,15 +1583,15 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1583
1583
|
}
|
|
1584
1584
|
if (shouldFetch) {
|
|
1585
1585
|
if (peer instanceof _2_tl_js_1.types.InputPeerChannel) {
|
|
1586
|
-
messages_ = await this.
|
|
1586
|
+
messages_ = await this.api.channels.getMessages({
|
|
1587
1587
|
channel: new _2_tl_js_1.types.InputChannel(peer),
|
|
1588
1588
|
id: messageIds.map((v) => new _2_tl_js_1.types.InputMessageID({ id: v })),
|
|
1589
|
-
})
|
|
1589
|
+
}).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.messages.ChannelMessages).messages);
|
|
1590
1590
|
}
|
|
1591
1591
|
else {
|
|
1592
|
-
messages_ = await this.
|
|
1592
|
+
messages_ = await this.api.messages.getMessages({
|
|
1593
1593
|
id: messageIds.map((v) => new _2_tl_js_1.types.InputMessageID({ id: v })),
|
|
1594
|
-
})
|
|
1594
|
+
}).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.messages.Messages).messages);
|
|
1595
1595
|
}
|
|
1596
1596
|
}
|
|
1597
1597
|
const messages = new Array();
|
|
@@ -1635,14 +1635,17 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1635
1635
|
* ```
|
|
1636
1636
|
* @returns A generator yielding the contents of the file.
|
|
1637
1637
|
*/
|
|
1638
|
-
async download(fileId, params) {
|
|
1638
|
+
async *download(fileId, params) {
|
|
1639
1639
|
const fileId_ = _3_types_js_1.FileID.decode(fileId);
|
|
1640
1640
|
switch (fileId_.fileType) {
|
|
1641
1641
|
case _3_types_js_1.FileType.ChatPhoto: {
|
|
1642
1642
|
const big = fileId_.params.thumbnailSource == _3_types_js_1.ThumbnailSource.ChatPhotoBig;
|
|
1643
1643
|
const peer = await this.getInputPeer(fileId_.params.chatId);
|
|
1644
1644
|
const location = new _2_tl_js_1.types.InputPeerPhotoFileLocation({ big: big ? true : undefined, peer, photo_id: fileId_.params.mediaId });
|
|
1645
|
-
|
|
1645
|
+
for await (const chunk of __classPrivateFieldGet(this, _Client_instances, "m", _Client_downloadInner).call(this, location, fileId_.dcId, params)) {
|
|
1646
|
+
yield chunk;
|
|
1647
|
+
}
|
|
1648
|
+
break;
|
|
1646
1649
|
}
|
|
1647
1650
|
case _3_types_js_1.FileType.Photo: {
|
|
1648
1651
|
if (fileId_.params.mediaId == undefined || fileId_.params.accessHash == undefined || fileId_.params.fileReference == undefined || fileId_.params.thumbnailSize == undefined) {
|
|
@@ -1654,7 +1657,26 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1654
1657
|
file_reference: fileId_.params.fileReference,
|
|
1655
1658
|
thumb_size: fileId_.params.thumbnailSize,
|
|
1656
1659
|
});
|
|
1657
|
-
|
|
1660
|
+
for await (const chunk of __classPrivateFieldGet(this, _Client_instances, "m", _Client_downloadInner).call(this, location, fileId_.dcId, params)) {
|
|
1661
|
+
yield chunk;
|
|
1662
|
+
}
|
|
1663
|
+
break;
|
|
1664
|
+
}
|
|
1665
|
+
case _3_types_js_1.FileType.Document:
|
|
1666
|
+
case _3_types_js_1.FileType.Sticker: {
|
|
1667
|
+
if (fileId_.params.mediaId == undefined || fileId_.params.accessHash == undefined || fileId_.params.fileReference == undefined || fileId_.params.thumbnailSize == undefined) {
|
|
1668
|
+
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
1669
|
+
}
|
|
1670
|
+
const location = new _2_tl_js_1.types.InputDocumentFileLocation({
|
|
1671
|
+
id: fileId_.params.mediaId,
|
|
1672
|
+
access_hash: fileId_.params.accessHash,
|
|
1673
|
+
file_reference: fileId_.params.fileReference,
|
|
1674
|
+
thumb_size: fileId_.params.thumbnailSize,
|
|
1675
|
+
});
|
|
1676
|
+
for await (const chunk of __classPrivateFieldGet(this, _Client_instances, "m", _Client_downloadInner).call(this, location, fileId_.dcId, params)) {
|
|
1677
|
+
yield chunk;
|
|
1678
|
+
}
|
|
1679
|
+
break;
|
|
1658
1680
|
}
|
|
1659
1681
|
default:
|
|
1660
1682
|
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
@@ -1695,7 +1717,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1695
1717
|
client.invoke.use(async (ctx, next) => {
|
|
1696
1718
|
if (ctx.error instanceof _4_errors_js_1.AuthKeyUnregistered) {
|
|
1697
1719
|
try {
|
|
1698
|
-
const exportedAuth = await this.
|
|
1720
|
+
const exportedAuth = await this.api.auth.exportAuthorization({ dc_id: dcId });
|
|
1699
1721
|
await client.authorize(exportedAuth);
|
|
1700
1722
|
return true;
|
|
1701
1723
|
}
|
|
@@ -1738,7 +1760,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1738
1760
|
return maybeStickerSetName[0];
|
|
1739
1761
|
}
|
|
1740
1762
|
else {
|
|
1741
|
-
const stickerSet = await this.
|
|
1763
|
+
const stickerSet = await this.api.messages.getStickerSet({ stickerset: inputStickerSet, hash });
|
|
1742
1764
|
const name = stickerSet[_2_tl_js_1.as](_2_tl_js_1.types.messages.StickerSet).set.short_name;
|
|
1743
1765
|
await this.storage.updateStickerSetName(inputStickerSet.id, inputStickerSet.access_hash, name);
|
|
1744
1766
|
return name;
|
|
@@ -1754,7 +1776,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1754
1776
|
* @returns The forwarded messages.
|
|
1755
1777
|
*/
|
|
1756
1778
|
async forwardMessages(from, to, messageIds, params) {
|
|
1757
|
-
const result = await this.
|
|
1779
|
+
const result = await this.api.messages.forwardMessages({
|
|
1758
1780
|
from_peer: await this.getInputPeer(from),
|
|
1759
1781
|
to_peer: await this.getInputPeer(to),
|
|
1760
1782
|
id: messageIds,
|
|
@@ -1765,7 +1787,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1765
1787
|
send_as: params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined,
|
|
1766
1788
|
drop_author: params?.dropSenderName || undefined,
|
|
1767
1789
|
drop_media_captions: params?.dropCaption || undefined,
|
|
1768
|
-
})
|
|
1790
|
+
});
|
|
1769
1791
|
return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, to, result);
|
|
1770
1792
|
}
|
|
1771
1793
|
/**
|
|
@@ -1786,7 +1808,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1786
1808
|
* @method
|
|
1787
1809
|
*/
|
|
1788
1810
|
async getMe() {
|
|
1789
|
-
const users = await this.
|
|
1811
|
+
const users = await this.api.users.getUsers({ id: [new _2_tl_js_1.types.InputUserSelf()] });
|
|
1790
1812
|
if (users.length < 1) {
|
|
1791
1813
|
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
1792
1814
|
}
|
|
@@ -1802,12 +1824,12 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1802
1824
|
*/
|
|
1803
1825
|
async answerCallbackQuery(id, params) {
|
|
1804
1826
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_assertBot).call(this, "answerCallbackQuery");
|
|
1805
|
-
await this.
|
|
1827
|
+
await this.api.messages.setBotCallbackAnswer({
|
|
1806
1828
|
query_id: BigInt(id),
|
|
1807
1829
|
cache_time: params?.cacheTime ?? 0,
|
|
1808
1830
|
message: params?.text,
|
|
1809
1831
|
alert: params?.alert ? true : undefined,
|
|
1810
|
-
})
|
|
1832
|
+
});
|
|
1811
1833
|
}
|
|
1812
1834
|
/**
|
|
1813
1835
|
* Send a poll.
|
|
@@ -1849,7 +1871,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1849
1871
|
solution,
|
|
1850
1872
|
solution_entities: solutionEntities,
|
|
1851
1873
|
});
|
|
1852
|
-
const result = await this.
|
|
1874
|
+
const result = await this.api.messages.sendMedia({
|
|
1853
1875
|
peer,
|
|
1854
1876
|
random_id: randomId,
|
|
1855
1877
|
silent,
|
|
@@ -1859,7 +1881,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1859
1881
|
send_as: sendAs,
|
|
1860
1882
|
media,
|
|
1861
1883
|
message: "",
|
|
1862
|
-
})
|
|
1884
|
+
});
|
|
1863
1885
|
const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
|
|
1864
1886
|
return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "poll");
|
|
1865
1887
|
}
|
|
@@ -1910,7 +1932,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1910
1932
|
default:
|
|
1911
1933
|
throw new Error("Invalid chat action: " + action);
|
|
1912
1934
|
}
|
|
1913
|
-
await this.
|
|
1935
|
+
await this.api.messages.setTyping({ peer: await this.getInputPeer(chatId), action: action_, top_msg_id: params?.messageThreadId });
|
|
1914
1936
|
}
|
|
1915
1937
|
/**
|
|
1916
1938
|
* Upload a file.
|
|
@@ -2010,20 +2032,20 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
2010
2032
|
* @param commands The commands to set.
|
|
2011
2033
|
*/
|
|
2012
2034
|
async setMyCommands(commands, params) {
|
|
2013
|
-
await this.
|
|
2035
|
+
await this.api.bots.setBotCommands({
|
|
2014
2036
|
commands: commands.map((v) => new _2_tl_js_1.types.BotCommand(v)),
|
|
2015
2037
|
lang_code: params?.languageCode ?? "",
|
|
2016
2038
|
scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)),
|
|
2017
|
-
})
|
|
2039
|
+
});
|
|
2018
2040
|
}
|
|
2019
2041
|
/**
|
|
2020
2042
|
* Get the bot's commands in the given scope and/or language. Bot-only.
|
|
2021
2043
|
*/
|
|
2022
2044
|
async getMyCommands(params) {
|
|
2023
|
-
const commands_ = await this.
|
|
2045
|
+
const commands_ = await this.api.bots.getBotCommands({
|
|
2024
2046
|
lang_code: params?.languageCode ?? "",
|
|
2025
2047
|
scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)),
|
|
2026
|
-
})
|
|
2048
|
+
});
|
|
2027
2049
|
return commands_.map((v) => ({ command: v.command, description: v.description }));
|
|
2028
2050
|
}
|
|
2029
2051
|
/**
|
|
@@ -2034,7 +2056,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
2034
2056
|
* @param results The results to answer with.
|
|
2035
2057
|
*/
|
|
2036
2058
|
async answerInlineQuery(id, results, params) {
|
|
2037
|
-
await this.
|
|
2059
|
+
await this.api.messages.setInlineBotResults({
|
|
2038
2060
|
query_id: BigInt(id),
|
|
2039
2061
|
results: await Promise.all(results.map((v) => (0, _3_types_js_1.inlineQueryResultToTlObject)(v, __classPrivateFieldGet(this, _Client_instances, "m", _Client_parseText).bind(this), __classPrivateFieldGet(this, _Client_usernameResolver, "f").bind(this)))),
|
|
2040
2062
|
cache_time: params?.cacheTime ?? 300,
|
|
@@ -2043,7 +2065,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
2043
2065
|
switch_pm: params?.button && params.button.startParameter ? new _2_tl_js_1.types.InlineBotSwitchPM({ text: params.button.text, start_param: params.button.startParameter }) : undefined,
|
|
2044
2066
|
gallery: params?.isGallery ? true : undefined,
|
|
2045
2067
|
next_offset: params?.nextOffset,
|
|
2046
|
-
})
|
|
2068
|
+
});
|
|
2047
2069
|
}
|
|
2048
2070
|
use(...middleware) {
|
|
2049
2071
|
const composer = new _4_composer_js_1.Composer(...middleware);
|
|
@@ -2195,10 +2217,10 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
2195
2217
|
async deleteMessages(chatId, messageIds, params) {
|
|
2196
2218
|
const peer = await this.getInputPeer(chatId);
|
|
2197
2219
|
if (peer instanceof _2_tl_js_1.types.InputPeerChannel) {
|
|
2198
|
-
await this.
|
|
2220
|
+
await this.api.channels.deleteMessages({ channel: new _2_tl_js_1.types.InputChannel(peer), id: messageIds });
|
|
2199
2221
|
}
|
|
2200
2222
|
else {
|
|
2201
|
-
await this.
|
|
2223
|
+
await this.api.messages.deleteMessages({ id: messageIds, revoke: params?.onlyForMe ? undefined : true });
|
|
2202
2224
|
}
|
|
2203
2225
|
}
|
|
2204
2226
|
/**
|
|
@@ -2305,7 +2327,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
2305
2327
|
return { messages, cdn };
|
|
2306
2328
|
}
|
|
2307
2329
|
/**
|
|
2308
|
-
* Get chats.
|
|
2330
|
+
* Get chats from a chat list.
|
|
2309
2331
|
*
|
|
2310
2332
|
* @method
|
|
2311
2333
|
*/
|
|
@@ -2337,6 +2359,76 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
2337
2359
|
chats = chats.slice(0, limit);
|
|
2338
2360
|
return chats;
|
|
2339
2361
|
}
|
|
2362
|
+
/**
|
|
2363
|
+
* Get a chat.
|
|
2364
|
+
*
|
|
2365
|
+
* @method
|
|
2366
|
+
*/
|
|
2367
|
+
async getChat(chatId) {
|
|
2368
|
+
if (await this.storage.getAccountType() == "user") {
|
|
2369
|
+
let maybeChatId = null;
|
|
2370
|
+
if (typeof chatId === "number") {
|
|
2371
|
+
maybeChatId = chatId;
|
|
2372
|
+
}
|
|
2373
|
+
else if (typeof chatId === "string") {
|
|
2374
|
+
maybeChatId = __classPrivateFieldGet(this, _Client_instances, "m", _Client_tryGetChatId).call(this, (0, _0_utilities_js_1.getUsername)(chatId));
|
|
2375
|
+
}
|
|
2376
|
+
else {
|
|
2377
|
+
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
2378
|
+
}
|
|
2379
|
+
if (maybeChatId != null) {
|
|
2380
|
+
const [chat] = __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChatAnywhere).call(this, maybeChatId);
|
|
2381
|
+
if (chat !== undefined) {
|
|
2382
|
+
return chat;
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
let inputPeer = null;
|
|
2387
|
+
if (typeof chatId === "number") {
|
|
2388
|
+
const chat = await (0, _3_types_js_1.constructChat3)(chatId, -1, undefined, this[getEntity].bind(this));
|
|
2389
|
+
if (chat != null) {
|
|
2390
|
+
return chat;
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
else {
|
|
2394
|
+
inputPeer = await this.getInputPeer(chatId);
|
|
2395
|
+
const chatId_ = (0, _2_tl_js_1.peerToChatId)(inputPeer);
|
|
2396
|
+
const chat = await (0, _3_types_js_1.constructChat3)(chatId_, -1, undefined, this[getEntity].bind(this));
|
|
2397
|
+
if (chat != null) {
|
|
2398
|
+
return chat;
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
if (inputPeer == null) {
|
|
2402
|
+
inputPeer = await this.getInputPeer(chatId);
|
|
2403
|
+
}
|
|
2404
|
+
if (inputPeer instanceof _2_tl_js_1.types.InputPeerChat) {
|
|
2405
|
+
const chats = await this.api.messages.getChats({ id: [inputPeer.chat_id] }).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.messages.Chats));
|
|
2406
|
+
const chat = chats.chats[0];
|
|
2407
|
+
if (chat instanceof _2_tl_js_1.types.ChatEmpty) {
|
|
2408
|
+
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
2409
|
+
}
|
|
2410
|
+
return (0, _3_types_js_1.constructChat2)(chat, -1, undefined);
|
|
2411
|
+
}
|
|
2412
|
+
else if (inputPeer instanceof _2_tl_js_1.types.InputPeerChannel) {
|
|
2413
|
+
const channels = await this.api.channels.getChannels({ id: [new _2_tl_js_1.types.InputChannel(inputPeer)] });
|
|
2414
|
+
const channel = channels.chats[0];
|
|
2415
|
+
if (channel instanceof _2_tl_js_1.types.ChatEmpty) {
|
|
2416
|
+
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
2417
|
+
}
|
|
2418
|
+
return (0, _3_types_js_1.constructChat2)(channel, -1, undefined);
|
|
2419
|
+
}
|
|
2420
|
+
else if (inputPeer instanceof _2_tl_js_1.types.InputPeerUser) {
|
|
2421
|
+
const users = await this.api.users.getUsers({ id: [new _2_tl_js_1.types.InputUser(inputPeer)] });
|
|
2422
|
+
const user = users[0];
|
|
2423
|
+
if (user instanceof _2_tl_js_1.types.UserEmpty) {
|
|
2424
|
+
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
2425
|
+
}
|
|
2426
|
+
return (0, _3_types_js_1.constructChat2)(user, -1, undefined);
|
|
2427
|
+
}
|
|
2428
|
+
else {
|
|
2429
|
+
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2340
2432
|
/**
|
|
2341
2433
|
* Get chat history.
|
|
2342
2434
|
*
|
|
@@ -2386,6 +2478,53 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
2386
2478
|
}
|
|
2387
2479
|
return messages;
|
|
2388
2480
|
}
|
|
2481
|
+
/**
|
|
2482
|
+
* Get custom emoji documents for download.
|
|
2483
|
+
*
|
|
2484
|
+
* @param id Identifier of one or more of custom emojis.
|
|
2485
|
+
* @method
|
|
2486
|
+
*/
|
|
2487
|
+
async getCustomEmojiDocuments(id) {
|
|
2488
|
+
id = Array.isArray(id) ? id : [id];
|
|
2489
|
+
if (!id.length) {
|
|
2490
|
+
throw new Error("No custom emoji ID provided");
|
|
2491
|
+
}
|
|
2492
|
+
const documents = new Array();
|
|
2493
|
+
let shouldFetch = false;
|
|
2494
|
+
for (const [i, id_] of id.entries()) {
|
|
2495
|
+
const maybeDocument = await this.storage.getCustomEmojiDocument(BigInt(id_));
|
|
2496
|
+
if (maybeDocument != null && Date.now() - maybeDocument[1].getTime() <= 30 * 60 * 1000) {
|
|
2497
|
+
const document_ = maybeDocument[0];
|
|
2498
|
+
const fileUniqueId = new _3_types_js_1.FileUniqueID(_3_types_js_1.FileUniqueType.Document, { mediaId: document_.id }).encode();
|
|
2499
|
+
const fileId = new _3_types_js_1.FileID(null, null, _3_types_js_1.FileType.Document, document_.dc_id, {
|
|
2500
|
+
mediaId: document_.id,
|
|
2501
|
+
accessHash: document_.access_hash,
|
|
2502
|
+
fileReference: document_.file_reference,
|
|
2503
|
+
}).encode();
|
|
2504
|
+
const document = (0, _3_types_js_1.constructDocument)(document_, new _2_tl_js_1.types.DocumentAttributeFilename({ file_name: `${id[i] ?? "customEmoji"}.${(0, _0_deps_js_1.extension)(document_.mime_type)}` }), fileId, fileUniqueId);
|
|
2505
|
+
documents.push(document);
|
|
2506
|
+
}
|
|
2507
|
+
else {
|
|
2508
|
+
shouldFetch = true;
|
|
2509
|
+
break;
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
if (!shouldFetch) {
|
|
2513
|
+
return documents;
|
|
2514
|
+
}
|
|
2515
|
+
const documents_ = await this.api.messages.getCustomEmojiDocuments({ document_id: id.map(BigInt) }).then((v) => v.map((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.Document)));
|
|
2516
|
+
for (const [i, document_] of documents_.entries()) {
|
|
2517
|
+
const fileUniqueId = new _3_types_js_1.FileUniqueID(_3_types_js_1.FileUniqueType.Document, { mediaId: document_.id }).encode();
|
|
2518
|
+
const fileId = new _3_types_js_1.FileID(null, null, _3_types_js_1.FileType.Document, document_.dc_id, {
|
|
2519
|
+
mediaId: document_.id,
|
|
2520
|
+
accessHash: document_.access_hash,
|
|
2521
|
+
fileReference: document_.file_reference,
|
|
2522
|
+
}).encode();
|
|
2523
|
+
const document = (0, _3_types_js_1.constructDocument)(document_, new _2_tl_js_1.types.DocumentAttributeFilename({ file_name: `${id[i] ?? "customEmoji"}.${(0, _0_deps_js_1.extension)(document_.mime_type)}` }), fileId, fileUniqueId);
|
|
2524
|
+
documents.push(document);
|
|
2525
|
+
}
|
|
2526
|
+
return documents;
|
|
2527
|
+
}
|
|
2389
2528
|
}
|
|
2390
2529
|
exports.Client = Client;
|
|
2391
2530
|
_a = Client, _Client_getMe = async function _Client_getMe() {
|
|
@@ -2558,9 +2697,9 @@ async function _Client_handleUpdate(update) {
|
|
|
2558
2697
|
}, _Client_setMyInfo =
|
|
2559
2698
|
//#endregion
|
|
2560
2699
|
async function _Client_setMyInfo(info) {
|
|
2561
|
-
await this.
|
|
2700
|
+
await this.api.bots.setBotInfo({ bot: new _2_tl_js_1.types.InputUserSelf(), ...info });
|
|
2562
2701
|
}, _Client_getMyInfo = function _Client_getMyInfo(languageCode) {
|
|
2563
|
-
return this.
|
|
2702
|
+
return this.api.bots.getBotInfo({ bot: new _2_tl_js_1.types.InputUserSelf(), lang_code: languageCode ?? "" });
|
|
2564
2703
|
}, _Client_resolveFileId = function _Client_resolveFileId(maybeFileId, expectedFileType) {
|
|
2565
2704
|
let fileId = null;
|
|
2566
2705
|
try {
|
|
@@ -2596,7 +2735,7 @@ async function _Client_setMyInfo(info) {
|
|
|
2596
2735
|
const parseResult = caption_ !== undefined ? __classPrivateFieldGet(this, _Client_instances, "m", _Client_parseText).call(this, caption_, { parseMode: params?.parseMode, entities: params?.captionEntities }) : undefined;
|
|
2597
2736
|
const caption = parseResult === undefined ? undefined : parseResult[0];
|
|
2598
2737
|
const captionEntities = parseResult === undefined ? undefined : parseResult[1];
|
|
2599
|
-
const result = await this.
|
|
2738
|
+
const result = await this.api.messages.sendMedia({
|
|
2600
2739
|
peer,
|
|
2601
2740
|
random_id: randomId,
|
|
2602
2741
|
silent,
|
|
@@ -2607,7 +2746,7 @@ async function _Client_setMyInfo(info) {
|
|
|
2607
2746
|
media,
|
|
2608
2747
|
message: caption ?? "",
|
|
2609
2748
|
entities: captionEntities,
|
|
2610
|
-
})
|
|
2749
|
+
});
|
|
2611
2750
|
return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
|
|
2612
2751
|
}, _Client_sendChatUpdate = async function _Client_sendChatUpdate(chatId, added) {
|
|
2613
2752
|
try {
|
|
@@ -2642,7 +2781,7 @@ async function _Client_setMyInfo(info) {
|
|
|
2642
2781
|
}
|
|
2643
2782
|
else {
|
|
2644
2783
|
const pinnedChats = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getPinnedChats).call(this, listId);
|
|
2645
|
-
const chat = await (0, _3_types_js_1.
|
|
2784
|
+
const chat = await (0, _3_types_js_1.constructChat3)(chatId, pinnedChats.indexOf(chatId), message, this[getEntity].bind(this));
|
|
2646
2785
|
if (chat == null) {
|
|
2647
2786
|
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
2648
2787
|
}
|
|
@@ -2663,7 +2802,7 @@ async function _Client_setMyInfo(info) {
|
|
|
2663
2802
|
}
|
|
2664
2803
|
else {
|
|
2665
2804
|
const pinnedChats = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getPinnedChats).call(this, listId);
|
|
2666
|
-
const chat = await (0, _3_types_js_1.
|
|
2805
|
+
const chat = await (0, _3_types_js_1.constructChat3)(chatId, pinnedChats.indexOf(chatId), message, this[getEntity].bind(this));
|
|
2667
2806
|
if (chat == null) {
|
|
2668
2807
|
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
2669
2808
|
}
|
|
@@ -2681,6 +2820,23 @@ async function _Client_setMyInfo(info) {
|
|
|
2681
2820
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendChatUpdate).call(this, chatId, false);
|
|
2682
2821
|
}
|
|
2683
2822
|
}
|
|
2823
|
+
}, _Client_tryGetChatId = function _Client_tryGetChatId(username) {
|
|
2824
|
+
username = username.toLowerCase();
|
|
2825
|
+
for (const chat of __classPrivateFieldGet(this, _Client_chats, "f").values()) {
|
|
2826
|
+
if ("username" in chat) {
|
|
2827
|
+
if (chat.username === username || chat.also?.some((v) => v.toLowerCase() === username)) {
|
|
2828
|
+
return chat.id;
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
for (const chat of __classPrivateFieldGet(this, _Client_archivedChats, "f").values()) {
|
|
2833
|
+
if ("username" in chat) {
|
|
2834
|
+
if (chat.username === username || chat.also?.some((v) => v.toLowerCase() === username)) {
|
|
2835
|
+
return chat.id;
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
return null;
|
|
2684
2840
|
}, _Client_getChatAnywhere = function _Client_getChatAnywhere(chatId) {
|
|
2685
2841
|
let chat = __classPrivateFieldGet(this, _Client_chats, "f").get(chatId);
|
|
2686
2842
|
if (chat) {
|
|
@@ -2704,14 +2860,14 @@ async function _Client_setMyInfo(info) {
|
|
|
2704
2860
|
const chats = await this.storage.getChats(0);
|
|
2705
2861
|
const archivedChats = await this.storage.getChats(1);
|
|
2706
2862
|
for (const { chatId, pinned, topMessageId } of chats) {
|
|
2707
|
-
const chat = await (0, _3_types_js_1.
|
|
2863
|
+
const chat = await (0, _3_types_js_1.constructChat4)(chatId, pinned, topMessageId, this[getEntity].bind(this), this.getMessage.bind(this));
|
|
2708
2864
|
if (chat == null) {
|
|
2709
2865
|
continue;
|
|
2710
2866
|
}
|
|
2711
2867
|
__classPrivateFieldGet(this, _Client_chats, "f").set(chat.id, chat);
|
|
2712
2868
|
}
|
|
2713
2869
|
for (const { chatId, pinned, topMessageId } of archivedChats) {
|
|
2714
|
-
const chat = await (0, _3_types_js_1.
|
|
2870
|
+
const chat = await (0, _3_types_js_1.constructChat4)(chatId, pinned, topMessageId, this[getEntity].bind(this), this.getMessage.bind(this));
|
|
2715
2871
|
if (chat == null) {
|
|
2716
2872
|
continue;
|
|
2717
2873
|
}
|
|
@@ -2775,14 +2931,14 @@ async function _Client_setMyInfo(info) {
|
|
|
2775
2931
|
}, _Client_updateOrAddChat = async function _Client_updateOrAddChat(chatId) {
|
|
2776
2932
|
const [chat, listId] = __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChatAnywhere).call(this, chatId);
|
|
2777
2933
|
if (chat !== undefined) {
|
|
2778
|
-
const newChat = await (0, _3_types_js_1.
|
|
2934
|
+
const newChat = await (0, _3_types_js_1.constructChat3)(chatId, chat.pinned, chat.lastMessage, this[getEntity].bind(this));
|
|
2779
2935
|
if (newChat != null) {
|
|
2780
2936
|
__classPrivateFieldGet(this, _Client_instances, "m", _Client_getChatList).call(this, listId).set(chatId, newChat);
|
|
2781
2937
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendChatUpdate).call(this, chatId, false);
|
|
2782
2938
|
}
|
|
2783
2939
|
}
|
|
2784
2940
|
else {
|
|
2785
|
-
const chat = await (0, _3_types_js_1.
|
|
2941
|
+
const chat = await (0, _3_types_js_1.constructChat4)(chatId, -1, -1, this[getEntity].bind(this), this.getMessage.bind(this));
|
|
2786
2942
|
if (chat != null) {
|
|
2787
2943
|
__classPrivateFieldGet(this, _Client_instances, "m", _Client_getChatList).call(this, 0).set(chatId, chat);
|
|
2788
2944
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_reassignChatLastMessage).call(this, chatId, false, false);
|