@mtkruto/node 0.1.132 → 0.1.133

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 (69) hide show
  1. package/esm/3_types.d.ts +3 -0
  2. package/esm/3_types.js +3 -0
  3. package/esm/4_constants.d.ts +2 -2
  4. package/esm/4_constants.js +2 -2
  5. package/esm/client/0_utilities.d.ts +2 -2
  6. package/esm/client/0_utilities.js +3 -5
  7. package/esm/client/3_types.d.ts +10 -5
  8. package/esm/client/4_composer.d.ts +4 -4
  9. package/esm/client/4_composer.js +13 -1
  10. package/esm/client/5_client.d.ts +36 -36
  11. package/esm/client/5_client.js +181 -177
  12. package/esm/tl/2_types.d.ts +313 -24
  13. package/esm/tl/2_types.js +982 -46
  14. package/esm/tl/3_functions.d.ts +95 -32
  15. package/esm/tl/3_functions.js +227 -66
  16. package/esm/types/0_chat_photo.d.ts +22 -21
  17. package/esm/types/0_giveaway_parameters.d.ts +9 -0
  18. package/esm/types/0_giveaway_parameters.js +9 -0
  19. package/esm/types/0_message_entity.d.ts +93 -74
  20. package/esm/types/0_reaction.d.ts +13 -10
  21. package/esm/types/0_reaction.js +16 -1
  22. package/esm/types/1_bot_command_scope.d.ts +32 -27
  23. package/esm/types/1_chat_p.d.ts +76 -68
  24. package/esm/types/1_giveaway.d.ts +8 -0
  25. package/esm/types/1_giveaway.js +7 -0
  26. package/esm/types/1_keyboard_button.d.ts +62 -56
  27. package/esm/types/1_keyboard_button.js +3 -0
  28. package/esm/types/1_message_reaction.d.ts +14 -0
  29. package/esm/types/1_message_reaction.js +22 -0
  30. package/esm/types/1_user.d.ts +2 -2
  31. package/esm/types/2_inline_keyboard_button.d.ts +44 -37
  32. package/esm/types/3_message.d.ts +170 -113
  33. package/esm/types/3_message.js +218 -121
  34. package/esm/types/4_chat.d.ts +32 -29
  35. package/package.json +1 -1
  36. package/script/3_types.d.ts +3 -0
  37. package/script/3_types.js +3 -0
  38. package/script/4_constants.d.ts +2 -2
  39. package/script/4_constants.js +2 -2
  40. package/script/client/0_utilities.d.ts +2 -2
  41. package/script/client/0_utilities.js +3 -5
  42. package/script/client/3_types.d.ts +10 -5
  43. package/script/client/4_composer.d.ts +4 -4
  44. package/script/client/4_composer.js +13 -1
  45. package/script/client/5_client.d.ts +36 -36
  46. package/script/client/5_client.js +180 -176
  47. package/script/tl/2_types.d.ts +313 -24
  48. package/script/tl/2_types.js +1169 -217
  49. package/script/tl/3_functions.d.ts +95 -32
  50. package/script/tl/3_functions.js +241 -77
  51. package/script/types/0_chat_photo.d.ts +22 -21
  52. package/script/types/0_giveaway_parameters.d.ts +9 -0
  53. package/script/types/0_giveaway_parameters.js +13 -0
  54. package/script/types/0_message_entity.d.ts +93 -74
  55. package/script/types/0_reaction.d.ts +13 -10
  56. package/script/types/0_reaction.js +19 -0
  57. package/script/types/1_bot_command_scope.d.ts +32 -27
  58. package/script/types/1_chat_p.d.ts +76 -68
  59. package/script/types/1_giveaway.d.ts +8 -0
  60. package/script/types/1_giveaway.js +11 -0
  61. package/script/types/1_keyboard_button.d.ts +62 -56
  62. package/script/types/1_keyboard_button.js +3 -0
  63. package/script/types/1_message_reaction.d.ts +14 -0
  64. package/script/types/1_message_reaction.js +26 -0
  65. package/script/types/1_user.d.ts +2 -2
  66. package/script/types/2_inline_keyboard_button.d.ts +44 -37
  67. package/script/types/3_message.d.ts +170 -113
  68. package/script/types/3_message.js +220 -122
  69. package/script/types/4_chat.d.ts +32 -29
@@ -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_constructReplyTo, _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;
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_channelUpdateQueues, _Client_processChannelUpdate, _Client_queueChannelUpdate, _Client_handlePtsUpdate, _Client_ptsUpdateQueue, _Client_queuePtsUpdate, _Client_lastUpdates, _Client_processUpdates, _Client_setUpdateStateDate, _Client_setUpdatePts, _Client_getLocalState, _Client_recoverUpdateGap, _Client_recoverChannelUpdateGap, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_updatesToMessages, _Client_resolveSendAs, _Client_constructReplyTo, _Client_parseText, _Client_getMessagesInner, _Client_downloadInner, _Client_lastGetMe, _Client_getMe, _Client_handleUpdate, _Client_usernameResolver, _Client_constructReplyMarkup, _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;
13
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, constructChat4, constructChosenInlineResult, constructDocument, constructInlineQuery, constructMessage, constructUser, FileID, FileType, FileUniqueID, FileUniqueType, getChatOrder, inlineQueryResultToTlObject, messageEntityToTlObject, replyMarkupToTlObject, ThumbnailSource } from "../3_types.js";
17
+ import { assertMessageType, botCommandScopeToTlObject, constructCallbackQuery, constructChat, constructChat2, constructChat3, constructChat4, constructChosenInlineResult, constructDocument, constructInlineQuery, constructMessage, constructMessageReaction, constructUser, FileID, FileType, FileUniqueID, FileUniqueType, getChatOrder, inlineQueryResultToTlObject, messageEntityToTlObject, reactionToTlObject, 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";
@@ -198,14 +198,17 @@ export class Client extends ClientAbstract {
198
198
  return replyToMessageId;
199
199
  };
200
200
  const me = update.connectionState !== undefined ? __classPrivateFieldGet(this, _Client_lastGetMe, "f") : (update.authorizationState !== undefined && !update.authorizationState.authorized) ? __classPrivateFieldGet(this, _Client_lastGetMe, "f") : await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMe).call(this);
201
- return cleanObject({
201
+ const context = {
202
202
  ...update,
203
203
  client: this,
204
- me: me == null ? undefined : me,
205
- msg,
206
- chat,
207
- from,
208
- senderChat,
204
+ me: (me == null ? undefined : me),
205
+ msg: msg,
206
+ chat: chat,
207
+ from: from,
208
+ senderChat: senderChat,
209
+ get toJSON() {
210
+ return () => update;
211
+ },
209
212
  reply: (text, params) => {
210
213
  const effectiveMessage = mustGetMsg();
211
214
  const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
@@ -246,10 +249,10 @@ export class Client extends ClientAbstract {
246
249
  const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
247
250
  return this.sendVenue(effectiveMessage.chat.id, latitude, longitude, title, address, { ...params, replyToMessageId });
248
251
  },
249
- replyVideo: (document, params) => {
252
+ replyVideo: (video, params) => {
250
253
  const effectiveMessage = mustGetMsg();
251
254
  const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
252
- return this.sendDocument(effectiveMessage.chat.id, document, { ...params, replyToMessageId });
255
+ return this.sendVideo(effectiveMessage.chat.id, video, { ...params, replyToMessageId });
253
256
  },
254
257
  replyAnimation: (document, params) => {
255
258
  const effectiveMessage = mustGetMsg();
@@ -333,10 +336,8 @@ export class Client extends ClientAbstract {
333
336
  const effectiveMessage = mustGetMsg();
334
337
  return this.addReaction(effectiveMessage.chat.id, messageId, reaction, params);
335
338
  },
336
- get toJSON() {
337
- return () => update;
338
- },
339
- }, false);
339
+ };
340
+ return cleanObject(context, false);
340
341
  });
341
342
  _Client_lastPropagatedConnectionState.set(this, null);
342
343
  Object.defineProperty(this, "stateChangeHandler", {
@@ -396,6 +397,8 @@ export class Client extends ClientAbstract {
396
397
  });
397
398
  _Client_handleUpdateQueue.set(this, new Queue("handleUpdate"));
398
399
  _Client_processUpdatesQueue.set(this, new Queue("processUpdates"));
400
+ _Client_channelUpdateQueues.set(this, new Map());
401
+ _Client_ptsUpdateQueue.set(this, new Queue("ptsUpdate"));
399
402
  _Client_lastUpdates.set(this, new Date());
400
403
  _Client_lastGetMe.set(this, null);
401
404
  _Client_usernameResolver.set(this, async (v) => {
@@ -552,7 +555,7 @@ export class Client extends ClientAbstract {
552
555
  release();
553
556
  }
554
557
  }
555
- async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = new WeakMap(), _Client_updateState = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_autoStart = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_prefixes = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_authKeyWasCreated = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_pingLoopAbortSignal = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_handleUpdateQueue = new WeakMap(), _Client_processUpdatesQueue = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_usernameResolver = new WeakMap(), _Client_handle = new WeakMap(), _Client_chats = new WeakMap(), _Client_archivedChats = new WeakMap(), _Client_chatsLoadedFromStorage = new WeakMap(), _Client_pinnedChats = new WeakMap(), _Client_pinnedArchiveChats = new WeakMap(), _Client_storageHadPinnedChats = new WeakMap(), _Client_pinnedChatsLoaded = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
558
+ async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = new WeakMap(), _Client_updateState = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_autoStart = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_prefixes = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_authKeyWasCreated = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_pingLoopAbortSignal = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_handleUpdateQueue = new WeakMap(), _Client_processUpdatesQueue = new WeakMap(), _Client_channelUpdateQueues = new WeakMap(), _Client_ptsUpdateQueue = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_usernameResolver = new WeakMap(), _Client_handle = new WeakMap(), _Client_chats = new WeakMap(), _Client_archivedChats = new WeakMap(), _Client_chatsLoadedFromStorage = new WeakMap(), _Client_pinnedChats = new WeakMap(), _Client_pinnedArchiveChats = new WeakMap(), _Client_storageHadPinnedChats = new WeakMap(), _Client_pinnedChatsLoaded = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
556
559
  __classPrivateFieldGet(this, _Client_handleUpdateQueue, "f").add(async () => {
557
560
  await __classPrivateFieldGet(this, _Client_handle, "f").call(this, await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, { connectionState }), resolve);
558
561
  });
@@ -1079,9 +1082,61 @@ export class Client extends ClientAbstract {
1079
1082
  if (localPts + ptsCount < pts) {
1080
1083
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverChannelUpdateGap).call(this, channelId, "processUpdates");
1081
1084
  }
1085
+ }, _Client_processChannelUpdate = async function _Client_processChannelUpdate(update, checkGap) {
1086
+ const channelId = update instanceof types.UpdateNewChannelMessage || update instanceof types.UpdateEditChannelMessage ? update.message.peer_id[as](types.PeerChannel).channel_id : update.channel_id;
1087
+ if (update instanceof types.UpdateChannelTooLong) {
1088
+ if (update.pts != undefined) {
1089
+ await this.storage.setChannelPts(channelId, update.pts);
1090
+ }
1091
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverChannelUpdateGap).call(this, channelId, "updateChannelTooLong");
1092
+ return;
1093
+ }
1094
+ if (update.pts != 0) {
1095
+ const ptsCount = update.pts_count;
1096
+ if (checkGap) {
1097
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_checkChannelGap).call(this, channelId, update.pts, ptsCount);
1098
+ }
1099
+ let currentPts = await this.storage.getChannelPts(channelId);
1100
+ currentPts ??= update.pts - ptsCount;
1101
+ if (currentPts + ptsCount > update.pts) {
1102
+ return;
1103
+ }
1104
+ }
1105
+ await this.storage.setChannelPts(channelId, update.pts);
1106
+ __classPrivateFieldGet(this, _Client_handleUpdateQueue, "f").add(async () => {
1107
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleUpdate).call(this, update);
1108
+ });
1109
+ }, _Client_queueChannelUpdate = function _Client_queueChannelUpdate(update, checkGap) {
1110
+ const channelId = update instanceof types.UpdateNewChannelMessage || update instanceof types.UpdateEditChannelMessage ? update.message.peer_id[as](types.PeerChannel).channel_id : update.channel_id;
1111
+ let queue = __classPrivateFieldGet(this, _Client_channelUpdateQueues, "f").get(channelId);
1112
+ if (queue == undefined) {
1113
+ queue = new Queue(`channelUpdates-${channelId}`);
1114
+ __classPrivateFieldGet(this, _Client_channelUpdateQueues, "f").set(channelId, queue);
1115
+ }
1116
+ queue.add(async () => {
1117
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChannelUpdate).call(this, update, checkGap);
1118
+ });
1119
+ }, _Client_handlePtsUpdate = async function _Client_handlePtsUpdate(update, checkGap) {
1120
+ const localState = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
1121
+ if (update.pts != 0) {
1122
+ if (checkGap) {
1123
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_checkGap).call(this, update.pts, update.pts_count);
1124
+ }
1125
+ if (localState.pts + update.pts_count > update.pts) {
1126
+ return;
1127
+ }
1128
+ }
1129
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setUpdatePts).call(this, update.pts);
1130
+ __classPrivateFieldGet(this, _Client_handleUpdateQueue, "f").add(async () => {
1131
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleUpdate).call(this, update);
1132
+ });
1133
+ }, _Client_queuePtsUpdate = function _Client_queuePtsUpdate(update, checkGap) {
1134
+ __classPrivateFieldGet(this, _Client_ptsUpdateQueue, "f").add(async () => {
1135
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handlePtsUpdate).call(this, update, checkGap);
1136
+ });
1082
1137
  }, _Client_processUpdates = async function _Client_processUpdates(updates_, checkGap) {
1083
1138
  __classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
1084
- /// First, individual updates (Update[1]) and updateShort* are extracted from Updates.[2]
1139
+ /// First, individual updates (Update[1]) are extracted from Updates.[2]
1085
1140
  ///
1086
1141
  /// If an updatesTooLong[3] was received, an update gap recovery is initiated and no further action will be taken.
1087
1142
  ///
@@ -1102,14 +1157,14 @@ export class Client extends ClientAbstract {
1102
1157
  const localState = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
1103
1158
  const localSeq = localState.seq;
1104
1159
  if (localSeq + 1 == seqStart) {
1105
- // The updates can be applied.
1160
+ // The update sequence can be applied.
1106
1161
  localState.seq = seq;
1107
1162
  localState.date = updates_.date;
1108
1163
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setUpdateStateDate).call(this, updates_.date);
1109
1164
  await this.storage.setState(localState);
1110
1165
  }
1111
1166
  else if (localSeq + 1 > seqStart) {
1112
- // The updates were already applied, and must be ignored.
1167
+ // The update sequence was already applied, and must be ignored.
1113
1168
  d("localSeq + 1 > seqStart");
1114
1169
  return;
1115
1170
  }
@@ -1123,10 +1178,53 @@ export class Client extends ClientAbstract {
1123
1178
  else if (updates_ instanceof types.UpdateShort) {
1124
1179
  updates = [updates_.update];
1125
1180
  }
1126
- else if (updates_ instanceof types.UpdateShortMessage ||
1127
- updates_ instanceof types.UpdateShortChatMessage ||
1128
- updates_ instanceof types.UpdateShortSentMessage) {
1129
- updates = [updates_];
1181
+ else if (updates_ instanceof types.UpdateShortMessage) {
1182
+ updates = [
1183
+ new types.UpdateNewMessage({
1184
+ message: new types.Message({
1185
+ out: updates_.out,
1186
+ mentioned: updates_.mentioned,
1187
+ media_unread: updates_.media_unread,
1188
+ silent: updates_.silent,
1189
+ id: updates_.id,
1190
+ from_id: updates_.out ? new types.PeerUser({ user_id: await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).call(this).then(BigInt) }) : new types.PeerUser({ user_id: updates_.user_id }),
1191
+ peer_id: new types.PeerUser({ user_id: updates_.user_id }),
1192
+ message: updates_.message,
1193
+ date: updates_.date,
1194
+ fwd_from: updates_.fwd_from,
1195
+ via_bot_id: updates_.via_bot_id,
1196
+ reply_to: updates_.reply_to,
1197
+ entities: updates_.entities,
1198
+ ttl_period: updates_.ttl_period,
1199
+ }),
1200
+ pts: updates_.pts,
1201
+ pts_count: updates_.pts_count,
1202
+ }),
1203
+ ];
1204
+ }
1205
+ else if (updates_ instanceof types.UpdateShortChatMessage) {
1206
+ updates = [
1207
+ new types.UpdateNewMessage({
1208
+ message: new types.Message({
1209
+ out: updates_.out,
1210
+ mentioned: updates_.mentioned,
1211
+ media_unread: updates_.media_unread,
1212
+ silent: updates_.silent,
1213
+ id: updates_.id,
1214
+ from_id: new types.PeerUser({ user_id: updates_.from_id }),
1215
+ peer_id: new types.PeerChat({ chat_id: updates_.chat_id }),
1216
+ fwd_from: updates_.fwd_from,
1217
+ via_bot_id: updates_.via_bot_id,
1218
+ reply_to: updates_.reply_to,
1219
+ date: updates_.date,
1220
+ message: updates_.message,
1221
+ entities: updates_.entities,
1222
+ ttl_period: updates_.ttl_period,
1223
+ }),
1224
+ pts: updates_.pts,
1225
+ pts_count: updates_.pts_count,
1226
+ }),
1227
+ ];
1130
1228
  }
1131
1229
  else if (updates_ instanceof types.UpdatesTooLong) {
1132
1230
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "updatesTooLong");
@@ -1138,86 +1236,20 @@ export class Client extends ClientAbstract {
1138
1236
  else {
1139
1237
  UNREACHABLE();
1140
1238
  }
1141
- /// Then, we go through each Update and updateShort*, and see if they are order-sensitive.
1142
- /// If they were, we check the local state to see if it is OK to process them right away.
1143
- ///
1144
- /// If we there was a gap, a recovery process will be initiated and the processing will be postponed.
1145
- let localState = null;
1146
- let originalPts = null;
1147
- const channelPtsMap = new Map();
1148
- for (const update of updates) {
1149
- if (isPtsUpdate(update)) {
1150
- if (update.pts == 0) {
1151
- continue;
1152
- }
1153
- if (checkGap) {
1154
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_checkGap).call(this, update.pts, update.pts_count);
1155
- }
1156
- localState ??= await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
1157
- originalPts ??= localState.pts;
1158
- if (localState.pts + update.pts_count > update.pts) {
1159
- updates = updates.filter((v) => v != update);
1160
- }
1161
- else {
1162
- localState.pts = update.pts;
1163
- }
1164
- }
1165
- else if (isChannelPtsUpdate(update)) {
1166
- if (update.pts == 0) {
1167
- continue;
1168
- }
1169
- const ptsCount = update.pts_count;
1170
- const channelId = update instanceof types.UpdateNewChannelMessage || update instanceof types.UpdateEditChannelMessage ? update.message.peer_id[as](types.PeerChannel).channel_id : update.channel_id;
1171
- if (checkGap) {
1172
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_checkChannelGap).call(this, channelId, update.pts, ptsCount);
1173
- }
1174
- let currentPts = channelPtsMap.get(channelId);
1175
- if (currentPts === undefined) {
1176
- currentPts = await this.storage.getChannelPts(channelId);
1177
- }
1178
- currentPts ??= update.pts - ptsCount;
1179
- if (currentPts + ptsCount > update.pts) {
1180
- updates = updates.filter((v) => v != update);
1181
- }
1182
- else {
1183
- channelPtsMap.set(channelId, update.pts);
1184
- }
1185
- }
1186
- }
1187
1239
  /// We process the updates when we are sure there is no gap.
1188
1240
  if (updates_ instanceof types.Updates || updates_ instanceof types.UpdatesCombined) {
1189
1241
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, updates_.chats);
1190
1242
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUsers).call(this, updates_.users);
1191
1243
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setUpdateStateDate).call(this, updates_.date);
1192
1244
  }
1193
- else if (updates_ instanceof types.UpdateShort) {
1245
+ else if (updates_ instanceof types.UpdateShort ||
1246
+ updates_ instanceof types.UpdateShortMessage ||
1247
+ updates_ instanceof types.UpdateShortChatMessage ||
1248
+ updates_ instanceof types.UpdateShortSentMessage) {
1194
1249
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setUpdateStateDate).call(this, updates_.date);
1195
1250
  }
1196
- const updatesToHandle = new Array();
1197
1251
  for (const update of updates) {
1198
- if (update instanceof types.UpdateShortMessage ||
1199
- update instanceof types.UpdateShortChatMessage ||
1200
- update instanceof types.UpdateShortSentMessage) {
1201
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setUpdateStateDate).call(this, update.date);
1202
- }
1203
- else if (update instanceof types.UpdateChannelTooLong) {
1204
- if (update.pts != undefined) {
1205
- await this.storage.setChannelPts(update.channel_id, update.pts);
1206
- }
1207
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverChannelUpdateGap).call(this, update.channel_id, "updateChannelTooLong");
1208
- }
1209
- else if (update instanceof types.UpdateUserName) {
1210
- await this.storage.updateUsernames("user", update.user_id, update.usernames.map((v) => v.username));
1211
- const peer = new types.PeerUser(update);
1212
- const entity = await this[getEntity](peer);
1213
- if (entity != null) {
1214
- entity.usernames = update.usernames;
1215
- entity.first_name = update.first_name;
1216
- entity.last_name = update.last_name;
1217
- await this.storage.setEntity(entity);
1218
- }
1219
- }
1220
- else if (update instanceof types.UpdatePtsChanged) {
1252
+ if (update instanceof types.UpdatePtsChanged) {
1221
1253
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_fetchState).call(this, "updatePtsChanged");
1222
1254
  if (__classPrivateFieldGet(this, _Client_updateState, "f")) {
1223
1255
  await this.storage.setState(__classPrivateFieldGet(this, _Client_updateState, "f"));
@@ -1226,31 +1258,18 @@ export class Client extends ClientAbstract {
1226
1258
  UNREACHABLE();
1227
1259
  }
1228
1260
  }
1229
- if (isPtsUpdate(update)) {
1230
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setUpdatePts).call(this, update.pts);
1261
+ else if (isPtsUpdate(update)) {
1262
+ __classPrivateFieldGet(this, _Client_instances, "m", _Client_queuePtsUpdate).call(this, update, checkGap);
1231
1263
  }
1232
1264
  else if (isChannelPtsUpdate(update)) {
1233
- let channelId = null;
1234
- if ("channel_id" in update) {
1235
- channelId = update.channel_id;
1236
- }
1237
- else if ("peer_id" in update.message && update.message.peer_id !== undefined && "channel_id" in update.message.peer_id) {
1238
- channelId = update.message.peer_id.channel_id;
1239
- }
1240
- if (channelId != null) {
1241
- await this.storage.setChannelPts(channelId, update.pts);
1242
- }
1265
+ __classPrivateFieldGet(this, _Client_instances, "m", _Client_queueChannelUpdate).call(this, update, checkGap);
1243
1266
  }
1244
- /// If there were any Update, they will be passed to the update handling queue.
1245
- if (update instanceof types._Update || update instanceof types.UpdateShortMessage || update instanceof types.UpdateShortChatMessage || update instanceof types.UpdateShortSentMessage) {
1246
- updatesToHandle.push(update);
1267
+ else {
1268
+ __classPrivateFieldGet(this, _Client_handleUpdateQueue, "f").add(async () => {
1269
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleUpdate).call(this, update);
1270
+ });
1247
1271
  }
1248
1272
  }
1249
- __classPrivateFieldGet(this, _Client_handleUpdateQueue, "f").add(async () => {
1250
- for (const update of updatesToHandle) {
1251
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleUpdate).call(this, update);
1252
- }
1253
- });
1254
1273
  }, _Client_setUpdateStateDate = async function _Client_setUpdateStateDate(date) {
1255
1274
  const localState = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
1256
1275
  localState.date = date;
@@ -1526,7 +1545,7 @@ export class Client extends ClientAbstract {
1526
1545
  reply_markup: replyMarkup,
1527
1546
  });
1528
1547
  const message_ = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
1529
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message_, "text");
1548
+ return assertMessageType(message_, "text");
1530
1549
  }
1531
1550
  /**
1532
1551
  * Edit a message's text.
@@ -1548,7 +1567,7 @@ export class Client extends ClientAbstract {
1548
1567
  reply_markup: await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params),
1549
1568
  });
1550
1569
  const message_ = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
1551
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message_, "text");
1570
+ return assertMessageType(message_, "text");
1552
1571
  }
1553
1572
  /**
1554
1573
  * Retrieve multiple messages.
@@ -1936,7 +1955,7 @@ export class Client extends ClientAbstract {
1936
1955
  message: "",
1937
1956
  });
1938
1957
  const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
1939
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "poll");
1958
+ return assertMessageType(message, "poll");
1940
1959
  }
1941
1960
  /**
1942
1961
  * Send a chat action.
@@ -2144,9 +2163,19 @@ export class Client extends ClientAbstract {
2144
2163
  }
2145
2164
  on(filter, ...middleawre) {
2146
2165
  const type = typeof filter === "string" ? filter : filter[0];
2147
- const keys = Array.isArray(filter) ? filter.slice(1) : [];
2166
+ let keys = Array.isArray(filter) ? filter.slice(1) : [];
2167
+ let messageType = null;
2168
+ if (type == "message") {
2169
+ messageType = keys[0];
2170
+ keys = keys.slice(1);
2171
+ }
2148
2172
  return this.filter((ctx) => {
2149
2173
  if (type in ctx) {
2174
+ if (messageType != null) {
2175
+ // deno-lint-ignore ban-ts-comment
2176
+ // @ts-ignore
2177
+ assertMessageType(ctx[type], messageType);
2178
+ }
2150
2179
  if (keys.length > 0) {
2151
2180
  for (const key of keys) {
2152
2181
  // deno-lint-ignore ban-ts-comment
@@ -2161,6 +2190,7 @@ export class Client extends ClientAbstract {
2161
2190
  else {
2162
2191
  return false;
2163
2192
  }
2193
+ // deno-lint-ignore no-explicit-any
2164
2194
  }, ...middleawre);
2165
2195
  }
2166
2196
  command(commands, ...middleawre) {
@@ -2316,7 +2346,7 @@ export class Client extends ClientAbstract {
2316
2346
  }
2317
2347
  }
2318
2348
  const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendMedia).call(this, chatId, media, params);
2319
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "photo");
2349
+ return assertMessageType(message, "photo");
2320
2350
  }
2321
2351
  /**
2322
2352
  * Send a document.
@@ -2327,7 +2357,7 @@ export class Client extends ClientAbstract {
2327
2357
  */
2328
2358
  async sendDocument(chatId, document, params) {
2329
2359
  const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, document, params, FileType.Document, []);
2330
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "document");
2360
+ return assertMessageType(message, "document");
2331
2361
  }
2332
2362
  /**
2333
2363
  * Send a video.
@@ -2345,7 +2375,7 @@ export class Client extends ClientAbstract {
2345
2375
  duration: params?.duration ?? 0,
2346
2376
  }),
2347
2377
  ]);
2348
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "video");
2378
+ return assertMessageType(message, "video");
2349
2379
  }
2350
2380
  /**
2351
2381
  * Send an animation.
@@ -2364,7 +2394,7 @@ export class Client extends ClientAbstract {
2364
2394
  duration: params?.duration ?? 0,
2365
2395
  }),
2366
2396
  ]);
2367
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "animation");
2397
+ return assertMessageType(message, "animation");
2368
2398
  }
2369
2399
  /**
2370
2400
  * Send a voice message.
@@ -2380,7 +2410,7 @@ export class Client extends ClientAbstract {
2380
2410
  duration: params?.duration ?? 0,
2381
2411
  }),
2382
2412
  ]);
2383
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "voice");
2413
+ return assertMessageType(message, "voice");
2384
2414
  }
2385
2415
  /**
2386
2416
  * Send an audio file.
@@ -2397,7 +2427,7 @@ export class Client extends ClientAbstract {
2397
2427
  title: params?.title,
2398
2428
  }),
2399
2429
  ]);
2400
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "audio");
2430
+ return assertMessageType(message, "audio");
2401
2431
  }
2402
2432
  /**
2403
2433
  * Send a video note.
@@ -2415,7 +2445,7 @@ export class Client extends ClientAbstract {
2415
2445
  duration: params?.duration ?? 0,
2416
2446
  }),
2417
2447
  ], false);
2418
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "videoNote");
2448
+ return assertMessageType(message, "videoNote");
2419
2449
  }
2420
2450
  /**
2421
2451
  * Send a location.
@@ -2461,7 +2491,7 @@ export class Client extends ClientAbstract {
2461
2491
  message: "",
2462
2492
  });
2463
2493
  const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
2464
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "location");
2494
+ return assertMessageType(message, "location");
2465
2495
  }
2466
2496
  /**
2467
2497
  * Send a contact.
@@ -2495,7 +2525,7 @@ export class Client extends ClientAbstract {
2495
2525
  message: "",
2496
2526
  });
2497
2527
  const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
2498
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "contact");
2528
+ return assertMessageType(message, "contact");
2499
2529
  }
2500
2530
  /**
2501
2531
  * Send a dice.
@@ -2524,7 +2554,7 @@ export class Client extends ClientAbstract {
2524
2554
  message: "",
2525
2555
  });
2526
2556
  const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
2527
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "dice");
2557
+ return assertMessageType(message, "dice");
2528
2558
  }
2529
2559
  /**
2530
2560
  * Send a venue.
@@ -2565,7 +2595,7 @@ export class Client extends ClientAbstract {
2565
2595
  message: "",
2566
2596
  });
2567
2597
  const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
2568
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "dice");
2598
+ return assertMessageType(message, "venue");
2569
2599
  }
2570
2600
  /**
2571
2601
  * Get network statistics. This might not always be available.
@@ -2814,7 +2844,7 @@ export class Client extends ClientAbstract {
2814
2844
  await this.api.messages.sendReaction({
2815
2845
  peer: await this.getInputPeer(chatId),
2816
2846
  msg_id: messageId,
2817
- reaction: [reaction.type == "emoji" ? new types.ReactionEmoji({ emoticon: reaction.emoji }) : new types.ReactionCustomEmoji({ document_id: BigInt(reaction.id) })],
2847
+ reaction: [reactionToTlObject(reaction)],
2818
2848
  big: params?.big ? true : undefined,
2819
2849
  add_to_recent: params?.addToRecents ? true : undefined,
2820
2850
  });
@@ -2832,49 +2862,16 @@ _a = Client, _Client_getMe = async function _Client_getMe() {
2832
2862
  }, _Client_handleUpdate =
2833
2863
  // TODO: log errors
2834
2864
  async function _Client_handleUpdate(update) {
2835
- if (update instanceof types.UpdateShortMessage) {
2836
- update = new types.UpdateNewMessage({
2837
- message: new types.Message({
2838
- out: update.out,
2839
- mentioned: update.mentioned,
2840
- media_unread: update.media_unread,
2841
- silent: update.silent,
2842
- id: update.id,
2843
- from_id: update.out ? new types.PeerUser({ user_id: await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).call(this).then(BigInt) }) : new types.PeerUser({ user_id: update.user_id }),
2844
- peer_id: new types.PeerUser({ user_id: update.user_id }),
2845
- message: update.message,
2846
- date: update.date,
2847
- fwd_from: update.fwd_from,
2848
- via_bot_id: update.via_bot_id,
2849
- reply_to: update.reply_to,
2850
- entities: update.entities,
2851
- ttl_period: update.ttl_period,
2852
- }),
2853
- pts: update.pts,
2854
- pts_count: update.pts_count,
2855
- });
2856
- }
2857
- else if (update instanceof types.UpdateShortChatMessage) {
2858
- update = new types.UpdateNewMessage({
2859
- message: new types.Message({
2860
- out: update.out,
2861
- mentioned: update.mentioned,
2862
- media_unread: update.media_unread,
2863
- silent: update.silent,
2864
- id: update.id,
2865
- from_id: new types.PeerUser({ user_id: update.from_id }),
2866
- peer_id: new types.PeerChat({ chat_id: update.chat_id }),
2867
- fwd_from: update.fwd_from,
2868
- via_bot_id: update.via_bot_id,
2869
- reply_to: update.reply_to,
2870
- date: update.date,
2871
- message: update.message,
2872
- entities: update.entities,
2873
- ttl_period: update.ttl_period,
2874
- }),
2875
- pts: update.pts,
2876
- pts_count: update.pts_count,
2877
- });
2865
+ if (update instanceof types.UpdateUserName) {
2866
+ await this.storage.updateUsernames("user", update.user_id, update.usernames.map((v) => v.username));
2867
+ const peer = new types.PeerUser(update);
2868
+ const entity = await this[getEntity](peer);
2869
+ if (entity != null) {
2870
+ entity.usernames = update.usernames;
2871
+ entity.first_name = update.first_name;
2872
+ entity.last_name = update.last_name;
2873
+ await this.storage.setEntity(entity);
2874
+ }
2878
2875
  }
2879
2876
  if (update instanceof types.UpdateNewMessage || update instanceof types.UpdateNewChannelMessage || update instanceof types.UpdateEditMessage || update instanceof types.UpdateEditChannelMessage) {
2880
2877
  if (update.message instanceof types.Message || update.message instanceof types.MessageService) {
@@ -2883,6 +2880,17 @@ async function _Client_handleUpdate(update) {
2883
2880
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_reassignChatLastMessage).call(this, chatId);
2884
2881
  }
2885
2882
  }
2883
+ if (update instanceof types.UpdateMessageReactions) {
2884
+ const chatId = peerToChatId(update.peer);
2885
+ const message = await this.storage.getMessage(chatId, update.msg_id);
2886
+ if (message instanceof types.Message) {
2887
+ message.reactions = update.reactions;
2888
+ await this.storage.setMessage(chatId, update.msg_id, message);
2889
+ }
2890
+ const recentReactions = update.reactions.recent_reactions ?? [];
2891
+ const reactions = update.reactions.results.map((v) => constructMessageReaction(v, recentReactions));
2892
+ await __classPrivateFieldGet(this, _Client_handle, "f").call(this, await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, { reactions: { chatId, messageId: update.msg_id, reactions } }), resolve);
2893
+ }
2886
2894
  if (update instanceof types.UpdateNewMessage ||
2887
2895
  update instanceof types.UpdateNewChannelMessage ||
2888
2896
  update instanceof types.UpdateEditMessage ||
@@ -2982,11 +2990,6 @@ async function _Client_handleUpdate(update) {
2982
2990
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_assertBot).call(this, "replyMarkup");
2983
2991
  return replyMarkupToTlObject(params.replyMarkup, __classPrivateFieldGet(this, _Client_usernameResolver, "f").bind(this));
2984
2992
  }
2985
- }, _Client_assertMsgHas = function _Client_assertMsgHas(message, key) {
2986
- if (!(key in message) || message[key] === undefined) {
2987
- UNREACHABLE();
2988
- }
2989
- return message;
2990
2993
  }, _Client_setMyInfo =
2991
2994
  //#endregion
2992
2995
  async function _Client_setMyInfo(info) {
@@ -3302,6 +3305,7 @@ async function _Client_setMyInfo(info) {
3302
3305
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendChatUpdate).call(this, chat.id, false);
3303
3306
  }
3304
3307
  }
3308
+ await this.storage.setPinnedChats(listId, await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getPinnedChats).call(this, listId));
3305
3309
  }, _Client_fetchChats = async function _Client_fetchChats(listId, limit, after) {
3306
3310
  const dialogs = await this.api.messages.getDialogs({
3307
3311
  limit,