@mtkruto/node 0.1.129 → 0.1.131

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 (41) 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/3_types.d.ts +363 -3
  6. package/esm/client/5_client.d.ts +113 -5
  7. package/esm/client/5_client.js +561 -103
  8. package/esm/deps/deno.land/std@0.209.0/media_types/extension.d.ts +17 -0
  9. package/esm/deps/deno.land/std@0.209.0/media_types/extension.js +26 -0
  10. package/esm/deps/deno.land/std@0.209.0/media_types/extensions_by_type.d.ts +20 -0
  11. package/esm/deps/deno.land/std@0.209.0/media_types/extensions_by_type.js +31 -0
  12. package/esm/storage/0_storage.d.ts +3 -1
  13. package/esm/storage/0_storage.js +18 -5
  14. package/esm/tl/0_tl_raw_reader.js +1 -1
  15. package/esm/tl/3_utilities.d.ts +1 -0
  16. package/esm/tl/3_utilities.js +11 -0
  17. package/esm/types/1__getters.d.ts +1 -0
  18. package/esm/types/1_sticker.js +5 -4
  19. package/esm/types/4_chat.d.ts +3 -2
  20. package/esm/types/4_chat.js +16 -27
  21. package/package.json +1 -1
  22. package/script/0_deps.d.ts +1 -0
  23. package/script/0_deps.js +11 -1
  24. package/script/4_constants.d.ts +1 -1
  25. package/script/4_constants.js +1 -1
  26. package/script/client/3_types.d.ts +363 -3
  27. package/script/client/5_client.d.ts +113 -5
  28. package/script/client/5_client.js +558 -100
  29. package/script/deps/deno.land/std@0.209.0/media_types/extension.d.ts +17 -0
  30. package/script/deps/deno.land/std@0.209.0/media_types/extension.js +30 -0
  31. package/script/deps/deno.land/std@0.209.0/media_types/extensions_by_type.d.ts +20 -0
  32. package/script/deps/deno.land/std@0.209.0/media_types/extensions_by_type.js +35 -0
  33. package/script/storage/0_storage.d.ts +3 -1
  34. package/script/storage/0_storage.js +18 -5
  35. package/script/tl/0_tl_raw_reader.js +1 -1
  36. package/script/tl/3_utilities.d.ts +1 -0
  37. package/script/tl/3_utilities.js +13 -1
  38. package/script/types/1__getters.d.ts +1 -0
  39. package/script/types/1_sticker.js +4 -3
  40. package/script/types/4_chat.d.ts +3 -2
  41. 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_sendDocumentInner, _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");
@@ -231,6 +231,51 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
231
231
  const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
232
232
  return this.sendDocument(effectiveMessage.chat.id, document, { ...params, replyToMessageId });
233
233
  },
234
+ replyContact: (firstName, number, params) => {
235
+ const effectiveMessage = mustGetMsg();
236
+ const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
237
+ return this.sendContact(effectiveMessage.chat.id, firstName, number, { ...params, replyToMessageId });
238
+ },
239
+ replyLocation: (latitude, longitude, params) => {
240
+ const effectiveMessage = mustGetMsg();
241
+ const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
242
+ return this.sendLocation(effectiveMessage.chat.id, latitude, longitude, { ...params, replyToMessageId });
243
+ },
244
+ replyDice: (params) => {
245
+ const effectiveMessage = mustGetMsg();
246
+ const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
247
+ return this.sendDice(effectiveMessage.chat.id, { ...params, replyToMessageId });
248
+ },
249
+ replyVenue: (latitude, longitude, title, address, params) => {
250
+ const effectiveMessage = mustGetMsg();
251
+ const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
252
+ return this.sendVenue(effectiveMessage.chat.id, latitude, longitude, title, address, { ...params, replyToMessageId });
253
+ },
254
+ replyVideo: (document, params) => {
255
+ const effectiveMessage = mustGetMsg();
256
+ const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
257
+ return this.sendDocument(effectiveMessage.chat.id, document, { ...params, replyToMessageId });
258
+ },
259
+ replyAnimation: (document, params) => {
260
+ const effectiveMessage = mustGetMsg();
261
+ const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
262
+ return this.sendAnimation(effectiveMessage.chat.id, document, { ...params, replyToMessageId });
263
+ },
264
+ replyVoice: (document, params) => {
265
+ const effectiveMessage = mustGetMsg();
266
+ const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
267
+ return this.sendVoice(effectiveMessage.chat.id, document, { ...params, replyToMessageId });
268
+ },
269
+ replyAudio: (document, params) => {
270
+ const effectiveMessage = mustGetMsg();
271
+ const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
272
+ return this.sendAudio(effectiveMessage.chat.id, document, { ...params, replyToMessageId });
273
+ },
274
+ replyVideoNote: (videoNote, params) => {
275
+ const effectiveMessage = mustGetMsg();
276
+ const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
277
+ return this.sendVideoNote(effectiveMessage.chat.id, videoNote, { ...params, replyToMessageId });
278
+ },
234
279
  delete: () => {
235
280
  const effectiveMessage = mustGetMsg();
236
281
  return this.deleteMessage(effectiveMessage.chat.id, effectiveMessage.id);
@@ -522,7 +567,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
522
567
  throw new Error(`${source}: not a bot client`);
523
568
  }
524
569
  }, _Client_fetchState = async function _Client_fetchState(source) {
525
- const state = await this.invoke(new _2_tl_js_1.functions.updates.getState());
570
+ const state = await this.api.updates.getState();
526
571
  __classPrivateFieldSet(this, _Client_updateState, state, "f");
527
572
  d("state fetched [%s]", source);
528
573
  }, exports.handleMigrationError)](err) {
@@ -588,7 +633,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
588
633
  if (typeof params === "string") {
589
634
  while (true) {
590
635
  try {
591
- const auth = await this.invoke(new _2_tl_js_1.functions.auth.importBotAuthorization({ api_id: this.apiId, api_hash: this.apiHash, bot_auth_token: params, flags: 0 }));
636
+ const auth = await this.api.auth.importBotAuthorization({ api_id: this.apiId, api_hash: this.apiHash, bot_auth_token: params, flags: 0 });
592
637
  __classPrivateFieldSet(this, _Client_selfId, Number(auth[_2_tl_js_1.as](_2_tl_js_1.types.auth.Authorization).user.id), "f");
593
638
  await this.storage.setAccountType("bot");
594
639
  break;
@@ -610,7 +655,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
610
655
  return;
611
656
  }
612
657
  if (params instanceof _2_tl_js_1.types.auth.ExportedAuthorization) {
613
- await this.invoke(new _2_tl_js_1.functions.auth.importAuthorization({ id: params.id, bytes: params.bytes }));
658
+ await this.api.auth.importAuthorization({ id: params.id, bytes: params.bytes });
614
659
  dAuth("authorization imported");
615
660
  return;
616
661
  }
@@ -621,12 +666,12 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
621
666
  while (true) {
622
667
  try {
623
668
  phone = typeof params.phone === "string" ? params.phone : await params.phone();
624
- const sendCode = () => this.invoke(new _2_tl_js_1.functions.auth.sendCode({
669
+ const sendCode = () => this.api.auth.sendCode({
625
670
  phone_number: phone,
626
671
  api_id: this.apiId,
627
672
  api_hash: this.apiHash,
628
673
  settings: new _2_tl_js_1.types.CodeSettings(),
629
- })).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.auth.SentCode));
674
+ }).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.auth.SentCode));
630
675
  try {
631
676
  sentCode = await sendCode();
632
677
  }
@@ -656,11 +701,11 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
656
701
  code: while (true) {
657
702
  const code = typeof params.code === "string" ? params.code : await params.code();
658
703
  try {
659
- const auth = await this.invoke(new _2_tl_js_1.functions.auth.signIn({
704
+ const auth = await this.api.auth.signIn({
660
705
  phone_number: phone,
661
706
  phone_code: code,
662
707
  phone_code_hash: sentCode.phone_code_hash,
663
- }));
708
+ });
664
709
  __classPrivateFieldSet(this, _Client_selfId, Number(auth[_2_tl_js_1.as](_2_tl_js_1.types.auth.Authorization).user.id), "f");
665
710
  await this.storage.setAccountType("user");
666
711
  dAuth("authorized as user");
@@ -682,14 +727,14 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
682
727
  throw err;
683
728
  }
684
729
  password: while (true) {
685
- const ap = await this.invoke(new _2_tl_js_1.functions.account.getPassword());
730
+ const ap = await this.api.account.getPassword();
686
731
  if (!(ap.current_algo instanceof _2_tl_js_1.types.PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow)) {
687
732
  throw new Error(`Handling ${ap.current_algo?.[_2_tl_js_1.name]} not implemented`);
688
733
  }
689
734
  try {
690
735
  const password = typeof params.password === "string" ? params.password : await params.password(ap.hint ?? null);
691
736
  const input = await (0, _0_password_js_1.checkPassword)(password, ap);
692
- const auth = await this.invoke(new _2_tl_js_1.functions.auth.checkPassword({ password: input }));
737
+ const auth = await this.api.auth.checkPassword({ password: input });
693
738
  __classPrivateFieldSet(this, _Client_selfId, Number(auth[_2_tl_js_1.as](_2_tl_js_1.types.auth.Authorization).user.id), "f");
694
739
  await this.storage.setAccountType("user");
695
740
  dAuth("authorized as user");
@@ -737,7 +782,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
737
782
  return this.invoke(function_, true);
738
783
  }
739
784
  async getUserAccessHash(userId) {
740
- const users = await this.invoke(new _2_tl_js_1.functions.users.getUsers({ id: [new _2_tl_js_1.types.InputUser({ user_id: userId, access_hash: 0n })] }));
785
+ const users = await this.api.users.getUsers({ id: [new _2_tl_js_1.types.InputUser({ user_id: userId, access_hash: 0n })] });
741
786
  return users[0]?.[_2_tl_js_1.as](_2_tl_js_1.types.User).access_hash ?? 0n;
742
787
  }
743
788
  async getInputPeer(id) {
@@ -755,7 +800,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
755
800
  }
756
801
  [(_Client_initConnection = async function _Client_initConnection() {
757
802
  if (!__classPrivateFieldGet(this, _Client_connectionInited, "f")) {
758
- await this.invoke(new _2_tl_js_1.functions.initConnection({
803
+ await this.api.initConnection({
759
804
  api_id: this.apiId,
760
805
  app_version: this.appVersion,
761
806
  device_model: this.deviceModel,
@@ -767,7 +812,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
767
812
  }),
768
813
  system_lang_code: this.systemLangCode,
769
814
  system_version: this.systemVersion,
770
- }));
815
+ });
771
816
  __classPrivateFieldSet(this, _Client_connectionInited, true, "f");
772
817
  d("connection inited");
773
818
  }
@@ -910,7 +955,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
910
955
  reject(__classPrivateFieldGet(this, _Client_pingLoopAbortSignal, "f")?.signal.reason);
911
956
  };
912
957
  });
913
- await this.invoke(new _2_tl_js_1.functions.ping_delay_disconnect({ ping_id: (0, _1_utilities_js_1.getRandomId)(), disconnect_delay: __classPrivateFieldGet(this, _Client_pingInterval, "f") / 1000 + 15 }));
958
+ await this.api.ping_delay_disconnect({ ping_id: (0, _1_utilities_js_1.getRandomId)(), disconnect_delay: __classPrivateFieldGet(this, _Client_pingInterval, "f") / 1000 + 15 });
914
959
  if (Date.now() - __classPrivateFieldGet(this, _Client_lastUpdates, "f").getTime() >= 15 * 60 * 1000) {
915
960
  (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "lastUpdates"));
916
961
  }
@@ -920,20 +965,20 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
920
965
  }
921
966
  }
922
967
  }, _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
968
  let n = 1;
935
969
  while (true) {
936
970
  try {
971
+ if (!__classPrivateFieldGet(this, _Client_auth, "f") || !this.transport) {
972
+ if (__classPrivateFieldGet(this, _Client_autoStart, "f") && !__classPrivateFieldGet(this, _Client_autoStarted, "f")) {
973
+ await this.start();
974
+ }
975
+ else {
976
+ throw new ConnectionError("Not connected");
977
+ }
978
+ }
979
+ if (!__classPrivateFieldGet(this, _Client_auth, "f") || !this.transport) {
980
+ (0, _1_utilities_js_1.UNREACHABLE)();
981
+ }
937
982
  let seqNo = __classPrivateFieldGet(this, _Client_state, "f").seqNo * 2;
938
983
  if (!(function_ instanceof _2_tl_js_1.functions.ping) && !(function_ instanceof _2_tl_js_1.types.Msgs_ack)) {
939
984
  seqNo++;
@@ -1236,7 +1281,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1236
1281
  try {
1237
1282
  let state = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
1238
1283
  while (true) {
1239
- const difference = await this.invoke(new _2_tl_js_1.functions.updates.getDifference({ pts: state.pts, date: state.date, qts: state.qts ?? 0 }));
1284
+ const difference = await this.api.updates.getDifference({ pts: state.pts, date: state.date, qts: state.qts ?? 0 });
1240
1285
  if (difference instanceof _2_tl_js_1.types.updates.Difference || difference instanceof _2_tl_js_1.types.updates.DifferenceSlice) {
1241
1286
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, difference.chats);
1242
1287
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUsers).call(this, difference.users);
@@ -1285,12 +1330,12 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1285
1330
  let pts = pts_ == null ? 1 : pts_;
1286
1331
  while (true) {
1287
1332
  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.invoke(new _2_tl_js_1.functions.updates.getChannelDifference({
1333
+ const difference = await this.api.updates.getChannelDifference({
1289
1334
  pts,
1290
1335
  channel: new _2_tl_js_1.types.InputChannel({ channel_id: channelId, access_hash }),
1291
1336
  filter: new _2_tl_js_1.types.ChannelMessagesFilterEmpty(),
1292
1337
  limit: await this.storage.getAccountType() == "user" ? _4_constants_js_1.CHANNEL_DIFFERENCE_LIMIT_USER : _4_constants_js_1.CHANNEL_DIFFERENCE_LIMIT_BOT,
1293
- }));
1338
+ });
1294
1339
  if (difference instanceof _2_tl_js_1.types.updates.ChannelDifference) {
1295
1340
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, difference.chats);
1296
1341
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUsers).call(this, difference.users);
@@ -1327,7 +1372,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1327
1372
  }
1328
1373
  }
1329
1374
  }, _Client_getChannelAccessHash = async function _Client_getChannelAccessHash(channelId) {
1330
- const channels = await this.invoke(new _2_tl_js_1.functions.channels.getChannels({ id: [new _2_tl_js_1.types.InputChannel({ channel_id: channelId, access_hash: 0n })] }));
1375
+ const channels = await this.api.channels.getChannels({ id: [new _2_tl_js_1.types.InputChannel({ channel_id: channelId, access_hash: 0n })] });
1331
1376
  return channels.chats[0][_2_tl_js_1.as](_2_tl_js_1.types.Channel).access_hash ?? 0n;
1332
1377
  }, _Client_getInputPeerInner = async function _Client_getInputPeerInner(id) {
1333
1378
  if (typeof id === "string") {
@@ -1345,7 +1390,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1345
1390
  }
1346
1391
  }
1347
1392
  else {
1348
- const resolved = await this.invoke(new _2_tl_js_1.functions.contacts.resolveUsername({ username: id }));
1393
+ const resolved = await this.api.contacts.resolveUsername({ username: id });
1349
1394
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, resolved.chats);
1350
1395
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUsers).call(this, resolved.users);
1351
1396
  if (resolved.peer instanceof _2_tl_js_1.types.PeerUser) {
@@ -1467,7 +1512,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1467
1512
  const replyToMsgId = params?.replyToMessageId;
1468
1513
  const topMsgId = params?.messageThreadId;
1469
1514
  const sendAs = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_resolveSendAs).call(this, params);
1470
- const result = await this.invoke(new _2_tl_js_1.functions.messages.sendMessage({
1515
+ const result = await this.api.messages.sendMessage({
1471
1516
  peer,
1472
1517
  random_id: randomId,
1473
1518
  message,
@@ -1478,7 +1523,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1478
1523
  send_as: sendAs,
1479
1524
  entities,
1480
1525
  reply_markup: replyMarkup,
1481
- }));
1526
+ });
1482
1527
  const message_ = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
1483
1528
  return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message_, "text");
1484
1529
  }
@@ -1493,14 +1538,14 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1493
1538
  */
1494
1539
  async editMessageText(chatId, messageId, text, params) {
1495
1540
  const [message, entities] = __classPrivateFieldGet(this, _Client_instances, "m", _Client_parseText).call(this, text, params);
1496
- const result = await this.invoke(new _2_tl_js_1.functions.messages.editMessage({
1541
+ const result = await this.api.messages.editMessage({
1497
1542
  id: messageId,
1498
1543
  peer: await this.getInputPeer(chatId),
1499
1544
  entities,
1500
1545
  message,
1501
1546
  no_webpage: params?.disableWebPagePreview ? true : undefined,
1502
1547
  reply_markup: await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params),
1503
- }));
1548
+ });
1504
1549
  const message_ = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
1505
1550
  return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message_, "text");
1506
1551
  }
@@ -1583,15 +1628,15 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1583
1628
  }
1584
1629
  if (shouldFetch) {
1585
1630
  if (peer instanceof _2_tl_js_1.types.InputPeerChannel) {
1586
- messages_ = await this.invoke(new _2_tl_js_1.functions.channels.getMessages({
1631
+ messages_ = await this.api.channels.getMessages({
1587
1632
  channel: new _2_tl_js_1.types.InputChannel(peer),
1588
1633
  id: messageIds.map((v) => new _2_tl_js_1.types.InputMessageID({ id: v })),
1589
- })).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.messages.ChannelMessages).messages);
1634
+ }).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.messages.ChannelMessages).messages);
1590
1635
  }
1591
1636
  else {
1592
- messages_ = await this.invoke(new _2_tl_js_1.functions.messages.getMessages({
1637
+ messages_ = await this.api.messages.getMessages({
1593
1638
  id: messageIds.map((v) => new _2_tl_js_1.types.InputMessageID({ id: v })),
1594
- })).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.messages.Messages).messages);
1639
+ }).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.messages.Messages).messages);
1595
1640
  }
1596
1641
  }
1597
1642
  const messages = new Array();
@@ -1635,14 +1680,17 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1635
1680
  * ```
1636
1681
  * @returns A generator yielding the contents of the file.
1637
1682
  */
1638
- async download(fileId, params) {
1683
+ async *download(fileId, params) {
1639
1684
  const fileId_ = _3_types_js_1.FileID.decode(fileId);
1640
1685
  switch (fileId_.fileType) {
1641
1686
  case _3_types_js_1.FileType.ChatPhoto: {
1642
1687
  const big = fileId_.params.thumbnailSource == _3_types_js_1.ThumbnailSource.ChatPhotoBig;
1643
1688
  const peer = await this.getInputPeer(fileId_.params.chatId);
1644
1689
  const location = new _2_tl_js_1.types.InputPeerPhotoFileLocation({ big: big ? true : undefined, peer, photo_id: fileId_.params.mediaId });
1645
- return __classPrivateFieldGet(this, _Client_instances, "m", _Client_downloadInner).call(this, location, fileId_.dcId, params);
1690
+ for await (const chunk of __classPrivateFieldGet(this, _Client_instances, "m", _Client_downloadInner).call(this, location, fileId_.dcId, params)) {
1691
+ yield chunk;
1692
+ }
1693
+ break;
1646
1694
  }
1647
1695
  case _3_types_js_1.FileType.Photo: {
1648
1696
  if (fileId_.params.mediaId == undefined || fileId_.params.accessHash == undefined || fileId_.params.fileReference == undefined || fileId_.params.thumbnailSize == undefined) {
@@ -1654,7 +1702,31 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1654
1702
  file_reference: fileId_.params.fileReference,
1655
1703
  thumb_size: fileId_.params.thumbnailSize,
1656
1704
  });
1657
- return __classPrivateFieldGet(this, _Client_instances, "m", _Client_downloadInner).call(this, location, fileId_.dcId, params);
1705
+ for await (const chunk of __classPrivateFieldGet(this, _Client_instances, "m", _Client_downloadInner).call(this, location, fileId_.dcId, params)) {
1706
+ yield chunk;
1707
+ }
1708
+ break;
1709
+ }
1710
+ case _3_types_js_1.FileType.Document:
1711
+ case _3_types_js_1.FileType.Sticker:
1712
+ case _3_types_js_1.FileType.VideoNote:
1713
+ case _3_types_js_1.FileType.Video:
1714
+ case _3_types_js_1.FileType.Audio:
1715
+ case _3_types_js_1.FileType.Voice:
1716
+ case _3_types_js_1.FileType.Animation: {
1717
+ if (fileId_.params.mediaId == undefined || fileId_.params.accessHash == undefined || fileId_.params.fileReference == undefined || fileId_.params.thumbnailSize == undefined) {
1718
+ (0, _1_utilities_js_1.UNREACHABLE)();
1719
+ }
1720
+ const location = new _2_tl_js_1.types.InputDocumentFileLocation({
1721
+ id: fileId_.params.mediaId,
1722
+ access_hash: fileId_.params.accessHash,
1723
+ file_reference: fileId_.params.fileReference,
1724
+ thumb_size: fileId_.params.thumbnailSize,
1725
+ });
1726
+ for await (const chunk of __classPrivateFieldGet(this, _Client_instances, "m", _Client_downloadInner).call(this, location, fileId_.dcId, params)) {
1727
+ yield chunk;
1728
+ }
1729
+ break;
1658
1730
  }
1659
1731
  default:
1660
1732
  (0, _1_utilities_js_1.UNREACHABLE)();
@@ -1695,7 +1767,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1695
1767
  client.invoke.use(async (ctx, next) => {
1696
1768
  if (ctx.error instanceof _4_errors_js_1.AuthKeyUnregistered) {
1697
1769
  try {
1698
- const exportedAuth = await this.invoke(new _2_tl_js_1.functions.auth.exportAuthorization({ dc_id: dcId }));
1770
+ const exportedAuth = await this.api.auth.exportAuthorization({ dc_id: dcId });
1699
1771
  await client.authorize(exportedAuth);
1700
1772
  return true;
1701
1773
  }
@@ -1738,7 +1810,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1738
1810
  return maybeStickerSetName[0];
1739
1811
  }
1740
1812
  else {
1741
- const stickerSet = await this.invoke(new _2_tl_js_1.functions.messages.getStickerSet({ stickerset: inputStickerSet, hash }));
1813
+ const stickerSet = await this.api.messages.getStickerSet({ stickerset: inputStickerSet, hash });
1742
1814
  const name = stickerSet[_2_tl_js_1.as](_2_tl_js_1.types.messages.StickerSet).set.short_name;
1743
1815
  await this.storage.updateStickerSetName(inputStickerSet.id, inputStickerSet.access_hash, name);
1744
1816
  return name;
@@ -1754,7 +1826,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1754
1826
  * @returns The forwarded messages.
1755
1827
  */
1756
1828
  async forwardMessages(from, to, messageIds, params) {
1757
- const result = await this.invoke(new _2_tl_js_1.functions.messages.forwardMessages({
1829
+ const result = await this.api.messages.forwardMessages({
1758
1830
  from_peer: await this.getInputPeer(from),
1759
1831
  to_peer: await this.getInputPeer(to),
1760
1832
  id: messageIds,
@@ -1765,7 +1837,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1765
1837
  send_as: params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined,
1766
1838
  drop_author: params?.dropSenderName || undefined,
1767
1839
  drop_media_captions: params?.dropCaption || undefined,
1768
- }));
1840
+ });
1769
1841
  return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, to, result);
1770
1842
  }
1771
1843
  /**
@@ -1786,7 +1858,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1786
1858
  * @method
1787
1859
  */
1788
1860
  async getMe() {
1789
- const users = await this.invoke(new _2_tl_js_1.functions.users.getUsers({ id: [new _2_tl_js_1.types.InputUserSelf()] }));
1861
+ const users = await this.api.users.getUsers({ id: [new _2_tl_js_1.types.InputUserSelf()] });
1790
1862
  if (users.length < 1) {
1791
1863
  (0, _1_utilities_js_1.UNREACHABLE)();
1792
1864
  }
@@ -1802,12 +1874,12 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1802
1874
  */
1803
1875
  async answerCallbackQuery(id, params) {
1804
1876
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_assertBot).call(this, "answerCallbackQuery");
1805
- await this.invoke(new _2_tl_js_1.functions.messages.setBotCallbackAnswer({
1877
+ await this.api.messages.setBotCallbackAnswer({
1806
1878
  query_id: BigInt(id),
1807
1879
  cache_time: params?.cacheTime ?? 0,
1808
1880
  message: params?.text,
1809
1881
  alert: params?.alert ? true : undefined,
1810
- }));
1882
+ });
1811
1883
  }
1812
1884
  /**
1813
1885
  * Send a poll.
@@ -1849,7 +1921,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1849
1921
  solution,
1850
1922
  solution_entities: solutionEntities,
1851
1923
  });
1852
- const result = await this.invoke(new _2_tl_js_1.functions.messages.sendMedia({
1924
+ const result = await this.api.messages.sendMedia({
1853
1925
  peer,
1854
1926
  random_id: randomId,
1855
1927
  silent,
@@ -1859,7 +1931,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1859
1931
  send_as: sendAs,
1860
1932
  media,
1861
1933
  message: "",
1862
- }));
1934
+ });
1863
1935
  const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
1864
1936
  return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "poll");
1865
1937
  }
@@ -1910,7 +1982,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1910
1982
  default:
1911
1983
  throw new Error("Invalid chat action: " + action);
1912
1984
  }
1913
- await this.invoke(new _2_tl_js_1.functions.messages.setTyping({ peer: await this.getInputPeer(chatId), action: action_, top_msg_id: params?.messageThreadId }));
1985
+ await this.api.messages.setTyping({ peer: await this.getInputPeer(chatId), action: action_, top_msg_id: params?.messageThreadId });
1914
1986
  }
1915
1987
  /**
1916
1988
  * Upload a file.
@@ -2010,20 +2082,20 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2010
2082
  * @param commands The commands to set.
2011
2083
  */
2012
2084
  async setMyCommands(commands, params) {
2013
- await this.invoke(new _2_tl_js_1.functions.bots.setBotCommands({
2085
+ await this.api.bots.setBotCommands({
2014
2086
  commands: commands.map((v) => new _2_tl_js_1.types.BotCommand(v)),
2015
2087
  lang_code: params?.languageCode ?? "",
2016
2088
  scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)),
2017
- }));
2089
+ });
2018
2090
  }
2019
2091
  /**
2020
2092
  * Get the bot's commands in the given scope and/or language. Bot-only.
2021
2093
  */
2022
2094
  async getMyCommands(params) {
2023
- const commands_ = await this.invoke(new _2_tl_js_1.functions.bots.getBotCommands({
2095
+ const commands_ = await this.api.bots.getBotCommands({
2024
2096
  lang_code: params?.languageCode ?? "",
2025
2097
  scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)),
2026
- }));
2098
+ });
2027
2099
  return commands_.map((v) => ({ command: v.command, description: v.description }));
2028
2100
  }
2029
2101
  /**
@@ -2034,7 +2106,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2034
2106
  * @param results The results to answer with.
2035
2107
  */
2036
2108
  async answerInlineQuery(id, results, params) {
2037
- await this.invoke(new _2_tl_js_1.functions.messages.setInlineBotResults({
2109
+ await this.api.messages.setInlineBotResults({
2038
2110
  query_id: BigInt(id),
2039
2111
  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
2112
  cache_time: params?.cacheTime ?? 300,
@@ -2043,7 +2115,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2043
2115
  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
2116
  gallery: params?.isGallery ? true : undefined,
2045
2117
  next_offset: params?.nextOffset,
2046
- }));
2118
+ });
2047
2119
  }
2048
2120
  use(...middleware) {
2049
2121
  const composer = new _4_composer_js_1.Composer(...middleware);
@@ -2195,10 +2267,10 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2195
2267
  async deleteMessages(chatId, messageIds, params) {
2196
2268
  const peer = await this.getInputPeer(chatId);
2197
2269
  if (peer instanceof _2_tl_js_1.types.InputPeerChannel) {
2198
- await this.invoke(new _2_tl_js_1.functions.channels.deleteMessages({ channel: new _2_tl_js_1.types.InputChannel(peer), id: messageIds }));
2270
+ await this.api.channels.deleteMessages({ channel: new _2_tl_js_1.types.InputChannel(peer), id: messageIds });
2199
2271
  }
2200
2272
  else {
2201
- await this.invoke(new _2_tl_js_1.functions.messages.deleteMessages({ id: messageIds, revoke: params?.onlyForMe ? undefined : true }));
2273
+ await this.api.messages.deleteMessages({ id: messageIds, revoke: params?.onlyForMe ? undefined : true });
2202
2274
  }
2203
2275
  }
2204
2276
  /**
@@ -2251,37 +2323,255 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2251
2323
  * @param document The document to send.
2252
2324
  */
2253
2325
  async sendDocument(chatId, document, params) {
2254
- let media = null;
2255
- const spoiler = params?.hasSpoiler ? true : undefined;
2256
- if (typeof document === "string") {
2257
- const fileId = __classPrivateFieldGet(this, _Client_instances, "m", _Client_resolveFileId).call(this, document, _3_types_js_1.FileType.Document);
2258
- if (fileId != null) {
2259
- media = new _2_tl_js_1.types.InputMediaDocument({
2260
- id: new _2_tl_js_1.types.InputDocument(fileId),
2261
- spoiler,
2262
- });
2263
- }
2264
- }
2265
- if (media == null) {
2266
- if (typeof document === "string" && (0, _0_utilities_js_1.isHttpUrl)(document)) {
2267
- media = new _2_tl_js_1.types.InputMediaDocumentExternal({ url: document, spoiler });
2268
- }
2269
- else {
2270
- const [contents, fileName_] = await (0, _0_utilities_js_1.getFileContents)(document);
2271
- const fileName = params?.fileName ?? fileName_;
2272
- const mimeType = params?.mimeType ?? (0, _0_deps_js_1.contentType)(fileName.split(".").slice(-1)[0]) ?? "application/octet-stream";
2273
- const file = await this.upload(contents, { fileName, chunkSize: params?.chunkSize, signal: params?.signal });
2274
- media = new _2_tl_js_1.types.InputMediaUploadedDocument({
2275
- file,
2276
- spoiler,
2277
- attributes: [new _2_tl_js_1.types.DocumentAttributeFilename({ file_name: fileName })],
2278
- mime_type: mimeType,
2279
- });
2280
- }
2281
- }
2282
- const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendMedia).call(this, chatId, media, params);
2326
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, document, params, _3_types_js_1.FileType.Document, []);
2283
2327
  return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "document");
2284
2328
  }
2329
+ /**
2330
+ * Send a video.
2331
+ *
2332
+ * @method
2333
+ * @param chatId The chat to send the video to.
2334
+ * @param video The video to send.
2335
+ */
2336
+ async sendVideo(chatId, video, params) {
2337
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, video, params, _3_types_js_1.FileType.Video, [
2338
+ new _2_tl_js_1.types.DocumentAttributeVideo({
2339
+ supports_streaming: params?.supportsStreaming ? true : undefined,
2340
+ w: params?.width ?? 0,
2341
+ h: params?.height ?? 0,
2342
+ duration: params?.duration ?? 0,
2343
+ }),
2344
+ ]);
2345
+ return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "video");
2346
+ }
2347
+ /**
2348
+ * Send an animation.
2349
+ *
2350
+ * @method
2351
+ * @param chatId The chat to send the animation to.
2352
+ * @param animation The animation to send.
2353
+ */
2354
+ async sendAnimation(chatId, animation, params) {
2355
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, animation, params, _3_types_js_1.FileType.Animation, [
2356
+ new _2_tl_js_1.types.DocumentAttributeAnimated(),
2357
+ new _2_tl_js_1.types.DocumentAttributeVideo({
2358
+ supports_streaming: true,
2359
+ w: params?.width ?? 0,
2360
+ h: params?.height ?? 0,
2361
+ duration: params?.duration ?? 0,
2362
+ }),
2363
+ ]);
2364
+ return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "animation");
2365
+ }
2366
+ /**
2367
+ * Send a voice message.
2368
+ *
2369
+ * @method
2370
+ * @param chatId The chat to send the voice message to.
2371
+ * @param voice The voice to send.
2372
+ */
2373
+ async sendVoice(chatId, voice, params) {
2374
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, voice, params, _3_types_js_1.FileType.Voice, [
2375
+ new _2_tl_js_1.types.DocumentAttributeAudio({
2376
+ voice: true,
2377
+ duration: params?.duration ?? 0,
2378
+ }),
2379
+ ]);
2380
+ return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "voice");
2381
+ }
2382
+ /**
2383
+ * Send an audio file.
2384
+ *
2385
+ * @method
2386
+ * @param chatId The chat to send the audio file to.
2387
+ * @param audio The audio to send.
2388
+ */
2389
+ async sendAudio(chatId, audio, params) {
2390
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, audio, params, _3_types_js_1.FileType.Audio, [
2391
+ new _2_tl_js_1.types.DocumentAttributeAudio({
2392
+ duration: params?.duration ?? 0,
2393
+ performer: params?.performer,
2394
+ title: params?.title,
2395
+ }),
2396
+ ]);
2397
+ return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "audio");
2398
+ }
2399
+ /**
2400
+ * Send a video note.
2401
+ *
2402
+ * @method
2403
+ * @param chatId The chat to send the video note to.
2404
+ * @param videoNote The video note to send.
2405
+ */
2406
+ async sendVideoNote(chatId, audio, params) {
2407
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, audio, params, _3_types_js_1.FileType.VideoNote, [
2408
+ new _2_tl_js_1.types.DocumentAttributeVideo({
2409
+ round_message: true,
2410
+ w: params?.length ?? 0,
2411
+ h: params?.length ?? 0,
2412
+ duration: params?.duration ?? 0,
2413
+ }),
2414
+ ], false);
2415
+ return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "videoNote");
2416
+ }
2417
+ /**
2418
+ * Send a location.
2419
+ *
2420
+ * @method
2421
+ * @param chatId The chat to send the location to.
2422
+ * @param latitude The location's latitude.
2423
+ * @param longitude The location's longitude.
2424
+ */
2425
+ async sendLocation(chatId, latitude, longitude, params) {
2426
+ const peer = await this.getInputPeer(chatId);
2427
+ const randomId = (0, _1_utilities_js_1.getRandomId)();
2428
+ const silent = params?.disableNotification ? true : undefined;
2429
+ const noforwards = params?.protectContent ? true : undefined;
2430
+ const replyToMsgId = params?.replyToMessageId;
2431
+ const topMsgId = params?.messageThreadId;
2432
+ const sendAs = params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
2433
+ const replyMarkup = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params);
2434
+ const result = await this.api.messages.sendMedia({
2435
+ peer,
2436
+ random_id: randomId,
2437
+ silent,
2438
+ noforwards,
2439
+ reply_to: replyToMsgId !== undefined ? new _2_tl_js_1.types.InputReplyToMessage({ reply_to_msg_id: replyToMsgId, top_msg_id: topMsgId }) : undefined,
2440
+ send_as: sendAs,
2441
+ reply_markup: replyMarkup,
2442
+ media: params?.livePeriod !== undefined
2443
+ ? new _2_tl_js_1.types.InputMediaGeoLive({
2444
+ geo_point: new _2_tl_js_1.types.InputGeoPoint({
2445
+ lat: latitude,
2446
+ long: longitude,
2447
+ accuracy_radius: params?.horizontalAccuracy,
2448
+ }),
2449
+ heading: params?.heading,
2450
+ period: params.livePeriod,
2451
+ proximity_notification_radius: params?.proximityAlertRadius,
2452
+ })
2453
+ : new _2_tl_js_1.types.InputMediaGeoPoint({
2454
+ geo_point: new _2_tl_js_1.types.InputGeoPoint({
2455
+ lat: latitude,
2456
+ long: longitude,
2457
+ accuracy_radius: params?.horizontalAccuracy,
2458
+ }),
2459
+ }),
2460
+ message: "",
2461
+ });
2462
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
2463
+ return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "location");
2464
+ }
2465
+ /**
2466
+ * Send a contact.
2467
+ *
2468
+ * @method
2469
+ * @param chatId The chat to send the contact to.
2470
+ * @param firstName The contact's first name.
2471
+ * @param number The contact's phone number.
2472
+ */
2473
+ async sendContact(chatId, firstName, number, params) {
2474
+ const peer = await this.getInputPeer(chatId);
2475
+ const randomId = (0, _1_utilities_js_1.getRandomId)();
2476
+ const silent = params?.disableNotification ? true : undefined;
2477
+ const noforwards = params?.protectContent ? true : undefined;
2478
+ const replyToMsgId = params?.replyToMessageId;
2479
+ const topMsgId = params?.messageThreadId;
2480
+ const sendAs = params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
2481
+ const replyMarkup = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params);
2482
+ const result = await this.api.messages.sendMedia({
2483
+ peer,
2484
+ random_id: randomId,
2485
+ silent,
2486
+ noforwards,
2487
+ reply_to: replyToMsgId !== undefined ? new _2_tl_js_1.types.InputReplyToMessage({ reply_to_msg_id: replyToMsgId, top_msg_id: topMsgId }) : undefined,
2488
+ send_as: sendAs,
2489
+ reply_markup: replyMarkup,
2490
+ media: new _2_tl_js_1.types.InputMediaContact({
2491
+ phone_number: number,
2492
+ first_name: firstName,
2493
+ last_name: params?.lastName ?? "",
2494
+ vcard: params?.vcard ?? "",
2495
+ }),
2496
+ message: "",
2497
+ });
2498
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
2499
+ return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "contact");
2500
+ }
2501
+ /**
2502
+ * Send a dice.
2503
+ *
2504
+ * @method
2505
+ * @param chatId The chat to send the dice to.
2506
+ */
2507
+ async sendDice(chatId, params) {
2508
+ const peer = await this.getInputPeer(chatId);
2509
+ const randomId = (0, _1_utilities_js_1.getRandomId)();
2510
+ const silent = params?.disableNotification ? true : undefined;
2511
+ const noforwards = params?.protectContent ? true : undefined;
2512
+ const replyToMsgId = params?.replyToMessageId;
2513
+ const topMsgId = params?.messageThreadId;
2514
+ const sendAs = params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
2515
+ const replyMarkup = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params);
2516
+ const result = await this.api.messages.sendMedia({
2517
+ peer,
2518
+ random_id: randomId,
2519
+ silent,
2520
+ noforwards,
2521
+ reply_to: replyToMsgId !== undefined ? new _2_tl_js_1.types.InputReplyToMessage({ reply_to_msg_id: replyToMsgId, top_msg_id: topMsgId }) : undefined,
2522
+ send_as: sendAs,
2523
+ reply_markup: replyMarkup,
2524
+ media: new _2_tl_js_1.types.InputMediaDice({
2525
+ emoticon: params?.emoji ?? "🎲",
2526
+ }),
2527
+ message: "",
2528
+ });
2529
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
2530
+ return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "dice");
2531
+ }
2532
+ /**
2533
+ * Send a venue.
2534
+ *
2535
+ * @method
2536
+ * @param chatId The chat to send the venue to.
2537
+ * @param latitude The latitude of the venue.
2538
+ * @param longitude The longitude of the venue.
2539
+ * @param title The title of the venue.
2540
+ * @param address The written address of the venue.
2541
+ */
2542
+ async sendVenue(chatId, latitude, longitude, title, address, params) {
2543
+ const peer = await this.getInputPeer(chatId);
2544
+ const randomId = (0, _1_utilities_js_1.getRandomId)();
2545
+ const silent = params?.disableNotification ? true : undefined;
2546
+ const noforwards = params?.protectContent ? true : undefined;
2547
+ const replyToMsgId = params?.replyToMessageId;
2548
+ const topMsgId = params?.messageThreadId;
2549
+ const sendAs = params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
2550
+ const replyMarkup = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params);
2551
+ const result = await this.api.messages.sendMedia({
2552
+ peer,
2553
+ random_id: randomId,
2554
+ silent,
2555
+ noforwards,
2556
+ reply_to: replyToMsgId !== undefined ? new _2_tl_js_1.types.InputReplyToMessage({ reply_to_msg_id: replyToMsgId, top_msg_id: topMsgId }) : undefined,
2557
+ send_as: sendAs,
2558
+ reply_markup: replyMarkup,
2559
+ media: new _2_tl_js_1.types.InputMediaVenue({
2560
+ geo_point: new _2_tl_js_1.types.InputGeoPoint({
2561
+ lat: latitude,
2562
+ long: longitude,
2563
+ }),
2564
+ title,
2565
+ address,
2566
+ venue_id: params?.foursquareId ?? "",
2567
+ venue_type: params?.foursquareType ?? "",
2568
+ provider: "foursquare",
2569
+ }),
2570
+ message: "",
2571
+ });
2572
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
2573
+ return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "dice");
2574
+ }
2285
2575
  /**
2286
2576
  * Get network statistics. This might not always be available.
2287
2577
  *
@@ -2305,7 +2595,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2305
2595
  return { messages, cdn };
2306
2596
  }
2307
2597
  /**
2308
- * Get chats.
2598
+ * Get chats from a chat list. User-only.
2309
2599
  *
2310
2600
  * @method
2311
2601
  */
@@ -2338,7 +2628,77 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2338
2628
  return chats;
2339
2629
  }
2340
2630
  /**
2341
- * Get chat history.
2631
+ * Get a chat.
2632
+ *
2633
+ * @method
2634
+ */
2635
+ async getChat(chatId) {
2636
+ if (await this.storage.getAccountType() == "user") {
2637
+ let maybeChatId = null;
2638
+ if (typeof chatId === "number") {
2639
+ maybeChatId = chatId;
2640
+ }
2641
+ else if (typeof chatId === "string") {
2642
+ maybeChatId = __classPrivateFieldGet(this, _Client_instances, "m", _Client_tryGetChatId).call(this, (0, _0_utilities_js_1.getUsername)(chatId));
2643
+ }
2644
+ else {
2645
+ (0, _1_utilities_js_1.UNREACHABLE)();
2646
+ }
2647
+ if (maybeChatId != null) {
2648
+ const [chat] = __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChatAnywhere).call(this, maybeChatId);
2649
+ if (chat !== undefined) {
2650
+ return chat;
2651
+ }
2652
+ }
2653
+ }
2654
+ let inputPeer = null;
2655
+ if (typeof chatId === "number") {
2656
+ const chat = await (0, _3_types_js_1.constructChat3)(chatId, -1, undefined, this[getEntity].bind(this));
2657
+ if (chat != null) {
2658
+ return chat;
2659
+ }
2660
+ }
2661
+ else {
2662
+ inputPeer = await this.getInputPeer(chatId);
2663
+ const chatId_ = (0, _2_tl_js_1.peerToChatId)(inputPeer);
2664
+ const chat = await (0, _3_types_js_1.constructChat3)(chatId_, -1, undefined, this[getEntity].bind(this));
2665
+ if (chat != null) {
2666
+ return chat;
2667
+ }
2668
+ }
2669
+ if (inputPeer == null) {
2670
+ inputPeer = await this.getInputPeer(chatId);
2671
+ }
2672
+ if (inputPeer instanceof _2_tl_js_1.types.InputPeerChat) {
2673
+ 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));
2674
+ const chat = chats.chats[0];
2675
+ if (chat instanceof _2_tl_js_1.types.ChatEmpty) {
2676
+ (0, _1_utilities_js_1.UNREACHABLE)();
2677
+ }
2678
+ return (0, _3_types_js_1.constructChat2)(chat, -1, undefined);
2679
+ }
2680
+ else if (inputPeer instanceof _2_tl_js_1.types.InputPeerChannel) {
2681
+ const channels = await this.api.channels.getChannels({ id: [new _2_tl_js_1.types.InputChannel(inputPeer)] });
2682
+ const channel = channels.chats[0];
2683
+ if (channel instanceof _2_tl_js_1.types.ChatEmpty) {
2684
+ (0, _1_utilities_js_1.UNREACHABLE)();
2685
+ }
2686
+ return (0, _3_types_js_1.constructChat2)(channel, -1, undefined);
2687
+ }
2688
+ else if (inputPeer instanceof _2_tl_js_1.types.InputPeerUser) {
2689
+ const users = await this.api.users.getUsers({ id: [new _2_tl_js_1.types.InputUser(inputPeer)] });
2690
+ const user = users[0];
2691
+ if (user instanceof _2_tl_js_1.types.UserEmpty) {
2692
+ (0, _1_utilities_js_1.UNREACHABLE)();
2693
+ }
2694
+ return (0, _3_types_js_1.constructChat2)(user, -1, undefined);
2695
+ }
2696
+ else {
2697
+ (0, _1_utilities_js_1.UNREACHABLE)();
2698
+ }
2699
+ }
2700
+ /**
2701
+ * Get chat history. User-only.
2342
2702
  *
2343
2703
  * @param chatId The identifier of the chat to get its history.
2344
2704
  * @method
@@ -2386,6 +2746,53 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2386
2746
  }
2387
2747
  return messages;
2388
2748
  }
2749
+ /**
2750
+ * Get custom emoji documents for download.
2751
+ *
2752
+ * @param id Identifier of one or more of custom emojis.
2753
+ * @method
2754
+ */
2755
+ async getCustomEmojiDocuments(id) {
2756
+ id = Array.isArray(id) ? id : [id];
2757
+ if (!id.length) {
2758
+ throw new Error("No custom emoji ID provided");
2759
+ }
2760
+ const documents = new Array();
2761
+ let shouldFetch = false;
2762
+ for (const [i, id_] of id.entries()) {
2763
+ const maybeDocument = await this.storage.getCustomEmojiDocument(BigInt(id_));
2764
+ if (maybeDocument != null && Date.now() - maybeDocument[1].getTime() <= 30 * 60 * 1000) {
2765
+ const document_ = maybeDocument[0];
2766
+ const fileUniqueId = new _3_types_js_1.FileUniqueID(_3_types_js_1.FileUniqueType.Document, { mediaId: document_.id }).encode();
2767
+ const fileId = new _3_types_js_1.FileID(null, null, _3_types_js_1.FileType.Document, document_.dc_id, {
2768
+ mediaId: document_.id,
2769
+ accessHash: document_.access_hash,
2770
+ fileReference: document_.file_reference,
2771
+ }).encode();
2772
+ 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);
2773
+ documents.push(document);
2774
+ }
2775
+ else {
2776
+ shouldFetch = true;
2777
+ break;
2778
+ }
2779
+ }
2780
+ if (!shouldFetch) {
2781
+ return documents;
2782
+ }
2783
+ 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)));
2784
+ for (const [i, document_] of documents_.entries()) {
2785
+ const fileUniqueId = new _3_types_js_1.FileUniqueID(_3_types_js_1.FileUniqueType.Document, { mediaId: document_.id }).encode();
2786
+ const fileId = new _3_types_js_1.FileID(null, null, _3_types_js_1.FileType.Document, document_.dc_id, {
2787
+ mediaId: document_.id,
2788
+ accessHash: document_.access_hash,
2789
+ fileReference: document_.file_reference,
2790
+ }).encode();
2791
+ 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);
2792
+ documents.push(document);
2793
+ }
2794
+ return documents;
2795
+ }
2389
2796
  }
2390
2797
  exports.Client = Client;
2391
2798
  _a = Client, _Client_getMe = async function _Client_getMe() {
@@ -2558,9 +2965,9 @@ async function _Client_handleUpdate(update) {
2558
2965
  }, _Client_setMyInfo =
2559
2966
  //#endregion
2560
2967
  async function _Client_setMyInfo(info) {
2561
- await this.invoke(new _2_tl_js_1.functions.bots.setBotInfo({ bot: new _2_tl_js_1.types.InputUserSelf(), ...info }));
2968
+ await this.api.bots.setBotInfo({ bot: new _2_tl_js_1.types.InputUserSelf(), ...info });
2562
2969
  }, _Client_getMyInfo = function _Client_getMyInfo(languageCode) {
2563
- return this.invoke(new _2_tl_js_1.functions.bots.getBotInfo({ bot: new _2_tl_js_1.types.InputUserSelf(), lang_code: languageCode ?? "" }));
2970
+ return this.api.bots.getBotInfo({ bot: new _2_tl_js_1.types.InputUserSelf(), lang_code: languageCode ?? "" });
2564
2971
  }, _Client_resolveFileId = function _Client_resolveFileId(maybeFileId, expectedFileType) {
2565
2972
  let fileId = null;
2566
2973
  try {
@@ -2596,7 +3003,7 @@ async function _Client_setMyInfo(info) {
2596
3003
  const parseResult = caption_ !== undefined ? __classPrivateFieldGet(this, _Client_instances, "m", _Client_parseText).call(this, caption_, { parseMode: params?.parseMode, entities: params?.captionEntities }) : undefined;
2597
3004
  const caption = parseResult === undefined ? undefined : parseResult[0];
2598
3005
  const captionEntities = parseResult === undefined ? undefined : parseResult[1];
2599
- const result = await this.invoke(new _2_tl_js_1.functions.messages.sendMedia({
3006
+ const result = await this.api.messages.sendMedia({
2600
3007
  peer,
2601
3008
  random_id: randomId,
2602
3009
  silent,
@@ -2607,8 +3014,42 @@ async function _Client_setMyInfo(info) {
2607
3014
  media,
2608
3015
  message: caption ?? "",
2609
3016
  entities: captionEntities,
2610
- }));
3017
+ });
2611
3018
  return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
3019
+ }, _Client_sendDocumentInner = async function _Client_sendDocumentInner(chatId, document, params, fileType, otherAttribs, urlSupported = false) {
3020
+ let media = null;
3021
+ const spoiler = params?.hasSpoiler ? true : undefined;
3022
+ if (typeof document === "string") {
3023
+ const fileId = __classPrivateFieldGet(this, _Client_instances, "m", _Client_resolveFileId).call(this, document, fileType);
3024
+ if (fileId != null) {
3025
+ media = new _2_tl_js_1.types.InputMediaDocument({
3026
+ id: new _2_tl_js_1.types.InputDocument(fileId),
3027
+ spoiler,
3028
+ });
3029
+ }
3030
+ }
3031
+ if (media == null) {
3032
+ if (typeof document === "string" && (0, _0_utilities_js_1.isHttpUrl)(document)) {
3033
+ if (!urlSupported) {
3034
+ throw new Error("URL not supported");
3035
+ }
3036
+ media = new _2_tl_js_1.types.InputMediaDocumentExternal({ url: document, spoiler });
3037
+ }
3038
+ else {
3039
+ const [contents, fileName_] = await (0, _0_utilities_js_1.getFileContents)(document);
3040
+ const fileName = params?.fileName ?? fileName_;
3041
+ const mimeType = params?.mimeType ?? (0, _0_deps_js_1.contentType)(fileName.split(".").slice(-1)[0]) ?? "application/octet-stream";
3042
+ const file = await this.upload(contents, { fileName, chunkSize: params?.chunkSize, signal: params?.signal });
3043
+ media = new _2_tl_js_1.types.InputMediaUploadedDocument({
3044
+ file,
3045
+ spoiler,
3046
+ attributes: [new _2_tl_js_1.types.DocumentAttributeFilename({ file_name: fileName }), ...otherAttribs],
3047
+ mime_type: mimeType,
3048
+ });
3049
+ }
3050
+ }
3051
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendMedia).call(this, chatId, media, params);
3052
+ return message;
2612
3053
  }, _Client_sendChatUpdate = async function _Client_sendChatUpdate(chatId, added) {
2613
3054
  try {
2614
3055
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_assertUser).call(this, "");
@@ -2642,7 +3083,7 @@ async function _Client_setMyInfo(info) {
2642
3083
  }
2643
3084
  else {
2644
3085
  const pinnedChats = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getPinnedChats).call(this, listId);
2645
- const chat = await (0, _3_types_js_1.constructChat2)(chatId, pinnedChats.indexOf(chatId), message, this[getEntity].bind(this));
3086
+ const chat = await (0, _3_types_js_1.constructChat3)(chatId, pinnedChats.indexOf(chatId), message, this[getEntity].bind(this));
2646
3087
  if (chat == null) {
2647
3088
  (0, _1_utilities_js_1.UNREACHABLE)();
2648
3089
  }
@@ -2663,7 +3104,7 @@ async function _Client_setMyInfo(info) {
2663
3104
  }
2664
3105
  else {
2665
3106
  const pinnedChats = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getPinnedChats).call(this, listId);
2666
- const chat = await (0, _3_types_js_1.constructChat2)(chatId, pinnedChats.indexOf(chatId), message, this[getEntity].bind(this));
3107
+ const chat = await (0, _3_types_js_1.constructChat3)(chatId, pinnedChats.indexOf(chatId), message, this[getEntity].bind(this));
2667
3108
  if (chat == null) {
2668
3109
  (0, _1_utilities_js_1.UNREACHABLE)();
2669
3110
  }
@@ -2681,6 +3122,23 @@ async function _Client_setMyInfo(info) {
2681
3122
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendChatUpdate).call(this, chatId, false);
2682
3123
  }
2683
3124
  }
3125
+ }, _Client_tryGetChatId = function _Client_tryGetChatId(username) {
3126
+ username = username.toLowerCase();
3127
+ for (const chat of __classPrivateFieldGet(this, _Client_chats, "f").values()) {
3128
+ if ("username" in chat) {
3129
+ if (chat.username === username || chat.also?.some((v) => v.toLowerCase() === username)) {
3130
+ return chat.id;
3131
+ }
3132
+ }
3133
+ }
3134
+ for (const chat of __classPrivateFieldGet(this, _Client_archivedChats, "f").values()) {
3135
+ if ("username" in chat) {
3136
+ if (chat.username === username || chat.also?.some((v) => v.toLowerCase() === username)) {
3137
+ return chat.id;
3138
+ }
3139
+ }
3140
+ }
3141
+ return null;
2684
3142
  }, _Client_getChatAnywhere = function _Client_getChatAnywhere(chatId) {
2685
3143
  let chat = __classPrivateFieldGet(this, _Client_chats, "f").get(chatId);
2686
3144
  if (chat) {
@@ -2704,14 +3162,14 @@ async function _Client_setMyInfo(info) {
2704
3162
  const chats = await this.storage.getChats(0);
2705
3163
  const archivedChats = await this.storage.getChats(1);
2706
3164
  for (const { chatId, pinned, topMessageId } of chats) {
2707
- const chat = await (0, _3_types_js_1.constructChat3)(chatId, pinned, topMessageId, this[getEntity].bind(this), this.getMessage.bind(this));
3165
+ const chat = await (0, _3_types_js_1.constructChat4)(chatId, pinned, topMessageId, this[getEntity].bind(this), this.getMessage.bind(this));
2708
3166
  if (chat == null) {
2709
3167
  continue;
2710
3168
  }
2711
3169
  __classPrivateFieldGet(this, _Client_chats, "f").set(chat.id, chat);
2712
3170
  }
2713
3171
  for (const { chatId, pinned, topMessageId } of archivedChats) {
2714
- const chat = await (0, _3_types_js_1.constructChat3)(chatId, pinned, topMessageId, this[getEntity].bind(this), this.getMessage.bind(this));
3172
+ const chat = await (0, _3_types_js_1.constructChat4)(chatId, pinned, topMessageId, this[getEntity].bind(this), this.getMessage.bind(this));
2715
3173
  if (chat == null) {
2716
3174
  continue;
2717
3175
  }
@@ -2775,14 +3233,14 @@ async function _Client_setMyInfo(info) {
2775
3233
  }, _Client_updateOrAddChat = async function _Client_updateOrAddChat(chatId) {
2776
3234
  const [chat, listId] = __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChatAnywhere).call(this, chatId);
2777
3235
  if (chat !== undefined) {
2778
- const newChat = await (0, _3_types_js_1.constructChat2)(chatId, chat.pinned, chat.lastMessage, this[getEntity].bind(this));
3236
+ const newChat = await (0, _3_types_js_1.constructChat3)(chatId, chat.pinned, chat.lastMessage, this[getEntity].bind(this));
2779
3237
  if (newChat != null) {
2780
3238
  __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChatList).call(this, listId).set(chatId, newChat);
2781
3239
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendChatUpdate).call(this, chatId, false);
2782
3240
  }
2783
3241
  }
2784
3242
  else {
2785
- const chat = await (0, _3_types_js_1.constructChat3)(chatId, -1, -1, this[getEntity].bind(this), this.getMessage.bind(this));
3243
+ const chat = await (0, _3_types_js_1.constructChat4)(chatId, -1, -1, this[getEntity].bind(this), this.getMessage.bind(this));
2786
3244
  if (chat != null) {
2787
3245
  __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChatList).call(this, 0).set(chatId, chat);
2788
3246
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_reassignChatLastMessage).call(this, chatId, false, false);