@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.
Files changed (39) hide show
  1. package/esm/0_deps.d.ts +1 -0
  2. package/esm/0_deps.js +9 -0
  3. package/esm/4_constants.d.ts +1 -1
  4. package/esm/4_constants.js +1 -1
  5. package/esm/client/5_client.d.ts +17 -3
  6. package/esm/client/5_client.js +229 -73
  7. package/esm/deps/deno.land/std@0.209.0/media_types/extension.d.ts +17 -0
  8. package/esm/deps/deno.land/std@0.209.0/media_types/extension.js +26 -0
  9. package/esm/deps/deno.land/std@0.209.0/media_types/extensions_by_type.d.ts +20 -0
  10. package/esm/deps/deno.land/std@0.209.0/media_types/extensions_by_type.js +31 -0
  11. package/esm/storage/0_storage.d.ts +3 -1
  12. package/esm/storage/0_storage.js +18 -5
  13. package/esm/tl/0_tl_raw_reader.js +1 -1
  14. package/esm/tl/3_utilities.d.ts +1 -0
  15. package/esm/tl/3_utilities.js +11 -0
  16. package/esm/types/1__getters.d.ts +1 -0
  17. package/esm/types/1_sticker.js +5 -4
  18. package/esm/types/4_chat.d.ts +3 -2
  19. package/esm/types/4_chat.js +16 -27
  20. package/package.json +1 -1
  21. package/script/0_deps.d.ts +1 -0
  22. package/script/0_deps.js +11 -1
  23. package/script/4_constants.d.ts +1 -1
  24. package/script/4_constants.js +1 -1
  25. package/script/client/5_client.d.ts +17 -3
  26. package/script/client/5_client.js +226 -70
  27. package/script/deps/deno.land/std@0.209.0/media_types/extension.d.ts +17 -0
  28. package/script/deps/deno.land/std@0.209.0/media_types/extension.js +30 -0
  29. package/script/deps/deno.land/std@0.209.0/media_types/extensions_by_type.d.ts +20 -0
  30. package/script/deps/deno.land/std@0.209.0/media_types/extensions_by_type.js +35 -0
  31. package/script/storage/0_storage.d.ts +3 -1
  32. package/script/storage/0_storage.js +18 -5
  33. package/script/tl/0_tl_raw_reader.js +1 -1
  34. package/script/tl/3_utilities.d.ts +1 -0
  35. package/script/tl/3_utilities.js +13 -1
  36. package/script/types/1__getters.d.ts +1 -0
  37. package/script/types/1_sticker.js +4 -3
  38. package/script/types/4_chat.d.ts +3 -2
  39. package/script/types/4_chat.js +17 -27
@@ -9,12 +9,12 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _Client_instances, _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
- import { contentType, debug, gunzip, Mutex } from "../0_deps.js";
12
+ 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;
13
+ import { contentType, debug, extension, gunzip, Mutex } from "../0_deps.js";
14
14
  import { bigIntFromBuffer, cleanObject, drop, getRandomBigInt, getRandomId, mod, mustPrompt, mustPromptOneOf, Queue, sha1, UNREACHABLE, ZERO_CHANNEL_ID } from "../1_utilities.js";
15
15
  import { as, functions, getChannelChatId, Message_, MessageContainer, name, peerToChatId, RPCResult, TLError, TLReader, types } from "../2_tl.js";
16
16
  import { StorageMemory } from "../3_storage.js";
17
- import { botCommandScopeToTlObject, constructCallbackQuery, constructChat, constructChat2, constructChat3, constructChosenInlineResult, constructInlineQuery, constructMessage, constructUser, FileID, FileType, getChatOrder, inlineQueryResultToTlObject, messageEntityToTlObject, replyMarkupToTlObject, ThumbnailSource } from "../3_types.js";
17
+ import { botCommandScopeToTlObject, constructCallbackQuery, constructChat, constructChat2, constructChat3, constructChat4, constructChosenInlineResult, constructDocument, constructInlineQuery, constructMessage, constructUser, FileID, FileType, FileUniqueID, FileUniqueType, getChatOrder, inlineQueryResultToTlObject, messageEntityToTlObject, replyMarkupToTlObject, ThumbnailSource } from "../3_types.js";
18
18
  import { ACK_THRESHOLD, APP_VERSION, CHANNEL_DIFFERENCE_LIMIT_BOT, CHANNEL_DIFFERENCE_LIMIT_USER, DEVICE_MODEL, LANG_CODE, LANG_PACK, LAYER, MAX_CHANNEL_ID, MAX_CHAT_ID, STICKER_SET_NAME_TTL, SYSTEM_LANG_CODE, SYSTEM_VERSION, USERNAME_TTL } from "../4_constants.js";
19
19
  import { AuthKeyUnregistered, FloodWait, Migrate, PasswordHashInvalid, PhoneNumberInvalid, SessionPasswordNeeded, upgradeInstance } from "../4_errors.js";
20
20
  import { parseHtml } from "./0_html.js";
@@ -23,7 +23,7 @@ import { checkPassword } from "./0_password.js";
23
23
  import { getFileContents, getUsername, isChannelPtsUpdate, isHttpUrl, isPtsUpdate, resolve } from "./0_utilities.js";
24
24
  import { ClientAbstract } from "./1_client_abstract.js";
25
25
  import { ClientPlain } from "./2_client_plain.js";
26
- import { getChatListId, } from "./3_types.js";
26
+ import { getChatListId } from "./3_types.js";
27
27
  import { Composer, concat, flatten, skip } from "./4_composer.js";
28
28
  const d = debug("Client");
29
29
  const dGap = debug("Client/recoverUpdateGap");
@@ -517,7 +517,7 @@ export class Client extends ClientAbstract {
517
517
  throw new Error(`${source}: not a bot client`);
518
518
  }
519
519
  }, _Client_fetchState = async function _Client_fetchState(source) {
520
- const state = await this.invoke(new functions.updates.getState());
520
+ const state = await this.api.updates.getState();
521
521
  __classPrivateFieldSet(this, _Client_updateState, state, "f");
522
522
  d("state fetched [%s]", source);
523
523
  }, handleMigrationError)](err) {
@@ -583,7 +583,7 @@ export class Client extends ClientAbstract {
583
583
  if (typeof params === "string") {
584
584
  while (true) {
585
585
  try {
586
- const auth = await this.invoke(new functions.auth.importBotAuthorization({ api_id: this.apiId, api_hash: this.apiHash, bot_auth_token: params, flags: 0 }));
586
+ const auth = await this.api.auth.importBotAuthorization({ api_id: this.apiId, api_hash: this.apiHash, bot_auth_token: params, flags: 0 });
587
587
  __classPrivateFieldSet(this, _Client_selfId, Number(auth[as](types.auth.Authorization).user.id), "f");
588
588
  await this.storage.setAccountType("bot");
589
589
  break;
@@ -605,7 +605,7 @@ export class Client extends ClientAbstract {
605
605
  return;
606
606
  }
607
607
  if (params instanceof types.auth.ExportedAuthorization) {
608
- await this.invoke(new functions.auth.importAuthorization({ id: params.id, bytes: params.bytes }));
608
+ await this.api.auth.importAuthorization({ id: params.id, bytes: params.bytes });
609
609
  dAuth("authorization imported");
610
610
  return;
611
611
  }
@@ -616,12 +616,12 @@ export class Client extends ClientAbstract {
616
616
  while (true) {
617
617
  try {
618
618
  phone = typeof params.phone === "string" ? params.phone : await params.phone();
619
- const sendCode = () => this.invoke(new functions.auth.sendCode({
619
+ const sendCode = () => this.api.auth.sendCode({
620
620
  phone_number: phone,
621
621
  api_id: this.apiId,
622
622
  api_hash: this.apiHash,
623
623
  settings: new types.CodeSettings(),
624
- })).then((v) => v[as](types.auth.SentCode));
624
+ }).then((v) => v[as](types.auth.SentCode));
625
625
  try {
626
626
  sentCode = await sendCode();
627
627
  }
@@ -651,11 +651,11 @@ export class Client extends ClientAbstract {
651
651
  code: while (true) {
652
652
  const code = typeof params.code === "string" ? params.code : await params.code();
653
653
  try {
654
- const auth = await this.invoke(new functions.auth.signIn({
654
+ const auth = await this.api.auth.signIn({
655
655
  phone_number: phone,
656
656
  phone_code: code,
657
657
  phone_code_hash: sentCode.phone_code_hash,
658
- }));
658
+ });
659
659
  __classPrivateFieldSet(this, _Client_selfId, Number(auth[as](types.auth.Authorization).user.id), "f");
660
660
  await this.storage.setAccountType("user");
661
661
  dAuth("authorized as user");
@@ -677,14 +677,14 @@ export class Client extends ClientAbstract {
677
677
  throw err;
678
678
  }
679
679
  password: while (true) {
680
- const ap = await this.invoke(new functions.account.getPassword());
680
+ const ap = await this.api.account.getPassword();
681
681
  if (!(ap.current_algo instanceof types.PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow)) {
682
682
  throw new Error(`Handling ${ap.current_algo?.[name]} not implemented`);
683
683
  }
684
684
  try {
685
685
  const password = typeof params.password === "string" ? params.password : await params.password(ap.hint ?? null);
686
686
  const input = await checkPassword(password, ap);
687
- const auth = await this.invoke(new functions.auth.checkPassword({ password: input }));
687
+ const auth = await this.api.auth.checkPassword({ password: input });
688
688
  __classPrivateFieldSet(this, _Client_selfId, Number(auth[as](types.auth.Authorization).user.id), "f");
689
689
  await this.storage.setAccountType("user");
690
690
  dAuth("authorized as user");
@@ -732,7 +732,7 @@ export class Client extends ClientAbstract {
732
732
  return this.invoke(function_, true);
733
733
  }
734
734
  async getUserAccessHash(userId) {
735
- const users = await this.invoke(new functions.users.getUsers({ id: [new types.InputUser({ user_id: userId, access_hash: 0n })] }));
735
+ const users = await this.api.users.getUsers({ id: [new types.InputUser({ user_id: userId, access_hash: 0n })] });
736
736
  return users[0]?.[as](types.User).access_hash ?? 0n;
737
737
  }
738
738
  async getInputPeer(id) {
@@ -750,7 +750,7 @@ export class Client extends ClientAbstract {
750
750
  }
751
751
  [(_Client_initConnection = async function _Client_initConnection() {
752
752
  if (!__classPrivateFieldGet(this, _Client_connectionInited, "f")) {
753
- await this.invoke(new functions.initConnection({
753
+ await this.api.initConnection({
754
754
  api_id: this.apiId,
755
755
  app_version: this.appVersion,
756
756
  device_model: this.deviceModel,
@@ -762,7 +762,7 @@ export class Client extends ClientAbstract {
762
762
  }),
763
763
  system_lang_code: this.systemLangCode,
764
764
  system_version: this.systemVersion,
765
- }));
765
+ });
766
766
  __classPrivateFieldSet(this, _Client_connectionInited, true, "f");
767
767
  d("connection inited");
768
768
  }
@@ -905,7 +905,7 @@ export class Client extends ClientAbstract {
905
905
  reject(__classPrivateFieldGet(this, _Client_pingLoopAbortSignal, "f")?.signal.reason);
906
906
  };
907
907
  });
908
- await this.invoke(new functions.ping_delay_disconnect({ ping_id: getRandomId(), disconnect_delay: __classPrivateFieldGet(this, _Client_pingInterval, "f") / 1000 + 15 }));
908
+ await this.api.ping_delay_disconnect({ ping_id: getRandomId(), disconnect_delay: __classPrivateFieldGet(this, _Client_pingInterval, "f") / 1000 + 15 });
909
909
  if (Date.now() - __classPrivateFieldGet(this, _Client_lastUpdates, "f").getTime() >= 15 * 60 * 1000) {
910
910
  drop(__classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "lastUpdates"));
911
911
  }
@@ -915,20 +915,20 @@ export class Client extends ClientAbstract {
915
915
  }
916
916
  }
917
917
  }, _Client_invoke = async function _Client_invoke(function_, noWait) {
918
- if (!__classPrivateFieldGet(this, _Client_auth, "f") || !this.transport) {
919
- if (__classPrivateFieldGet(this, _Client_autoStart, "f") && !__classPrivateFieldGet(this, _Client_autoStarted, "f")) {
920
- await this.start();
921
- }
922
- else {
923
- throw new ConnectionError("Not connected");
924
- }
925
- }
926
- if (!__classPrivateFieldGet(this, _Client_auth, "f") || !this.transport) {
927
- UNREACHABLE();
928
- }
929
918
  let n = 1;
930
919
  while (true) {
931
920
  try {
921
+ if (!__classPrivateFieldGet(this, _Client_auth, "f") || !this.transport) {
922
+ if (__classPrivateFieldGet(this, _Client_autoStart, "f") && !__classPrivateFieldGet(this, _Client_autoStarted, "f")) {
923
+ await this.start();
924
+ }
925
+ else {
926
+ throw new ConnectionError("Not connected");
927
+ }
928
+ }
929
+ if (!__classPrivateFieldGet(this, _Client_auth, "f") || !this.transport) {
930
+ UNREACHABLE();
931
+ }
932
932
  let seqNo = __classPrivateFieldGet(this, _Client_state, "f").seqNo * 2;
933
933
  if (!(function_ instanceof functions.ping) && !(function_ instanceof types.Msgs_ack)) {
934
934
  seqNo++;
@@ -1231,7 +1231,7 @@ export class Client extends ClientAbstract {
1231
1231
  try {
1232
1232
  let state = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
1233
1233
  while (true) {
1234
- const difference = await this.invoke(new functions.updates.getDifference({ pts: state.pts, date: state.date, qts: state.qts ?? 0 }));
1234
+ const difference = await this.api.updates.getDifference({ pts: state.pts, date: state.date, qts: state.qts ?? 0 });
1235
1235
  if (difference instanceof types.updates.Difference || difference instanceof types.updates.DifferenceSlice) {
1236
1236
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, difference.chats);
1237
1237
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUsers).call(this, difference.users);
@@ -1280,12 +1280,12 @@ export class Client extends ClientAbstract {
1280
1280
  let pts = pts_ == null ? 1 : pts_;
1281
1281
  while (true) {
1282
1282
  const { access_hash } = await this.getInputPeer(ZERO_CHANNEL_ID + -Number(channelId)).then((v) => v[as](types.InputPeerChannel));
1283
- const difference = await this.invoke(new functions.updates.getChannelDifference({
1283
+ const difference = await this.api.updates.getChannelDifference({
1284
1284
  pts,
1285
1285
  channel: new types.InputChannel({ channel_id: channelId, access_hash }),
1286
1286
  filter: new types.ChannelMessagesFilterEmpty(),
1287
1287
  limit: await this.storage.getAccountType() == "user" ? CHANNEL_DIFFERENCE_LIMIT_USER : CHANNEL_DIFFERENCE_LIMIT_BOT,
1288
- }));
1288
+ });
1289
1289
  if (difference instanceof types.updates.ChannelDifference) {
1290
1290
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, difference.chats);
1291
1291
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUsers).call(this, difference.users);
@@ -1322,7 +1322,7 @@ export class Client extends ClientAbstract {
1322
1322
  }
1323
1323
  }
1324
1324
  }, _Client_getChannelAccessHash = async function _Client_getChannelAccessHash(channelId) {
1325
- const channels = await this.invoke(new functions.channels.getChannels({ id: [new types.InputChannel({ channel_id: channelId, access_hash: 0n })] }));
1325
+ const channels = await this.api.channels.getChannels({ id: [new types.InputChannel({ channel_id: channelId, access_hash: 0n })] });
1326
1326
  return channels.chats[0][as](types.Channel).access_hash ?? 0n;
1327
1327
  }, _Client_getInputPeerInner = async function _Client_getInputPeerInner(id) {
1328
1328
  if (typeof id === "string") {
@@ -1340,7 +1340,7 @@ export class Client extends ClientAbstract {
1340
1340
  }
1341
1341
  }
1342
1342
  else {
1343
- const resolved = await this.invoke(new functions.contacts.resolveUsername({ username: id }));
1343
+ const resolved = await this.api.contacts.resolveUsername({ username: id });
1344
1344
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, resolved.chats);
1345
1345
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUsers).call(this, resolved.users);
1346
1346
  if (resolved.peer instanceof types.PeerUser) {
@@ -1462,7 +1462,7 @@ export class Client extends ClientAbstract {
1462
1462
  const replyToMsgId = params?.replyToMessageId;
1463
1463
  const topMsgId = params?.messageThreadId;
1464
1464
  const sendAs = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_resolveSendAs).call(this, params);
1465
- const result = await this.invoke(new functions.messages.sendMessage({
1465
+ const result = await this.api.messages.sendMessage({
1466
1466
  peer,
1467
1467
  random_id: randomId,
1468
1468
  message,
@@ -1473,7 +1473,7 @@ export class Client extends ClientAbstract {
1473
1473
  send_as: sendAs,
1474
1474
  entities,
1475
1475
  reply_markup: replyMarkup,
1476
- }));
1476
+ });
1477
1477
  const message_ = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
1478
1478
  return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message_, "text");
1479
1479
  }
@@ -1488,14 +1488,14 @@ export class Client extends ClientAbstract {
1488
1488
  */
1489
1489
  async editMessageText(chatId, messageId, text, params) {
1490
1490
  const [message, entities] = __classPrivateFieldGet(this, _Client_instances, "m", _Client_parseText).call(this, text, params);
1491
- const result = await this.invoke(new functions.messages.editMessage({
1491
+ const result = await this.api.messages.editMessage({
1492
1492
  id: messageId,
1493
1493
  peer: await this.getInputPeer(chatId),
1494
1494
  entities,
1495
1495
  message,
1496
1496
  no_webpage: params?.disableWebPagePreview ? true : undefined,
1497
1497
  reply_markup: await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params),
1498
- }));
1498
+ });
1499
1499
  const message_ = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
1500
1500
  return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message_, "text");
1501
1501
  }
@@ -1578,15 +1578,15 @@ export class Client extends ClientAbstract {
1578
1578
  }
1579
1579
  if (shouldFetch) {
1580
1580
  if (peer instanceof types.InputPeerChannel) {
1581
- messages_ = await this.invoke(new functions.channels.getMessages({
1581
+ messages_ = await this.api.channels.getMessages({
1582
1582
  channel: new types.InputChannel(peer),
1583
1583
  id: messageIds.map((v) => new types.InputMessageID({ id: v })),
1584
- })).then((v) => v[as](types.messages.ChannelMessages).messages);
1584
+ }).then((v) => v[as](types.messages.ChannelMessages).messages);
1585
1585
  }
1586
1586
  else {
1587
- messages_ = await this.invoke(new functions.messages.getMessages({
1587
+ messages_ = await this.api.messages.getMessages({
1588
1588
  id: messageIds.map((v) => new types.InputMessageID({ id: v })),
1589
- })).then((v) => v[as](types.messages.Messages).messages);
1589
+ }).then((v) => v[as](types.messages.Messages).messages);
1590
1590
  }
1591
1591
  }
1592
1592
  const messages = new Array();
@@ -1630,14 +1630,17 @@ export class Client extends ClientAbstract {
1630
1630
  * ```
1631
1631
  * @returns A generator yielding the contents of the file.
1632
1632
  */
1633
- async download(fileId, params) {
1633
+ async *download(fileId, params) {
1634
1634
  const fileId_ = FileID.decode(fileId);
1635
1635
  switch (fileId_.fileType) {
1636
1636
  case FileType.ChatPhoto: {
1637
1637
  const big = fileId_.params.thumbnailSource == ThumbnailSource.ChatPhotoBig;
1638
1638
  const peer = await this.getInputPeer(fileId_.params.chatId);
1639
1639
  const location = new types.InputPeerPhotoFileLocation({ big: big ? true : undefined, peer, photo_id: fileId_.params.mediaId });
1640
- return __classPrivateFieldGet(this, _Client_instances, "m", _Client_downloadInner).call(this, location, fileId_.dcId, params);
1640
+ for await (const chunk of __classPrivateFieldGet(this, _Client_instances, "m", _Client_downloadInner).call(this, location, fileId_.dcId, params)) {
1641
+ yield chunk;
1642
+ }
1643
+ break;
1641
1644
  }
1642
1645
  case FileType.Photo: {
1643
1646
  if (fileId_.params.mediaId == undefined || fileId_.params.accessHash == undefined || fileId_.params.fileReference == undefined || fileId_.params.thumbnailSize == undefined) {
@@ -1649,7 +1652,26 @@ export class Client extends ClientAbstract {
1649
1652
  file_reference: fileId_.params.fileReference,
1650
1653
  thumb_size: fileId_.params.thumbnailSize,
1651
1654
  });
1652
- return __classPrivateFieldGet(this, _Client_instances, "m", _Client_downloadInner).call(this, location, fileId_.dcId, params);
1655
+ for await (const chunk of __classPrivateFieldGet(this, _Client_instances, "m", _Client_downloadInner).call(this, location, fileId_.dcId, params)) {
1656
+ yield chunk;
1657
+ }
1658
+ break;
1659
+ }
1660
+ case FileType.Document:
1661
+ case FileType.Sticker: {
1662
+ if (fileId_.params.mediaId == undefined || fileId_.params.accessHash == undefined || fileId_.params.fileReference == undefined || fileId_.params.thumbnailSize == undefined) {
1663
+ UNREACHABLE();
1664
+ }
1665
+ const location = new types.InputDocumentFileLocation({
1666
+ id: fileId_.params.mediaId,
1667
+ access_hash: fileId_.params.accessHash,
1668
+ file_reference: fileId_.params.fileReference,
1669
+ thumb_size: fileId_.params.thumbnailSize,
1670
+ });
1671
+ for await (const chunk of __classPrivateFieldGet(this, _Client_instances, "m", _Client_downloadInner).call(this, location, fileId_.dcId, params)) {
1672
+ yield chunk;
1673
+ }
1674
+ break;
1653
1675
  }
1654
1676
  default:
1655
1677
  UNREACHABLE();
@@ -1690,7 +1712,7 @@ export class Client extends ClientAbstract {
1690
1712
  client.invoke.use(async (ctx, next) => {
1691
1713
  if (ctx.error instanceof AuthKeyUnregistered) {
1692
1714
  try {
1693
- const exportedAuth = await this.invoke(new functions.auth.exportAuthorization({ dc_id: dcId }));
1715
+ const exportedAuth = await this.api.auth.exportAuthorization({ dc_id: dcId });
1694
1716
  await client.authorize(exportedAuth);
1695
1717
  return true;
1696
1718
  }
@@ -1733,7 +1755,7 @@ export class Client extends ClientAbstract {
1733
1755
  return maybeStickerSetName[0];
1734
1756
  }
1735
1757
  else {
1736
- const stickerSet = await this.invoke(new functions.messages.getStickerSet({ stickerset: inputStickerSet, hash }));
1758
+ const stickerSet = await this.api.messages.getStickerSet({ stickerset: inputStickerSet, hash });
1737
1759
  const name = stickerSet[as](types.messages.StickerSet).set.short_name;
1738
1760
  await this.storage.updateStickerSetName(inputStickerSet.id, inputStickerSet.access_hash, name);
1739
1761
  return name;
@@ -1749,7 +1771,7 @@ export class Client extends ClientAbstract {
1749
1771
  * @returns The forwarded messages.
1750
1772
  */
1751
1773
  async forwardMessages(from, to, messageIds, params) {
1752
- const result = await this.invoke(new functions.messages.forwardMessages({
1774
+ const result = await this.api.messages.forwardMessages({
1753
1775
  from_peer: await this.getInputPeer(from),
1754
1776
  to_peer: await this.getInputPeer(to),
1755
1777
  id: messageIds,
@@ -1760,7 +1782,7 @@ export class Client extends ClientAbstract {
1760
1782
  send_as: params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined,
1761
1783
  drop_author: params?.dropSenderName || undefined,
1762
1784
  drop_media_captions: params?.dropCaption || undefined,
1763
- }));
1785
+ });
1764
1786
  return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, to, result);
1765
1787
  }
1766
1788
  /**
@@ -1781,7 +1803,7 @@ export class Client extends ClientAbstract {
1781
1803
  * @method
1782
1804
  */
1783
1805
  async getMe() {
1784
- const users = await this.invoke(new functions.users.getUsers({ id: [new types.InputUserSelf()] }));
1806
+ const users = await this.api.users.getUsers({ id: [new types.InputUserSelf()] });
1785
1807
  if (users.length < 1) {
1786
1808
  UNREACHABLE();
1787
1809
  }
@@ -1797,12 +1819,12 @@ export class Client extends ClientAbstract {
1797
1819
  */
1798
1820
  async answerCallbackQuery(id, params) {
1799
1821
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_assertBot).call(this, "answerCallbackQuery");
1800
- await this.invoke(new functions.messages.setBotCallbackAnswer({
1822
+ await this.api.messages.setBotCallbackAnswer({
1801
1823
  query_id: BigInt(id),
1802
1824
  cache_time: params?.cacheTime ?? 0,
1803
1825
  message: params?.text,
1804
1826
  alert: params?.alert ? true : undefined,
1805
- }));
1827
+ });
1806
1828
  }
1807
1829
  /**
1808
1830
  * Send a poll.
@@ -1844,7 +1866,7 @@ export class Client extends ClientAbstract {
1844
1866
  solution,
1845
1867
  solution_entities: solutionEntities,
1846
1868
  });
1847
- const result = await this.invoke(new functions.messages.sendMedia({
1869
+ const result = await this.api.messages.sendMedia({
1848
1870
  peer,
1849
1871
  random_id: randomId,
1850
1872
  silent,
@@ -1854,7 +1876,7 @@ export class Client extends ClientAbstract {
1854
1876
  send_as: sendAs,
1855
1877
  media,
1856
1878
  message: "",
1857
- }));
1879
+ });
1858
1880
  const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
1859
1881
  return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "poll");
1860
1882
  }
@@ -1905,7 +1927,7 @@ export class Client extends ClientAbstract {
1905
1927
  default:
1906
1928
  throw new Error("Invalid chat action: " + action);
1907
1929
  }
1908
- await this.invoke(new functions.messages.setTyping({ peer: await this.getInputPeer(chatId), action: action_, top_msg_id: params?.messageThreadId }));
1930
+ await this.api.messages.setTyping({ peer: await this.getInputPeer(chatId), action: action_, top_msg_id: params?.messageThreadId });
1909
1931
  }
1910
1932
  /**
1911
1933
  * Upload a file.
@@ -2005,20 +2027,20 @@ export class Client extends ClientAbstract {
2005
2027
  * @param commands The commands to set.
2006
2028
  */
2007
2029
  async setMyCommands(commands, params) {
2008
- await this.invoke(new functions.bots.setBotCommands({
2030
+ await this.api.bots.setBotCommands({
2009
2031
  commands: commands.map((v) => new types.BotCommand(v)),
2010
2032
  lang_code: params?.languageCode ?? "",
2011
2033
  scope: await botCommandScopeToTlObject(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)),
2012
- }));
2034
+ });
2013
2035
  }
2014
2036
  /**
2015
2037
  * Get the bot's commands in the given scope and/or language. Bot-only.
2016
2038
  */
2017
2039
  async getMyCommands(params) {
2018
- const commands_ = await this.invoke(new functions.bots.getBotCommands({
2040
+ const commands_ = await this.api.bots.getBotCommands({
2019
2041
  lang_code: params?.languageCode ?? "",
2020
2042
  scope: await botCommandScopeToTlObject(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)),
2021
- }));
2043
+ });
2022
2044
  return commands_.map((v) => ({ command: v.command, description: v.description }));
2023
2045
  }
2024
2046
  /**
@@ -2029,7 +2051,7 @@ export class Client extends ClientAbstract {
2029
2051
  * @param results The results to answer with.
2030
2052
  */
2031
2053
  async answerInlineQuery(id, results, params) {
2032
- await this.invoke(new functions.messages.setInlineBotResults({
2054
+ await this.api.messages.setInlineBotResults({
2033
2055
  query_id: BigInt(id),
2034
2056
  results: await Promise.all(results.map((v) => inlineQueryResultToTlObject(v, __classPrivateFieldGet(this, _Client_instances, "m", _Client_parseText).bind(this), __classPrivateFieldGet(this, _Client_usernameResolver, "f").bind(this)))),
2035
2057
  cache_time: params?.cacheTime ?? 300,
@@ -2038,7 +2060,7 @@ export class Client extends ClientAbstract {
2038
2060
  switch_pm: params?.button && params.button.startParameter ? new types.InlineBotSwitchPM({ text: params.button.text, start_param: params.button.startParameter }) : undefined,
2039
2061
  gallery: params?.isGallery ? true : undefined,
2040
2062
  next_offset: params?.nextOffset,
2041
- }));
2063
+ });
2042
2064
  }
2043
2065
  use(...middleware) {
2044
2066
  const composer = new Composer(...middleware);
@@ -2190,10 +2212,10 @@ export class Client extends ClientAbstract {
2190
2212
  async deleteMessages(chatId, messageIds, params) {
2191
2213
  const peer = await this.getInputPeer(chatId);
2192
2214
  if (peer instanceof types.InputPeerChannel) {
2193
- await this.invoke(new functions.channels.deleteMessages({ channel: new types.InputChannel(peer), id: messageIds }));
2215
+ await this.api.channels.deleteMessages({ channel: new types.InputChannel(peer), id: messageIds });
2194
2216
  }
2195
2217
  else {
2196
- await this.invoke(new functions.messages.deleteMessages({ id: messageIds, revoke: params?.onlyForMe ? undefined : true }));
2218
+ await this.api.messages.deleteMessages({ id: messageIds, revoke: params?.onlyForMe ? undefined : true });
2197
2219
  }
2198
2220
  }
2199
2221
  /**
@@ -2300,7 +2322,7 @@ export class Client extends ClientAbstract {
2300
2322
  return { messages, cdn };
2301
2323
  }
2302
2324
  /**
2303
- * Get chats.
2325
+ * Get chats from a chat list.
2304
2326
  *
2305
2327
  * @method
2306
2328
  */
@@ -2332,6 +2354,76 @@ export class Client extends ClientAbstract {
2332
2354
  chats = chats.slice(0, limit);
2333
2355
  return chats;
2334
2356
  }
2357
+ /**
2358
+ * Get a chat.
2359
+ *
2360
+ * @method
2361
+ */
2362
+ async getChat(chatId) {
2363
+ if (await this.storage.getAccountType() == "user") {
2364
+ let maybeChatId = null;
2365
+ if (typeof chatId === "number") {
2366
+ maybeChatId = chatId;
2367
+ }
2368
+ else if (typeof chatId === "string") {
2369
+ maybeChatId = __classPrivateFieldGet(this, _Client_instances, "m", _Client_tryGetChatId).call(this, getUsername(chatId));
2370
+ }
2371
+ else {
2372
+ UNREACHABLE();
2373
+ }
2374
+ if (maybeChatId != null) {
2375
+ const [chat] = __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChatAnywhere).call(this, maybeChatId);
2376
+ if (chat !== undefined) {
2377
+ return chat;
2378
+ }
2379
+ }
2380
+ }
2381
+ let inputPeer = null;
2382
+ if (typeof chatId === "number") {
2383
+ const chat = await constructChat3(chatId, -1, undefined, this[getEntity].bind(this));
2384
+ if (chat != null) {
2385
+ return chat;
2386
+ }
2387
+ }
2388
+ else {
2389
+ inputPeer = await this.getInputPeer(chatId);
2390
+ const chatId_ = peerToChatId(inputPeer);
2391
+ const chat = await constructChat3(chatId_, -1, undefined, this[getEntity].bind(this));
2392
+ if (chat != null) {
2393
+ return chat;
2394
+ }
2395
+ }
2396
+ if (inputPeer == null) {
2397
+ inputPeer = await this.getInputPeer(chatId);
2398
+ }
2399
+ if (inputPeer instanceof types.InputPeerChat) {
2400
+ const chats = await this.api.messages.getChats({ id: [inputPeer.chat_id] }).then((v) => v[as](types.messages.Chats));
2401
+ const chat = chats.chats[0];
2402
+ if (chat instanceof types.ChatEmpty) {
2403
+ UNREACHABLE();
2404
+ }
2405
+ return constructChat2(chat, -1, undefined);
2406
+ }
2407
+ else if (inputPeer instanceof types.InputPeerChannel) {
2408
+ const channels = await this.api.channels.getChannels({ id: [new types.InputChannel(inputPeer)] });
2409
+ const channel = channels.chats[0];
2410
+ if (channel instanceof types.ChatEmpty) {
2411
+ UNREACHABLE();
2412
+ }
2413
+ return constructChat2(channel, -1, undefined);
2414
+ }
2415
+ else if (inputPeer instanceof types.InputPeerUser) {
2416
+ const users = await this.api.users.getUsers({ id: [new types.InputUser(inputPeer)] });
2417
+ const user = users[0];
2418
+ if (user instanceof types.UserEmpty) {
2419
+ UNREACHABLE();
2420
+ }
2421
+ return constructChat2(user, -1, undefined);
2422
+ }
2423
+ else {
2424
+ UNREACHABLE();
2425
+ }
2426
+ }
2335
2427
  /**
2336
2428
  * Get chat history.
2337
2429
  *
@@ -2381,6 +2473,53 @@ export class Client extends ClientAbstract {
2381
2473
  }
2382
2474
  return messages;
2383
2475
  }
2476
+ /**
2477
+ * Get custom emoji documents for download.
2478
+ *
2479
+ * @param id Identifier of one or more of custom emojis.
2480
+ * @method
2481
+ */
2482
+ async getCustomEmojiDocuments(id) {
2483
+ id = Array.isArray(id) ? id : [id];
2484
+ if (!id.length) {
2485
+ throw new Error("No custom emoji ID provided");
2486
+ }
2487
+ const documents = new Array();
2488
+ let shouldFetch = false;
2489
+ for (const [i, id_] of id.entries()) {
2490
+ const maybeDocument = await this.storage.getCustomEmojiDocument(BigInt(id_));
2491
+ if (maybeDocument != null && Date.now() - maybeDocument[1].getTime() <= 30 * 60 * 1000) {
2492
+ const document_ = maybeDocument[0];
2493
+ const fileUniqueId = new FileUniqueID(FileUniqueType.Document, { mediaId: document_.id }).encode();
2494
+ const fileId = new FileID(null, null, FileType.Document, document_.dc_id, {
2495
+ mediaId: document_.id,
2496
+ accessHash: document_.access_hash,
2497
+ fileReference: document_.file_reference,
2498
+ }).encode();
2499
+ const document = constructDocument(document_, new types.DocumentAttributeFilename({ file_name: `${id[i] ?? "customEmoji"}.${extension(document_.mime_type)}` }), fileId, fileUniqueId);
2500
+ documents.push(document);
2501
+ }
2502
+ else {
2503
+ shouldFetch = true;
2504
+ break;
2505
+ }
2506
+ }
2507
+ if (!shouldFetch) {
2508
+ return documents;
2509
+ }
2510
+ const documents_ = await this.api.messages.getCustomEmojiDocuments({ document_id: id.map(BigInt) }).then((v) => v.map((v) => v[as](types.Document)));
2511
+ for (const [i, document_] of documents_.entries()) {
2512
+ const fileUniqueId = new FileUniqueID(FileUniqueType.Document, { mediaId: document_.id }).encode();
2513
+ const fileId = new FileID(null, null, FileType.Document, document_.dc_id, {
2514
+ mediaId: document_.id,
2515
+ accessHash: document_.access_hash,
2516
+ fileReference: document_.file_reference,
2517
+ }).encode();
2518
+ const document = constructDocument(document_, new types.DocumentAttributeFilename({ file_name: `${id[i] ?? "customEmoji"}.${extension(document_.mime_type)}` }), fileId, fileUniqueId);
2519
+ documents.push(document);
2520
+ }
2521
+ return documents;
2522
+ }
2384
2523
  }
2385
2524
  _a = Client, _Client_getMe = async function _Client_getMe() {
2386
2525
  if (__classPrivateFieldGet(this, _Client_lastGetMe, "f") != null) {
@@ -2552,9 +2691,9 @@ async function _Client_handleUpdate(update) {
2552
2691
  }, _Client_setMyInfo =
2553
2692
  //#endregion
2554
2693
  async function _Client_setMyInfo(info) {
2555
- await this.invoke(new functions.bots.setBotInfo({ bot: new types.InputUserSelf(), ...info }));
2694
+ await this.api.bots.setBotInfo({ bot: new types.InputUserSelf(), ...info });
2556
2695
  }, _Client_getMyInfo = function _Client_getMyInfo(languageCode) {
2557
- return this.invoke(new functions.bots.getBotInfo({ bot: new types.InputUserSelf(), lang_code: languageCode ?? "" }));
2696
+ return this.api.bots.getBotInfo({ bot: new types.InputUserSelf(), lang_code: languageCode ?? "" });
2558
2697
  }, _Client_resolveFileId = function _Client_resolveFileId(maybeFileId, expectedFileType) {
2559
2698
  let fileId = null;
2560
2699
  try {
@@ -2590,7 +2729,7 @@ async function _Client_setMyInfo(info) {
2590
2729
  const parseResult = caption_ !== undefined ? __classPrivateFieldGet(this, _Client_instances, "m", _Client_parseText).call(this, caption_, { parseMode: params?.parseMode, entities: params?.captionEntities }) : undefined;
2591
2730
  const caption = parseResult === undefined ? undefined : parseResult[0];
2592
2731
  const captionEntities = parseResult === undefined ? undefined : parseResult[1];
2593
- const result = await this.invoke(new functions.messages.sendMedia({
2732
+ const result = await this.api.messages.sendMedia({
2594
2733
  peer,
2595
2734
  random_id: randomId,
2596
2735
  silent,
@@ -2601,7 +2740,7 @@ async function _Client_setMyInfo(info) {
2601
2740
  media,
2602
2741
  message: caption ?? "",
2603
2742
  entities: captionEntities,
2604
- }));
2743
+ });
2605
2744
  return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
2606
2745
  }, _Client_sendChatUpdate = async function _Client_sendChatUpdate(chatId, added) {
2607
2746
  try {
@@ -2636,7 +2775,7 @@ async function _Client_setMyInfo(info) {
2636
2775
  }
2637
2776
  else {
2638
2777
  const pinnedChats = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getPinnedChats).call(this, listId);
2639
- const chat = await constructChat2(chatId, pinnedChats.indexOf(chatId), message, this[getEntity].bind(this));
2778
+ const chat = await constructChat3(chatId, pinnedChats.indexOf(chatId), message, this[getEntity].bind(this));
2640
2779
  if (chat == null) {
2641
2780
  UNREACHABLE();
2642
2781
  }
@@ -2657,7 +2796,7 @@ async function _Client_setMyInfo(info) {
2657
2796
  }
2658
2797
  else {
2659
2798
  const pinnedChats = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getPinnedChats).call(this, listId);
2660
- const chat = await constructChat2(chatId, pinnedChats.indexOf(chatId), message, this[getEntity].bind(this));
2799
+ const chat = await constructChat3(chatId, pinnedChats.indexOf(chatId), message, this[getEntity].bind(this));
2661
2800
  if (chat == null) {
2662
2801
  UNREACHABLE();
2663
2802
  }
@@ -2675,6 +2814,23 @@ async function _Client_setMyInfo(info) {
2675
2814
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendChatUpdate).call(this, chatId, false);
2676
2815
  }
2677
2816
  }
2817
+ }, _Client_tryGetChatId = function _Client_tryGetChatId(username) {
2818
+ username = username.toLowerCase();
2819
+ for (const chat of __classPrivateFieldGet(this, _Client_chats, "f").values()) {
2820
+ if ("username" in chat) {
2821
+ if (chat.username === username || chat.also?.some((v) => v.toLowerCase() === username)) {
2822
+ return chat.id;
2823
+ }
2824
+ }
2825
+ }
2826
+ for (const chat of __classPrivateFieldGet(this, _Client_archivedChats, "f").values()) {
2827
+ if ("username" in chat) {
2828
+ if (chat.username === username || chat.also?.some((v) => v.toLowerCase() === username)) {
2829
+ return chat.id;
2830
+ }
2831
+ }
2832
+ }
2833
+ return null;
2678
2834
  }, _Client_getChatAnywhere = function _Client_getChatAnywhere(chatId) {
2679
2835
  let chat = __classPrivateFieldGet(this, _Client_chats, "f").get(chatId);
2680
2836
  if (chat) {
@@ -2698,14 +2854,14 @@ async function _Client_setMyInfo(info) {
2698
2854
  const chats = await this.storage.getChats(0);
2699
2855
  const archivedChats = await this.storage.getChats(1);
2700
2856
  for (const { chatId, pinned, topMessageId } of chats) {
2701
- const chat = await constructChat3(chatId, pinned, topMessageId, this[getEntity].bind(this), this.getMessage.bind(this));
2857
+ const chat = await constructChat4(chatId, pinned, topMessageId, this[getEntity].bind(this), this.getMessage.bind(this));
2702
2858
  if (chat == null) {
2703
2859
  continue;
2704
2860
  }
2705
2861
  __classPrivateFieldGet(this, _Client_chats, "f").set(chat.id, chat);
2706
2862
  }
2707
2863
  for (const { chatId, pinned, topMessageId } of archivedChats) {
2708
- const chat = await constructChat3(chatId, pinned, topMessageId, this[getEntity].bind(this), this.getMessage.bind(this));
2864
+ const chat = await constructChat4(chatId, pinned, topMessageId, this[getEntity].bind(this), this.getMessage.bind(this));
2709
2865
  if (chat == null) {
2710
2866
  continue;
2711
2867
  }
@@ -2769,14 +2925,14 @@ async function _Client_setMyInfo(info) {
2769
2925
  }, _Client_updateOrAddChat = async function _Client_updateOrAddChat(chatId) {
2770
2926
  const [chat, listId] = __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChatAnywhere).call(this, chatId);
2771
2927
  if (chat !== undefined) {
2772
- const newChat = await constructChat2(chatId, chat.pinned, chat.lastMessage, this[getEntity].bind(this));
2928
+ const newChat = await constructChat3(chatId, chat.pinned, chat.lastMessage, this[getEntity].bind(this));
2773
2929
  if (newChat != null) {
2774
2930
  __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChatList).call(this, listId).set(chatId, newChat);
2775
2931
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendChatUpdate).call(this, chatId, false);
2776
2932
  }
2777
2933
  }
2778
2934
  else {
2779
- const chat = await constructChat3(chatId, -1, -1, this[getEntity].bind(this), this.getMessage.bind(this));
2935
+ const chat = await constructChat4(chatId, -1, -1, this[getEntity].bind(this), this.getMessage.bind(this));
2780
2936
  if (chat != null) {
2781
2937
  __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChatList).call(this, 0).set(chatId, chat);
2782
2938
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_reassignChatLastMessage).call(this, chatId, false, false);