@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
@@ -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_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;
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_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;
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");
@@ -203,14 +203,17 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
203
203
  return replyToMessageId;
204
204
  };
205
205
  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);
206
- return (0, _1_utilities_js_1.cleanObject)({
206
+ const context = {
207
207
  ...update,
208
208
  client: this,
209
- me: me == null ? undefined : me,
210
- msg,
211
- chat,
212
- from,
213
- senderChat,
209
+ me: (me == null ? undefined : me),
210
+ msg: msg,
211
+ chat: chat,
212
+ from: from,
213
+ senderChat: senderChat,
214
+ get toJSON() {
215
+ return () => update;
216
+ },
214
217
  reply: (text, params) => {
215
218
  const effectiveMessage = mustGetMsg();
216
219
  const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
@@ -251,10 +254,10 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
251
254
  const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
252
255
  return this.sendVenue(effectiveMessage.chat.id, latitude, longitude, title, address, { ...params, replyToMessageId });
253
256
  },
254
- replyVideo: (document, params) => {
257
+ replyVideo: (video, params) => {
255
258
  const effectiveMessage = mustGetMsg();
256
259
  const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
257
- return this.sendDocument(effectiveMessage.chat.id, document, { ...params, replyToMessageId });
260
+ return this.sendVideo(effectiveMessage.chat.id, video, { ...params, replyToMessageId });
258
261
  },
259
262
  replyAnimation: (document, params) => {
260
263
  const effectiveMessage = mustGetMsg();
@@ -338,10 +341,8 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
338
341
  const effectiveMessage = mustGetMsg();
339
342
  return this.addReaction(effectiveMessage.chat.id, messageId, reaction, params);
340
343
  },
341
- get toJSON() {
342
- return () => update;
343
- },
344
- }, false);
344
+ };
345
+ return (0, _1_utilities_js_1.cleanObject)(context, false);
345
346
  });
346
347
  _Client_lastPropagatedConnectionState.set(this, null);
347
348
  Object.defineProperty(this, "stateChangeHandler", {
@@ -401,6 +402,8 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
401
402
  });
402
403
  _Client_handleUpdateQueue.set(this, new _1_utilities_js_1.Queue("handleUpdate"));
403
404
  _Client_processUpdatesQueue.set(this, new _1_utilities_js_1.Queue("processUpdates"));
405
+ _Client_channelUpdateQueues.set(this, new Map());
406
+ _Client_ptsUpdateQueue.set(this, new _1_utilities_js_1.Queue("ptsUpdate"));
404
407
  _Client_lastUpdates.set(this, new Date());
405
408
  _Client_lastGetMe.set(this, null);
406
409
  _Client_usernameResolver.set(this, async (v) => {
@@ -557,7 +560,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
557
560
  release();
558
561
  }
559
562
  }
560
- 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) {
563
+ 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) {
561
564
  __classPrivateFieldGet(this, _Client_handleUpdateQueue, "f").add(async () => {
562
565
  await __classPrivateFieldGet(this, _Client_handle, "f").call(this, await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, { connectionState }), _0_utilities_js_1.resolve);
563
566
  });
@@ -1084,9 +1087,61 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1084
1087
  if (localPts + ptsCount < pts) {
1085
1088
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverChannelUpdateGap).call(this, channelId, "processUpdates");
1086
1089
  }
1090
+ }, _Client_processChannelUpdate = async function _Client_processChannelUpdate(update, checkGap) {
1091
+ const channelId = update instanceof _2_tl_js_1.types.UpdateNewChannelMessage || update instanceof _2_tl_js_1.types.UpdateEditChannelMessage ? update.message.peer_id[_2_tl_js_1.as](_2_tl_js_1.types.PeerChannel).channel_id : update.channel_id;
1092
+ if (update instanceof _2_tl_js_1.types.UpdateChannelTooLong) {
1093
+ if (update.pts != undefined) {
1094
+ await this.storage.setChannelPts(channelId, update.pts);
1095
+ }
1096
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverChannelUpdateGap).call(this, channelId, "updateChannelTooLong");
1097
+ return;
1098
+ }
1099
+ if (update.pts != 0) {
1100
+ const ptsCount = update.pts_count;
1101
+ if (checkGap) {
1102
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_checkChannelGap).call(this, channelId, update.pts, ptsCount);
1103
+ }
1104
+ let currentPts = await this.storage.getChannelPts(channelId);
1105
+ currentPts ??= update.pts - ptsCount;
1106
+ if (currentPts + ptsCount > update.pts) {
1107
+ return;
1108
+ }
1109
+ }
1110
+ await this.storage.setChannelPts(channelId, update.pts);
1111
+ __classPrivateFieldGet(this, _Client_handleUpdateQueue, "f").add(async () => {
1112
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleUpdate).call(this, update);
1113
+ });
1114
+ }, _Client_queueChannelUpdate = function _Client_queueChannelUpdate(update, checkGap) {
1115
+ const channelId = update instanceof _2_tl_js_1.types.UpdateNewChannelMessage || update instanceof _2_tl_js_1.types.UpdateEditChannelMessage ? update.message.peer_id[_2_tl_js_1.as](_2_tl_js_1.types.PeerChannel).channel_id : update.channel_id;
1116
+ let queue = __classPrivateFieldGet(this, _Client_channelUpdateQueues, "f").get(channelId);
1117
+ if (queue == undefined) {
1118
+ queue = new _1_utilities_js_1.Queue(`channelUpdates-${channelId}`);
1119
+ __classPrivateFieldGet(this, _Client_channelUpdateQueues, "f").set(channelId, queue);
1120
+ }
1121
+ queue.add(async () => {
1122
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChannelUpdate).call(this, update, checkGap);
1123
+ });
1124
+ }, _Client_handlePtsUpdate = async function _Client_handlePtsUpdate(update, checkGap) {
1125
+ const localState = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
1126
+ if (update.pts != 0) {
1127
+ if (checkGap) {
1128
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_checkGap).call(this, update.pts, update.pts_count);
1129
+ }
1130
+ if (localState.pts + update.pts_count > update.pts) {
1131
+ return;
1132
+ }
1133
+ }
1134
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setUpdatePts).call(this, update.pts);
1135
+ __classPrivateFieldGet(this, _Client_handleUpdateQueue, "f").add(async () => {
1136
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleUpdate).call(this, update);
1137
+ });
1138
+ }, _Client_queuePtsUpdate = function _Client_queuePtsUpdate(update, checkGap) {
1139
+ __classPrivateFieldGet(this, _Client_ptsUpdateQueue, "f").add(async () => {
1140
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handlePtsUpdate).call(this, update, checkGap);
1141
+ });
1087
1142
  }, _Client_processUpdates = async function _Client_processUpdates(updates_, checkGap) {
1088
1143
  __classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
1089
- /// First, individual updates (Update[1]) and updateShort* are extracted from Updates.[2]
1144
+ /// First, individual updates (Update[1]) are extracted from Updates.[2]
1090
1145
  ///
1091
1146
  /// If an updatesTooLong[3] was received, an update gap recovery is initiated and no further action will be taken.
1092
1147
  ///
@@ -1107,14 +1162,14 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1107
1162
  const localState = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
1108
1163
  const localSeq = localState.seq;
1109
1164
  if (localSeq + 1 == seqStart) {
1110
- // The updates can be applied.
1165
+ // The update sequence can be applied.
1111
1166
  localState.seq = seq;
1112
1167
  localState.date = updates_.date;
1113
1168
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setUpdateStateDate).call(this, updates_.date);
1114
1169
  await this.storage.setState(localState);
1115
1170
  }
1116
1171
  else if (localSeq + 1 > seqStart) {
1117
- // The updates were already applied, and must be ignored.
1172
+ // The update sequence was already applied, and must be ignored.
1118
1173
  d("localSeq + 1 > seqStart");
1119
1174
  return;
1120
1175
  }
@@ -1128,10 +1183,53 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1128
1183
  else if (updates_ instanceof _2_tl_js_1.types.UpdateShort) {
1129
1184
  updates = [updates_.update];
1130
1185
  }
1131
- else if (updates_ instanceof _2_tl_js_1.types.UpdateShortMessage ||
1132
- updates_ instanceof _2_tl_js_1.types.UpdateShortChatMessage ||
1133
- updates_ instanceof _2_tl_js_1.types.UpdateShortSentMessage) {
1134
- updates = [updates_];
1186
+ else if (updates_ instanceof _2_tl_js_1.types.UpdateShortMessage) {
1187
+ updates = [
1188
+ new _2_tl_js_1.types.UpdateNewMessage({
1189
+ message: new _2_tl_js_1.types.Message({
1190
+ out: updates_.out,
1191
+ mentioned: updates_.mentioned,
1192
+ media_unread: updates_.media_unread,
1193
+ silent: updates_.silent,
1194
+ id: updates_.id,
1195
+ from_id: updates_.out ? new _2_tl_js_1.types.PeerUser({ user_id: await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).call(this).then(BigInt) }) : new _2_tl_js_1.types.PeerUser({ user_id: updates_.user_id }),
1196
+ peer_id: new _2_tl_js_1.types.PeerUser({ user_id: updates_.user_id }),
1197
+ message: updates_.message,
1198
+ date: updates_.date,
1199
+ fwd_from: updates_.fwd_from,
1200
+ via_bot_id: updates_.via_bot_id,
1201
+ reply_to: updates_.reply_to,
1202
+ entities: updates_.entities,
1203
+ ttl_period: updates_.ttl_period,
1204
+ }),
1205
+ pts: updates_.pts,
1206
+ pts_count: updates_.pts_count,
1207
+ }),
1208
+ ];
1209
+ }
1210
+ else if (updates_ instanceof _2_tl_js_1.types.UpdateShortChatMessage) {
1211
+ updates = [
1212
+ new _2_tl_js_1.types.UpdateNewMessage({
1213
+ message: new _2_tl_js_1.types.Message({
1214
+ out: updates_.out,
1215
+ mentioned: updates_.mentioned,
1216
+ media_unread: updates_.media_unread,
1217
+ silent: updates_.silent,
1218
+ id: updates_.id,
1219
+ from_id: new _2_tl_js_1.types.PeerUser({ user_id: updates_.from_id }),
1220
+ peer_id: new _2_tl_js_1.types.PeerChat({ chat_id: updates_.chat_id }),
1221
+ fwd_from: updates_.fwd_from,
1222
+ via_bot_id: updates_.via_bot_id,
1223
+ reply_to: updates_.reply_to,
1224
+ date: updates_.date,
1225
+ message: updates_.message,
1226
+ entities: updates_.entities,
1227
+ ttl_period: updates_.ttl_period,
1228
+ }),
1229
+ pts: updates_.pts,
1230
+ pts_count: updates_.pts_count,
1231
+ }),
1232
+ ];
1135
1233
  }
1136
1234
  else if (updates_ instanceof _2_tl_js_1.types.UpdatesTooLong) {
1137
1235
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "updatesTooLong");
@@ -1143,86 +1241,20 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1143
1241
  else {
1144
1242
  (0, _1_utilities_js_1.UNREACHABLE)();
1145
1243
  }
1146
- /// Then, we go through each Update and updateShort*, and see if they are order-sensitive.
1147
- /// If they were, we check the local state to see if it is OK to process them right away.
1148
- ///
1149
- /// If we there was a gap, a recovery process will be initiated and the processing will be postponed.
1150
- let localState = null;
1151
- let originalPts = null;
1152
- const channelPtsMap = new Map();
1153
- for (const update of updates) {
1154
- if ((0, _0_utilities_js_1.isPtsUpdate)(update)) {
1155
- if (update.pts == 0) {
1156
- continue;
1157
- }
1158
- if (checkGap) {
1159
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_checkGap).call(this, update.pts, update.pts_count);
1160
- }
1161
- localState ??= await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
1162
- originalPts ??= localState.pts;
1163
- if (localState.pts + update.pts_count > update.pts) {
1164
- updates = updates.filter((v) => v != update);
1165
- }
1166
- else {
1167
- localState.pts = update.pts;
1168
- }
1169
- }
1170
- else if ((0, _0_utilities_js_1.isChannelPtsUpdate)(update)) {
1171
- if (update.pts == 0) {
1172
- continue;
1173
- }
1174
- const ptsCount = update.pts_count;
1175
- const channelId = update instanceof _2_tl_js_1.types.UpdateNewChannelMessage || update instanceof _2_tl_js_1.types.UpdateEditChannelMessage ? update.message.peer_id[_2_tl_js_1.as](_2_tl_js_1.types.PeerChannel).channel_id : update.channel_id;
1176
- if (checkGap) {
1177
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_checkChannelGap).call(this, channelId, update.pts, ptsCount);
1178
- }
1179
- let currentPts = channelPtsMap.get(channelId);
1180
- if (currentPts === undefined) {
1181
- currentPts = await this.storage.getChannelPts(channelId);
1182
- }
1183
- currentPts ??= update.pts - ptsCount;
1184
- if (currentPts + ptsCount > update.pts) {
1185
- updates = updates.filter((v) => v != update);
1186
- }
1187
- else {
1188
- channelPtsMap.set(channelId, update.pts);
1189
- }
1190
- }
1191
- }
1192
1244
  /// We process the updates when we are sure there is no gap.
1193
1245
  if (updates_ instanceof _2_tl_js_1.types.Updates || updates_ instanceof _2_tl_js_1.types.UpdatesCombined) {
1194
1246
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, updates_.chats);
1195
1247
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUsers).call(this, updates_.users);
1196
1248
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setUpdateStateDate).call(this, updates_.date);
1197
1249
  }
1198
- else if (updates_ instanceof _2_tl_js_1.types.UpdateShort) {
1250
+ else if (updates_ instanceof _2_tl_js_1.types.UpdateShort ||
1251
+ updates_ instanceof _2_tl_js_1.types.UpdateShortMessage ||
1252
+ updates_ instanceof _2_tl_js_1.types.UpdateShortChatMessage ||
1253
+ updates_ instanceof _2_tl_js_1.types.UpdateShortSentMessage) {
1199
1254
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setUpdateStateDate).call(this, updates_.date);
1200
1255
  }
1201
- const updatesToHandle = new Array();
1202
1256
  for (const update of updates) {
1203
- if (update instanceof _2_tl_js_1.types.UpdateShortMessage ||
1204
- update instanceof _2_tl_js_1.types.UpdateShortChatMessage ||
1205
- update instanceof _2_tl_js_1.types.UpdateShortSentMessage) {
1206
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setUpdateStateDate).call(this, update.date);
1207
- }
1208
- else if (update instanceof _2_tl_js_1.types.UpdateChannelTooLong) {
1209
- if (update.pts != undefined) {
1210
- await this.storage.setChannelPts(update.channel_id, update.pts);
1211
- }
1212
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverChannelUpdateGap).call(this, update.channel_id, "updateChannelTooLong");
1213
- }
1214
- else if (update instanceof _2_tl_js_1.types.UpdateUserName) {
1215
- await this.storage.updateUsernames("user", update.user_id, update.usernames.map((v) => v.username));
1216
- const peer = new _2_tl_js_1.types.PeerUser(update);
1217
- const entity = await this[getEntity](peer);
1218
- if (entity != null) {
1219
- entity.usernames = update.usernames;
1220
- entity.first_name = update.first_name;
1221
- entity.last_name = update.last_name;
1222
- await this.storage.setEntity(entity);
1223
- }
1224
- }
1225
- else if (update instanceof _2_tl_js_1.types.UpdatePtsChanged) {
1257
+ if (update instanceof _2_tl_js_1.types.UpdatePtsChanged) {
1226
1258
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_fetchState).call(this, "updatePtsChanged");
1227
1259
  if (__classPrivateFieldGet(this, _Client_updateState, "f")) {
1228
1260
  await this.storage.setState(__classPrivateFieldGet(this, _Client_updateState, "f"));
@@ -1231,31 +1263,18 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1231
1263
  (0, _1_utilities_js_1.UNREACHABLE)();
1232
1264
  }
1233
1265
  }
1234
- if ((0, _0_utilities_js_1.isPtsUpdate)(update)) {
1235
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setUpdatePts).call(this, update.pts);
1266
+ else if ((0, _0_utilities_js_1.isPtsUpdate)(update)) {
1267
+ __classPrivateFieldGet(this, _Client_instances, "m", _Client_queuePtsUpdate).call(this, update, checkGap);
1236
1268
  }
1237
1269
  else if ((0, _0_utilities_js_1.isChannelPtsUpdate)(update)) {
1238
- let channelId = null;
1239
- if ("channel_id" in update) {
1240
- channelId = update.channel_id;
1241
- }
1242
- else if ("peer_id" in update.message && update.message.peer_id !== undefined && "channel_id" in update.message.peer_id) {
1243
- channelId = update.message.peer_id.channel_id;
1244
- }
1245
- if (channelId != null) {
1246
- await this.storage.setChannelPts(channelId, update.pts);
1247
- }
1270
+ __classPrivateFieldGet(this, _Client_instances, "m", _Client_queueChannelUpdate).call(this, update, checkGap);
1248
1271
  }
1249
- /// If there were any Update, they will be passed to the update handling queue.
1250
- if (update instanceof _2_tl_js_1.types._Update || update instanceof _2_tl_js_1.types.UpdateShortMessage || update instanceof _2_tl_js_1.types.UpdateShortChatMessage || update instanceof _2_tl_js_1.types.UpdateShortSentMessage) {
1251
- updatesToHandle.push(update);
1272
+ else {
1273
+ __classPrivateFieldGet(this, _Client_handleUpdateQueue, "f").add(async () => {
1274
+ await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleUpdate).call(this, update);
1275
+ });
1252
1276
  }
1253
1277
  }
1254
- __classPrivateFieldGet(this, _Client_handleUpdateQueue, "f").add(async () => {
1255
- for (const update of updatesToHandle) {
1256
- await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleUpdate).call(this, update);
1257
- }
1258
- });
1259
1278
  }, _Client_setUpdateStateDate = async function _Client_setUpdateStateDate(date) {
1260
1279
  const localState = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
1261
1280
  localState.date = date;
@@ -1531,7 +1550,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1531
1550
  reply_markup: replyMarkup,
1532
1551
  });
1533
1552
  const message_ = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
1534
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message_, "text");
1553
+ return (0, _3_types_js_1.assertMessageType)(message_, "text");
1535
1554
  }
1536
1555
  /**
1537
1556
  * Edit a message's text.
@@ -1553,7 +1572,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1553
1572
  reply_markup: await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params),
1554
1573
  });
1555
1574
  const message_ = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
1556
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message_, "text");
1575
+ return (0, _3_types_js_1.assertMessageType)(message_, "text");
1557
1576
  }
1558
1577
  /**
1559
1578
  * Retrieve multiple messages.
@@ -1941,7 +1960,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1941
1960
  message: "",
1942
1961
  });
1943
1962
  const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
1944
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "poll");
1963
+ return (0, _3_types_js_1.assertMessageType)(message, "poll");
1945
1964
  }
1946
1965
  /**
1947
1966
  * Send a chat action.
@@ -2149,9 +2168,19 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2149
2168
  }
2150
2169
  on(filter, ...middleawre) {
2151
2170
  const type = typeof filter === "string" ? filter : filter[0];
2152
- const keys = Array.isArray(filter) ? filter.slice(1) : [];
2171
+ let keys = Array.isArray(filter) ? filter.slice(1) : [];
2172
+ let messageType = null;
2173
+ if (type == "message") {
2174
+ messageType = keys[0];
2175
+ keys = keys.slice(1);
2176
+ }
2153
2177
  return this.filter((ctx) => {
2154
2178
  if (type in ctx) {
2179
+ if (messageType != null) {
2180
+ // deno-lint-ignore ban-ts-comment
2181
+ // @ts-ignore
2182
+ (0, _3_types_js_1.assertMessageType)(ctx[type], messageType);
2183
+ }
2155
2184
  if (keys.length > 0) {
2156
2185
  for (const key of keys) {
2157
2186
  // deno-lint-ignore ban-ts-comment
@@ -2166,6 +2195,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2166
2195
  else {
2167
2196
  return false;
2168
2197
  }
2198
+ // deno-lint-ignore no-explicit-any
2169
2199
  }, ...middleawre);
2170
2200
  }
2171
2201
  command(commands, ...middleawre) {
@@ -2321,7 +2351,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2321
2351
  }
2322
2352
  }
2323
2353
  const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendMedia).call(this, chatId, media, params);
2324
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "photo");
2354
+ return (0, _3_types_js_1.assertMessageType)(message, "photo");
2325
2355
  }
2326
2356
  /**
2327
2357
  * Send a document.
@@ -2332,7 +2362,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2332
2362
  */
2333
2363
  async sendDocument(chatId, document, params) {
2334
2364
  const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, document, params, _3_types_js_1.FileType.Document, []);
2335
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "document");
2365
+ return (0, _3_types_js_1.assertMessageType)(message, "document");
2336
2366
  }
2337
2367
  /**
2338
2368
  * Send a video.
@@ -2350,7 +2380,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2350
2380
  duration: params?.duration ?? 0,
2351
2381
  }),
2352
2382
  ]);
2353
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "video");
2383
+ return (0, _3_types_js_1.assertMessageType)(message, "video");
2354
2384
  }
2355
2385
  /**
2356
2386
  * Send an animation.
@@ -2369,7 +2399,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2369
2399
  duration: params?.duration ?? 0,
2370
2400
  }),
2371
2401
  ]);
2372
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "animation");
2402
+ return (0, _3_types_js_1.assertMessageType)(message, "animation");
2373
2403
  }
2374
2404
  /**
2375
2405
  * Send a voice message.
@@ -2385,7 +2415,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2385
2415
  duration: params?.duration ?? 0,
2386
2416
  }),
2387
2417
  ]);
2388
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "voice");
2418
+ return (0, _3_types_js_1.assertMessageType)(message, "voice");
2389
2419
  }
2390
2420
  /**
2391
2421
  * Send an audio file.
@@ -2402,7 +2432,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2402
2432
  title: params?.title,
2403
2433
  }),
2404
2434
  ]);
2405
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "audio");
2435
+ return (0, _3_types_js_1.assertMessageType)(message, "audio");
2406
2436
  }
2407
2437
  /**
2408
2438
  * Send a video note.
@@ -2420,7 +2450,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2420
2450
  duration: params?.duration ?? 0,
2421
2451
  }),
2422
2452
  ], false);
2423
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "videoNote");
2453
+ return (0, _3_types_js_1.assertMessageType)(message, "videoNote");
2424
2454
  }
2425
2455
  /**
2426
2456
  * Send a location.
@@ -2466,7 +2496,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2466
2496
  message: "",
2467
2497
  });
2468
2498
  const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
2469
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "location");
2499
+ return (0, _3_types_js_1.assertMessageType)(message, "location");
2470
2500
  }
2471
2501
  /**
2472
2502
  * Send a contact.
@@ -2500,7 +2530,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2500
2530
  message: "",
2501
2531
  });
2502
2532
  const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
2503
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "contact");
2533
+ return (0, _3_types_js_1.assertMessageType)(message, "contact");
2504
2534
  }
2505
2535
  /**
2506
2536
  * Send a dice.
@@ -2529,7 +2559,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2529
2559
  message: "",
2530
2560
  });
2531
2561
  const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
2532
- return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "dice");
2562
+ return (0, _3_types_js_1.assertMessageType)(message, "dice");
2533
2563
  }
2534
2564
  /**
2535
2565
  * Send a venue.
@@ -2570,7 +2600,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2570
2600
  message: "",
2571
2601
  });
2572
2602
  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");
2603
+ return (0, _3_types_js_1.assertMessageType)(message, "venue");
2574
2604
  }
2575
2605
  /**
2576
2606
  * Get network statistics. This might not always be available.
@@ -2819,7 +2849,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
2819
2849
  await this.api.messages.sendReaction({
2820
2850
  peer: await this.getInputPeer(chatId),
2821
2851
  msg_id: messageId,
2822
- reaction: [reaction.type == "emoji" ? new _2_tl_js_1.types.ReactionEmoji({ emoticon: reaction.emoji }) : new _2_tl_js_1.types.ReactionCustomEmoji({ document_id: BigInt(reaction.id) })],
2852
+ reaction: [(0, _3_types_js_1.reactionToTlObject)(reaction)],
2823
2853
  big: params?.big ? true : undefined,
2824
2854
  add_to_recent: params?.addToRecents ? true : undefined,
2825
2855
  });
@@ -2838,49 +2868,16 @@ _a = Client, _Client_getMe = async function _Client_getMe() {
2838
2868
  }, _Client_handleUpdate =
2839
2869
  // TODO: log errors
2840
2870
  async function _Client_handleUpdate(update) {
2841
- if (update instanceof _2_tl_js_1.types.UpdateShortMessage) {
2842
- update = new _2_tl_js_1.types.UpdateNewMessage({
2843
- message: new _2_tl_js_1.types.Message({
2844
- out: update.out,
2845
- mentioned: update.mentioned,
2846
- media_unread: update.media_unread,
2847
- silent: update.silent,
2848
- id: update.id,
2849
- from_id: update.out ? new _2_tl_js_1.types.PeerUser({ user_id: await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).call(this).then(BigInt) }) : new _2_tl_js_1.types.PeerUser({ user_id: update.user_id }),
2850
- peer_id: new _2_tl_js_1.types.PeerUser({ user_id: update.user_id }),
2851
- message: update.message,
2852
- date: update.date,
2853
- fwd_from: update.fwd_from,
2854
- via_bot_id: update.via_bot_id,
2855
- reply_to: update.reply_to,
2856
- entities: update.entities,
2857
- ttl_period: update.ttl_period,
2858
- }),
2859
- pts: update.pts,
2860
- pts_count: update.pts_count,
2861
- });
2862
- }
2863
- else if (update instanceof _2_tl_js_1.types.UpdateShortChatMessage) {
2864
- update = new _2_tl_js_1.types.UpdateNewMessage({
2865
- message: new _2_tl_js_1.types.Message({
2866
- out: update.out,
2867
- mentioned: update.mentioned,
2868
- media_unread: update.media_unread,
2869
- silent: update.silent,
2870
- id: update.id,
2871
- from_id: new _2_tl_js_1.types.PeerUser({ user_id: update.from_id }),
2872
- peer_id: new _2_tl_js_1.types.PeerChat({ chat_id: update.chat_id }),
2873
- fwd_from: update.fwd_from,
2874
- via_bot_id: update.via_bot_id,
2875
- reply_to: update.reply_to,
2876
- date: update.date,
2877
- message: update.message,
2878
- entities: update.entities,
2879
- ttl_period: update.ttl_period,
2880
- }),
2881
- pts: update.pts,
2882
- pts_count: update.pts_count,
2883
- });
2871
+ if (update instanceof _2_tl_js_1.types.UpdateUserName) {
2872
+ await this.storage.updateUsernames("user", update.user_id, update.usernames.map((v) => v.username));
2873
+ const peer = new _2_tl_js_1.types.PeerUser(update);
2874
+ const entity = await this[getEntity](peer);
2875
+ if (entity != null) {
2876
+ entity.usernames = update.usernames;
2877
+ entity.first_name = update.first_name;
2878
+ entity.last_name = update.last_name;
2879
+ await this.storage.setEntity(entity);
2880
+ }
2884
2881
  }
2885
2882
  if (update instanceof _2_tl_js_1.types.UpdateNewMessage || update instanceof _2_tl_js_1.types.UpdateNewChannelMessage || update instanceof _2_tl_js_1.types.UpdateEditMessage || update instanceof _2_tl_js_1.types.UpdateEditChannelMessage) {
2886
2883
  if (update.message instanceof _2_tl_js_1.types.Message || update.message instanceof _2_tl_js_1.types.MessageService) {
@@ -2889,6 +2886,17 @@ async function _Client_handleUpdate(update) {
2889
2886
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_reassignChatLastMessage).call(this, chatId);
2890
2887
  }
2891
2888
  }
2889
+ if (update instanceof _2_tl_js_1.types.UpdateMessageReactions) {
2890
+ const chatId = (0, _2_tl_js_1.peerToChatId)(update.peer);
2891
+ const message = await this.storage.getMessage(chatId, update.msg_id);
2892
+ if (message instanceof _2_tl_js_1.types.Message) {
2893
+ message.reactions = update.reactions;
2894
+ await this.storage.setMessage(chatId, update.msg_id, message);
2895
+ }
2896
+ const recentReactions = update.reactions.recent_reactions ?? [];
2897
+ const reactions = update.reactions.results.map((v) => (0, _3_types_js_1.constructMessageReaction)(v, recentReactions));
2898
+ await __classPrivateFieldGet(this, _Client_handle, "f").call(this, await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, { reactions: { chatId, messageId: update.msg_id, reactions } }), _0_utilities_js_1.resolve);
2899
+ }
2892
2900
  if (update instanceof _2_tl_js_1.types.UpdateNewMessage ||
2893
2901
  update instanceof _2_tl_js_1.types.UpdateNewChannelMessage ||
2894
2902
  update instanceof _2_tl_js_1.types.UpdateEditMessage ||
@@ -2988,11 +2996,6 @@ async function _Client_handleUpdate(update) {
2988
2996
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_assertBot).call(this, "replyMarkup");
2989
2997
  return (0, _3_types_js_1.replyMarkupToTlObject)(params.replyMarkup, __classPrivateFieldGet(this, _Client_usernameResolver, "f").bind(this));
2990
2998
  }
2991
- }, _Client_assertMsgHas = function _Client_assertMsgHas(message, key) {
2992
- if (!(key in message) || message[key] === undefined) {
2993
- (0, _1_utilities_js_1.UNREACHABLE)();
2994
- }
2995
- return message;
2996
2999
  }, _Client_setMyInfo =
2997
3000
  //#endregion
2998
3001
  async function _Client_setMyInfo(info) {
@@ -3308,6 +3311,7 @@ async function _Client_setMyInfo(info) {
3308
3311
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendChatUpdate).call(this, chat.id, false);
3309
3312
  }
3310
3313
  }
3314
+ await this.storage.setPinnedChats(listId, await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getPinnedChats).call(this, listId));
3311
3315
  }, _Client_fetchChats = async function _Client_fetchChats(listId, limit, after) {
3312
3316
  const dialogs = await this.api.messages.getDialogs({
3313
3317
  limit,