@mtcute/core 0.23.2 → 0.24.0

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 (131) hide show
  1. package/client.cjs +21 -2
  2. package/client.js +21 -2
  3. package/highlevel/base.cjs +15 -3
  4. package/highlevel/base.d.cts +4 -1
  5. package/highlevel/base.d.ts +4 -1
  6. package/highlevel/base.js +15 -3
  7. package/highlevel/client.d.cts +56 -7
  8. package/highlevel/client.d.ts +56 -7
  9. package/highlevel/client.types.d.cts +2 -1
  10. package/highlevel/client.types.d.ts +2 -1
  11. package/highlevel/methods/chats/get-chat-event-log.cjs +5 -3
  12. package/highlevel/methods/chats/get-chat-event-log.js +3 -1
  13. package/highlevel/methods/files/download-iterable.cjs +1 -1
  14. package/highlevel/methods/files/download-iterable.js +1 -1
  15. package/highlevel/methods/premium/_normalize-input-star-gift.cjs +6 -0
  16. package/highlevel/methods/premium/_normalize-input-star-gift.js +6 -0
  17. package/highlevel/methods/premium/buy-resale-gift.cjs +30 -0
  18. package/highlevel/methods/premium/buy-resale-gift.d.cts +13 -0
  19. package/highlevel/methods/premium/buy-resale-gift.d.ts +13 -0
  20. package/highlevel/methods/premium/buy-resale-gift.js +25 -0
  21. package/highlevel/methods/premium/get-resale-star-gifts.cjs +107 -0
  22. package/highlevel/methods/premium/get-resale-star-gifts.d.cts +45 -0
  23. package/highlevel/methods/premium/get-resale-star-gifts.d.ts +45 -0
  24. package/highlevel/methods/premium/get-resale-star-gifts.js +102 -0
  25. package/highlevel/methods/premium/get-unique-star-gift.cjs +1 -1
  26. package/highlevel/methods/premium/get-unique-star-gift.js +1 -1
  27. package/highlevel/methods/premium/set-gift-resale-price.cjs +19 -0
  28. package/highlevel/methods/premium/set-gift-resale-price.d.cts +9 -0
  29. package/highlevel/methods/premium/set-gift-resale-price.d.ts +9 -0
  30. package/highlevel/methods/premium/set-gift-resale-price.js +14 -0
  31. package/highlevel/methods/premium/transfer-star-gift.cjs +28 -13
  32. package/highlevel/methods/premium/transfer-star-gift.d.cts +1 -1
  33. package/highlevel/methods/premium/transfer-star-gift.d.ts +1 -1
  34. package/highlevel/methods/premium/transfer-star-gift.js +28 -13
  35. package/highlevel/methods/premium/upgrade-star-gift.cjs +26 -11
  36. package/highlevel/methods/premium/upgrade-star-gift.js +26 -11
  37. package/highlevel/methods/users/resolve-peer.cjs +63 -70
  38. package/highlevel/methods/users/resolve-peer.d.cts +2 -1
  39. package/highlevel/methods/users/resolve-peer.d.ts +2 -1
  40. package/highlevel/methods/users/resolve-peer.js +61 -68
  41. package/highlevel/methods/users/resolve-phone-number.cjs +36 -0
  42. package/highlevel/methods/users/resolve-phone-number.d.cts +10 -0
  43. package/highlevel/methods/users/resolve-phone-number.d.ts +10 -0
  44. package/highlevel/methods/users/resolve-phone-number.js +31 -0
  45. package/highlevel/methods.d.cts +10 -4
  46. package/highlevel/methods.d.ts +10 -4
  47. package/highlevel/types/messages/message-action.cjs +8 -2
  48. package/highlevel/types/messages/message-action.d.cts +6 -0
  49. package/highlevel/types/messages/message-action.d.ts +6 -0
  50. package/highlevel/types/messages/message-action.js +8 -2
  51. package/highlevel/types/peers/chat-event/actions.cjs +49 -1
  52. package/highlevel/types/peers/chat-event/actions.d.cts +60 -2
  53. package/highlevel/types/peers/chat-event/actions.d.ts +60 -2
  54. package/highlevel/types/peers/chat-event/actions.js +49 -1
  55. package/highlevel/types/peers/chat-event/filters.cjs +9 -0
  56. package/highlevel/types/peers/chat-event/filters.js +9 -0
  57. package/highlevel/types/peers/chat-event/index.cjs +3 -2
  58. package/highlevel/types/peers/chat-event/index.d.cts +2 -1
  59. package/highlevel/types/peers/chat-event/index.d.ts +2 -1
  60. package/highlevel/types/peers/chat-event/index.js +3 -2
  61. package/highlevel/types/peers/chat.cjs +5 -4
  62. package/highlevel/types/peers/chat.d.cts +2 -0
  63. package/highlevel/types/peers/chat.d.ts +2 -0
  64. package/highlevel/types/peers/chat.js +5 -4
  65. package/highlevel/types/peers/peer.d.cts +2 -3
  66. package/highlevel/types/peers/peer.d.ts +2 -3
  67. package/highlevel/types/peers/user.cjs +1 -4
  68. package/highlevel/types/peers/user.js +1 -4
  69. package/highlevel/types/premium/saved-star-gift.cjs +8 -0
  70. package/highlevel/types/premium/saved-star-gift.d.cts +4 -0
  71. package/highlevel/types/premium/saved-star-gift.d.ts +4 -0
  72. package/highlevel/types/premium/saved-star-gift.js +8 -0
  73. package/highlevel/types/premium/stars-gift-unique.cjs +13 -2
  74. package/highlevel/types/premium/stars-gift-unique.d.cts +6 -2
  75. package/highlevel/types/premium/stars-gift-unique.d.ts +6 -2
  76. package/highlevel/types/premium/stars-gift-unique.js +13 -2
  77. package/highlevel/types/premium/stars-gift.cjs +11 -1
  78. package/highlevel/types/premium/stars-gift.d.cts +8 -1
  79. package/highlevel/types/premium/stars-gift.d.ts +8 -1
  80. package/highlevel/types/premium/stars-gift.js +11 -1
  81. package/highlevel/types/premium/stars-transaction.cjs +7 -1
  82. package/highlevel/types/premium/stars-transaction.d.cts +9 -2
  83. package/highlevel/types/premium/stars-transaction.d.ts +9 -2
  84. package/highlevel/types/premium/stars-transaction.js +7 -1
  85. package/highlevel/types/reactions/emoji-status.cjs +6 -0
  86. package/highlevel/types/reactions/emoji-status.d.cts +1 -0
  87. package/highlevel/types/reactions/emoji-status.d.ts +1 -0
  88. package/highlevel/types/reactions/emoji-status.js +6 -0
  89. package/highlevel/types/utils.d.cts +4 -0
  90. package/highlevel/types/utils.d.ts +4 -0
  91. package/highlevel/updates/manager.cjs +35 -26
  92. package/highlevel/updates/manager.d.cts +6 -6
  93. package/highlevel/updates/manager.d.ts +6 -6
  94. package/highlevel/updates/manager.js +35 -26
  95. package/highlevel/updates/types.d.cts +6 -6
  96. package/highlevel/updates/types.d.ts +6 -6
  97. package/highlevel/utils/misc-utils.cjs +8 -0
  98. package/highlevel/utils/misc-utils.d.cts +2 -1
  99. package/highlevel/utils/misc-utils.d.ts +2 -1
  100. package/highlevel/utils/misc-utils.js +8 -0
  101. package/highlevel/worker/port.cjs +7 -5
  102. package/highlevel/worker/port.d.cts +3 -2
  103. package/highlevel/worker/port.d.ts +3 -2
  104. package/highlevel/worker/port.js +7 -5
  105. package/methods.cjs +8 -0
  106. package/methods.js +8 -0
  107. package/network/client.cjs +12 -8
  108. package/network/client.d.cts +4 -1
  109. package/network/client.d.ts +4 -1
  110. package/network/client.js +12 -8
  111. package/network/network-manager.cjs +1 -1
  112. package/network/network-manager.js +1 -1
  113. package/network/session-connection.cjs +1 -0
  114. package/network/session-connection.js +1 -0
  115. package/package.json +2 -2
  116. package/utils/binary/compat.cjs +9 -0
  117. package/utils/binary/compat.js +9 -0
  118. package/utils/index.d.cts +0 -1
  119. package/utils/index.d.ts +0 -1
  120. package/utils/sorted-array.cjs +6 -0
  121. package/utils/sorted-array.d.cts +2 -0
  122. package/utils/sorted-array.d.ts +2 -0
  123. package/utils/sorted-array.js +6 -0
  124. package/utils.cjs +1 -2
  125. package/utils.js +2 -3
  126. package/utils/linked-list.cjs +0 -65
  127. package/utils/linked-list.d.cts +0 -21
  128. package/utils/linked-list.d.ts +0 -21
  129. package/utils/linked-list.js +0 -60
  130. package/utils/linked-list.test.d.cts +0 -1
  131. package/utils/linked-list.test.d.ts +0 -1
package/client.cjs CHANGED
@@ -191,6 +191,7 @@ const removeCloudPassword = require("./highlevel/methods/password/remove-cloud-p
191
191
  const _normalizeInputStarGift = require("./highlevel/methods/premium/_normalize-input-star-gift.cjs");
192
192
  const acceptStarGift = require("./highlevel/methods/premium/accept-star-gift.cjs");
193
193
  const applyBoost = require("./highlevel/methods/premium/apply-boost.cjs");
194
+ const buyResaleGift = require("./highlevel/methods/premium/buy-resale-gift.cjs");
194
195
  const canApplyBoost = require("./highlevel/methods/premium/can-apply-boost.cjs");
195
196
  const createBusinessChatLink = require("./highlevel/methods/premium/create-business-chat-link.cjs");
196
197
  const editBusinessChatLink = require("./highlevel/methods/premium/edit-business-chat-link.cjs");
@@ -199,6 +200,7 @@ const getBoosts = require("./highlevel/methods/premium/get-boosts.cjs");
199
200
  const getBusinessChatLinks = require("./highlevel/methods/premium/get-business-chat-links.cjs");
200
201
  const getBusinessConnection = require("./highlevel/methods/premium/get-business-connection.cjs");
201
202
  const getMyBoostSlots = require("./highlevel/methods/premium/get-my-boost-slots.cjs");
203
+ const getResaleStarGifts = require("./highlevel/methods/premium/get-resale-star-gifts.cjs");
202
204
  const getSavedStarGiftsById = require("./highlevel/methods/premium/get-saved-star-gifts-by-id.cjs");
203
205
  const getSavedStarGifts = require("./highlevel/methods/premium/get-saved-star-gifts.cjs");
204
206
  const getStarGiftOptions = require("./highlevel/methods/premium/get-star-gift-options.cjs");
@@ -212,6 +214,7 @@ const pinStarGift = require("./highlevel/methods/premium/pin-star-gift.cjs");
212
214
  const sendStarGift = require("./highlevel/methods/premium/send-star-gift.cjs");
213
215
  const setBusinessIntro = require("./highlevel/methods/premium/set-business-intro.cjs");
214
216
  const setBusinessWorkHours = require("./highlevel/methods/premium/set-business-work-hours.cjs");
217
+ const setGiftResalePrice = require("./highlevel/methods/premium/set-gift-resale-price.cjs");
215
218
  const transferStarGift = require("./highlevel/methods/premium/transfer-star-gift.cjs");
216
219
  const upgradeStarGift = require("./highlevel/methods/premium/upgrade-star-gift.cjs");
217
220
  const addStickerToSet = require("./highlevel/methods/stickers/add-sticker-to-set.cjs");
@@ -260,6 +263,7 @@ const isPeerAvailable = require("./highlevel/methods/users/is-peer-available.cjs
260
263
  const iterProfilePhotos = require("./highlevel/methods/users/iter-profile-photos.cjs");
261
264
  const resolvePeerMany = require("./highlevel/methods/users/resolve-peer-many.cjs");
262
265
  const resolvePeer = require("./highlevel/methods/users/resolve-peer.cjs");
266
+ const resolvePhoneNumber = require("./highlevel/methods/users/resolve-phone-number.cjs");
263
267
  const setEmojiStatus = require("./highlevel/methods/users/set-emoji-status.cjs");
264
268
  const setGlobalTtl = require("./highlevel/methods/users/set-global-ttl.cjs");
265
269
  const setMyBirthday = require("./highlevel/methods/users/set-my-birthday.cjs");
@@ -1036,6 +1040,9 @@ TelegramClient.prototype.acceptStarGift = function(...args) {
1036
1040
  TelegramClient.prototype.applyBoost = function(...args) {
1037
1041
  return applyBoost.applyBoost(this._client, ...args);
1038
1042
  };
1043
+ TelegramClient.prototype.buyResaleGift = function(...args) {
1044
+ return buyResaleGift.buyResaleGift(this._client, ...args);
1045
+ };
1039
1046
  TelegramClient.prototype.canApplyBoost = function(...args) {
1040
1047
  return canApplyBoost.canApplyBoost(this._client, ...args);
1041
1048
  };
@@ -1063,6 +1070,9 @@ TelegramClient.prototype.getBusinessConnection = function(...args) {
1063
1070
  TelegramClient.prototype.getMyBoostSlots = function(...args) {
1064
1071
  return getMyBoostSlots.getMyBoostSlots(this._client, ...args);
1065
1072
  };
1073
+ TelegramClient.prototype.getResaleOptions = function(...args) {
1074
+ return getResaleStarGifts.getResaleOptions(this._client, ...args);
1075
+ };
1066
1076
  TelegramClient.prototype.getSavedStarGiftsById = function(...args) {
1067
1077
  return getSavedStarGiftsById.getSavedStarGiftsById(this._client, ...args);
1068
1078
  };
@@ -1102,6 +1112,9 @@ TelegramClient.prototype.setBusinessIntro = function(...args) {
1102
1112
  TelegramClient.prototype.setBusinessWorkHours = function(...args) {
1103
1113
  return setBusinessWorkHours.setBusinessWorkHours(this._client, ...args);
1104
1114
  };
1115
+ TelegramClient.prototype.setResaleStarGiftPrice = function(...args) {
1116
+ return setGiftResalePrice.setResaleStarGiftPrice(this._client, ...args);
1117
+ };
1105
1118
  TelegramClient.prototype.transferStarGift = function(...args) {
1106
1119
  return transferStarGift.transferStarGift(this._client, ...args);
1107
1120
  };
@@ -1258,6 +1271,9 @@ TelegramClient.prototype.resolveUser = function(...args) {
1258
1271
  TelegramClient.prototype.resolveChannel = function(...args) {
1259
1272
  return resolvePeer.resolveChannel(this._client, ...args);
1260
1273
  };
1274
+ TelegramClient.prototype.resolvePhoneNumber = function(...args) {
1275
+ return resolvePhoneNumber.resolvePhoneNumber(this._client, ...args);
1276
+ };
1261
1277
  TelegramClient.prototype.setMyEmojiStatus = function(...args) {
1262
1278
  return setEmojiStatus.setMyEmojiStatus(this._client, ...args);
1263
1279
  };
@@ -1294,8 +1310,11 @@ TelegramClient.prototype.prepare = function(...args) {
1294
1310
  TelegramClient.prototype.connect = function(...args) {
1295
1311
  return this._client.connect(...args);
1296
1312
  };
1297
- TelegramClient.prototype.close = function(...args) {
1298
- return this._client.close(...args);
1313
+ TelegramClient.prototype.disconnect = function(...args) {
1314
+ return this._client.disconnect(...args);
1315
+ };
1316
+ TelegramClient.prototype.destroy = function(...args) {
1317
+ return this._client.destroy(...args);
1299
1318
  };
1300
1319
  TelegramClient.prototype.notifyLoggedIn = function(...args) {
1301
1320
  return this._client.notifyLoggedIn(...args);
package/client.js CHANGED
@@ -184,6 +184,7 @@ import { removeCloudPassword } from "./highlevel/methods/password/remove-cloud-p
184
184
  import { _normalizeInputStarGift } from "./highlevel/methods/premium/_normalize-input-star-gift.js";
185
185
  import { acceptStarGift } from "./highlevel/methods/premium/accept-star-gift.js";
186
186
  import { applyBoost } from "./highlevel/methods/premium/apply-boost.js";
187
+ import { buyResaleGift } from "./highlevel/methods/premium/buy-resale-gift.js";
187
188
  import { canApplyBoost } from "./highlevel/methods/premium/can-apply-boost.js";
188
189
  import { createBusinessChatLink } from "./highlevel/methods/premium/create-business-chat-link.js";
189
190
  import { editBusinessChatLink, deleteBusinessChatLink } from "./highlevel/methods/premium/edit-business-chat-link.js";
@@ -192,6 +193,7 @@ import { getBoosts } from "./highlevel/methods/premium/get-boosts.js";
192
193
  import { getBusinessChatLinks } from "./highlevel/methods/premium/get-business-chat-links.js";
193
194
  import { getBusinessConnection } from "./highlevel/methods/premium/get-business-connection.js";
194
195
  import { getMyBoostSlots } from "./highlevel/methods/premium/get-my-boost-slots.js";
196
+ import { getResaleOptions } from "./highlevel/methods/premium/get-resale-star-gifts.js";
195
197
  import { getSavedStarGiftsById } from "./highlevel/methods/premium/get-saved-star-gifts-by-id.js";
196
198
  import { getSavedStarGifts } from "./highlevel/methods/premium/get-saved-star-gifts.js";
197
199
  import { getStarGiftOptions } from "./highlevel/methods/premium/get-star-gift-options.js";
@@ -205,6 +207,7 @@ import { togglePinnedStarGifts } from "./highlevel/methods/premium/pin-star-gift
205
207
  import { sendStarGift } from "./highlevel/methods/premium/send-star-gift.js";
206
208
  import { setBusinessIntro } from "./highlevel/methods/premium/set-business-intro.js";
207
209
  import { setBusinessWorkHours } from "./highlevel/methods/premium/set-business-work-hours.js";
210
+ import { setResaleStarGiftPrice } from "./highlevel/methods/premium/set-gift-resale-price.js";
208
211
  import { transferStarGift } from "./highlevel/methods/premium/transfer-star-gift.js";
209
212
  import { upgradeStarGift } from "./highlevel/methods/premium/upgrade-star-gift.js";
210
213
  import { addStickerToSet } from "./highlevel/methods/stickers/add-sticker-to-set.js";
@@ -253,6 +256,7 @@ import { isPeerAvailable } from "./highlevel/methods/users/is-peer-available.js"
253
256
  import { iterProfilePhotos } from "./highlevel/methods/users/iter-profile-photos.js";
254
257
  import { resolvePeerMany } from "./highlevel/methods/users/resolve-peer-many.js";
255
258
  import { resolvePeer, resolveUser, resolveChannel } from "./highlevel/methods/users/resolve-peer.js";
259
+ import { resolvePhoneNumber } from "./highlevel/methods/users/resolve-phone-number.js";
256
260
  import { setMyEmojiStatus, setEmojiStatus } from "./highlevel/methods/users/set-emoji-status.js";
257
261
  import { setGlobalTtl } from "./highlevel/methods/users/set-global-ttl.js";
258
262
  import { setMyBirthday } from "./highlevel/methods/users/set-my-birthday.js";
@@ -1029,6 +1033,9 @@ TelegramClient.prototype.acceptStarGift = function(...args) {
1029
1033
  TelegramClient.prototype.applyBoost = function(...args) {
1030
1034
  return applyBoost(this._client, ...args);
1031
1035
  };
1036
+ TelegramClient.prototype.buyResaleGift = function(...args) {
1037
+ return buyResaleGift(this._client, ...args);
1038
+ };
1032
1039
  TelegramClient.prototype.canApplyBoost = function(...args) {
1033
1040
  return canApplyBoost(this._client, ...args);
1034
1041
  };
@@ -1056,6 +1063,9 @@ TelegramClient.prototype.getBusinessConnection = function(...args) {
1056
1063
  TelegramClient.prototype.getMyBoostSlots = function(...args) {
1057
1064
  return getMyBoostSlots(this._client, ...args);
1058
1065
  };
1066
+ TelegramClient.prototype.getResaleOptions = function(...args) {
1067
+ return getResaleOptions(this._client, ...args);
1068
+ };
1059
1069
  TelegramClient.prototype.getSavedStarGiftsById = function(...args) {
1060
1070
  return getSavedStarGiftsById(this._client, ...args);
1061
1071
  };
@@ -1095,6 +1105,9 @@ TelegramClient.prototype.setBusinessIntro = function(...args) {
1095
1105
  TelegramClient.prototype.setBusinessWorkHours = function(...args) {
1096
1106
  return setBusinessWorkHours(this._client, ...args);
1097
1107
  };
1108
+ TelegramClient.prototype.setResaleStarGiftPrice = function(...args) {
1109
+ return setResaleStarGiftPrice(this._client, ...args);
1110
+ };
1098
1111
  TelegramClient.prototype.transferStarGift = function(...args) {
1099
1112
  return transferStarGift(this._client, ...args);
1100
1113
  };
@@ -1251,6 +1264,9 @@ TelegramClient.prototype.resolveUser = function(...args) {
1251
1264
  TelegramClient.prototype.resolveChannel = function(...args) {
1252
1265
  return resolveChannel(this._client, ...args);
1253
1266
  };
1267
+ TelegramClient.prototype.resolvePhoneNumber = function(...args) {
1268
+ return resolvePhoneNumber(this._client, ...args);
1269
+ };
1254
1270
  TelegramClient.prototype.setMyEmojiStatus = function(...args) {
1255
1271
  return setMyEmojiStatus(this._client, ...args);
1256
1272
  };
@@ -1287,8 +1303,11 @@ TelegramClient.prototype.prepare = function(...args) {
1287
1303
  TelegramClient.prototype.connect = function(...args) {
1288
1304
  return this._client.connect(...args);
1289
1305
  };
1290
- TelegramClient.prototype.close = function(...args) {
1291
- return this._client.close(...args);
1306
+ TelegramClient.prototype.disconnect = function(...args) {
1307
+ return this._client.disconnect(...args);
1308
+ };
1309
+ TelegramClient.prototype.destroy = function(...args) {
1310
+ return this._client.destroy(...args);
1292
1311
  };
1293
1312
  TelegramClient.prototype.notifyLoggedIn = function(...args) {
1294
1313
  return this._client.notifyLoggedIn(...args);
@@ -98,6 +98,7 @@ class BaseTelegramClient {
98
98
  // used in a hot path, avoid extra function calls
99
99
  _connected = false;
100
100
  _connect = functionUtils.asyncResettable(async () => {
101
+ if (this.#destroyed) throw new Error("Client is destroyed");
101
102
  await this._prepare.run();
102
103
  await this.mt.connect();
103
104
  this._connected = true;
@@ -114,14 +115,24 @@ class BaseTelegramClient {
114
115
  get isConnected() {
115
116
  return this._connected;
116
117
  }
117
- async close() {
118
- this.timers.destroy();
118
+ async disconnect() {
119
119
  this._connected = false;
120
- await this.mt.close();
120
+ this.timers.destroy();
121
121
  this.updates?.stopLoop();
122
122
  await this.storage.close();
123
123
  this._prepare.reset();
124
124
  this._connect.reset();
125
+ await this.mt.disconnect();
126
+ }
127
+ #destroyed = false;
128
+ async destroy() {
129
+ if (this.#destroyed) return;
130
+ this.#destroyed = true;
131
+ await this.disconnect();
132
+ await this.mt.destroy();
133
+ }
134
+ [Symbol.asyncDispose]() {
135
+ return this.destroy();
125
136
  }
126
137
  async notifyLoggedIn(auth) {
127
138
  const user = this.mt.network.notifyLoggedIn(auth);
@@ -202,6 +213,7 @@ class BaseTelegramClient {
202
213
  if (data.self) {
203
214
  await this.storage.self.store(data.self);
204
215
  }
216
+ await this.mt.storage.provider.authKeys.deleteAll();
205
217
  await this.mt.storage.provider.authKeys.set(data.primaryDcs.main.id, data.authKey);
206
218
  await this.mt.storage.save();
207
219
  }
@@ -20,6 +20,7 @@ export interface BaseTelegramClientOptions extends MtClientOptions {
20
20
  updates?: UpdatesManagerParams | false;
21
21
  }
22
22
  export declare class BaseTelegramClient implements ITelegramClient {
23
+ #private;
23
24
  readonly params: BaseTelegramClientOptions;
24
25
  readonly updates?: UpdatesManager;
25
26
  readonly log: Logger;
@@ -54,7 +55,9 @@ export declare class BaseTelegramClient implements ITelegramClient {
54
55
  */
55
56
  connect(): Promise<void>;
56
57
  get isConnected(): boolean;
57
- close(): Promise<void>;
58
+ disconnect(): Promise<void>;
59
+ destroy(): Promise<void>;
60
+ [Symbol.asyncDispose](): Promise<void>;
58
61
  notifyLoggedIn(auth: tl.auth.TypeAuthorization | tl.RawUser): Promise<tl.RawUser>;
59
62
  notifyLoggedOut(): Promise<void>;
60
63
  notifyChannelOpened(channelId: number, pts?: number): Promise<boolean>;
@@ -20,6 +20,7 @@ export interface BaseTelegramClientOptions extends MtClientOptions {
20
20
  updates?: UpdatesManagerParams | false;
21
21
  }
22
22
  export declare class BaseTelegramClient implements ITelegramClient {
23
+ #private;
23
24
  readonly params: BaseTelegramClientOptions;
24
25
  readonly updates?: UpdatesManager;
25
26
  readonly log: Logger;
@@ -54,7 +55,9 @@ export declare class BaseTelegramClient implements ITelegramClient {
54
55
  */
55
56
  connect(): Promise<void>;
56
57
  get isConnected(): boolean;
57
- close(): Promise<void>;
58
+ disconnect(): Promise<void>;
59
+ destroy(): Promise<void>;
60
+ [Symbol.asyncDispose](): Promise<void>;
58
61
  notifyLoggedIn(auth: tl.auth.TypeAuthorization | tl.RawUser): Promise<tl.RawUser>;
59
62
  notifyLoggedOut(): Promise<void>;
60
63
  notifyChannelOpened(channelId: number, pts?: number): Promise<boolean>;
package/highlevel/base.js CHANGED
@@ -91,6 +91,7 @@ class BaseTelegramClient {
91
91
  // used in a hot path, avoid extra function calls
92
92
  _connected = false;
93
93
  _connect = asyncResettable(async () => {
94
+ if (this.#destroyed) throw new Error("Client is destroyed");
94
95
  await this._prepare.run();
95
96
  await this.mt.connect();
96
97
  this._connected = true;
@@ -107,14 +108,24 @@ class BaseTelegramClient {
107
108
  get isConnected() {
108
109
  return this._connected;
109
110
  }
110
- async close() {
111
- this.timers.destroy();
111
+ async disconnect() {
112
112
  this._connected = false;
113
- await this.mt.close();
113
+ this.timers.destroy();
114
114
  this.updates?.stopLoop();
115
115
  await this.storage.close();
116
116
  this._prepare.reset();
117
117
  this._connect.reset();
118
+ await this.mt.disconnect();
119
+ }
120
+ #destroyed = false;
121
+ async destroy() {
122
+ if (this.#destroyed) return;
123
+ this.#destroyed = true;
124
+ await this.disconnect();
125
+ await this.mt.destroy();
126
+ }
127
+ [Symbol.asyncDispose]() {
128
+ return this.destroy();
118
129
  }
119
130
  async notifyLoggedIn(auth) {
120
131
  const user = this.mt.network.notifyLoggedIn(auth);
@@ -195,6 +206,7 @@ class BaseTelegramClient {
195
206
  if (data.self) {
196
207
  await this.storage.self.store(data.self);
197
208
  }
209
+ await this.mt.storage.provider.authKeys.deleteAll();
198
210
  await this.mt.storage.provider.authKeys.set(data.primaryDcs.main.id, data.authKey);
199
211
  await this.mt.storage.save();
200
212
  }
@@ -21,9 +21,10 @@ import { SendCopyGroupParams } from './methods/messages/send-copy-group.js';
21
21
  import { SendCopyParams } from './methods/messages/send-copy.js';
22
22
  import { QuoteParamsFrom } from './methods/messages/send-quote.js';
23
23
  import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
24
+ import { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/premium/get-resale-star-gifts.js';
24
25
  import { CanSendStoryResult } from './methods/stories/can-send-story.js';
25
26
  import { ITelegramStorageProvider } from './storage/provider.js';
26
- import { AllStories, ArrayPaginated, ArrayWithTotal, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputFileLike, InputInlineResult, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SavedStarGift, SentCode, StarGift, StarGiftUnique, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js';
27
+ import { AllStories, ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputFileLike, InputInlineResult, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SavedStarGift, SentCode, StarGift, StarGiftUnique, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js';
27
28
  import { ParsedUpdateHandlerParams } from './updates/parsed.js';
28
29
  import { RawUpdateInfo } from './updates/types.js';
29
30
  import { InputStringSessionData } from './utils/string-session.js';
@@ -3864,6 +3865,17 @@ export interface TelegramClient extends ITelegramClient {
3864
3865
  * @param peerId Peer ID to boost
3865
3866
  */
3866
3867
  applyBoost(peerId: InputPeerLike): Promise<void>;
3868
+ buyResaleGift(params: {
3869
+ /** Slug of the star gift to buy */
3870
+ slug: string;
3871
+ /** ID of the user to buy the gift for */
3872
+ recipient: InputPeerLike;
3873
+ /**
3874
+ * Whether to dispatch the new message event
3875
+ * to the client's update handler.
3876
+ */
3877
+ shouldDispatch?: true;
3878
+ }): Promise<Message | null>;
3867
3879
  /**
3868
3880
  * Check if the current user can apply boost to some channel
3869
3881
  *
@@ -3959,6 +3971,30 @@ export interface TelegramClient extends ITelegramClient {
3959
3971
  *
3960
3972
  */
3961
3973
  getMyBoostSlots(): Promise<BoostSlot[]>;
3974
+ /**
3975
+ * Get a list of star gifts up for resale
3976
+ */
3977
+ getResaleOptions(params: {
3978
+ /** ID of the gift to get resale options for */
3979
+ giftId: tl.Long;
3980
+ /**
3981
+ * Sorting attribute
3982
+ *
3983
+ * - `price`: Sort by price
3984
+ * - `num`: Sort by its unique number
3985
+ */
3986
+ sort?: 'price' | 'num';
3987
+ /**
3988
+ * Hash of the `attributes` field, as returned by the server in the first response
3989
+ */
3990
+ attributesHash?: Long;
3991
+ /** Attributes to filter for */
3992
+ attributes?: tl.TypeStarGiftAttributeId[] | InputStarGiftAttributeIds;
3993
+ /** Offset for pagination */
3994
+ offset?: string;
3995
+ /** Limit for pagination */
3996
+ limit?: number;
3997
+ }): Promise<ArrayPaginatedWithMeta<StarGiftUnique, string, ResaleStarGiftsMeta>>;
3962
3998
  /** Get one or more saved star gifts by their IDs */
3963
3999
  getSavedStarGiftsById(gifts: MaybeArray<InputStarGift>): Promise<SavedStarGift[]>;
3964
4000
  /**
@@ -4189,6 +4225,13 @@ export interface TelegramClient extends ITelegramClient {
4189
4225
  /** Business work intervals, raw intervals */
4190
4226
  intervals: tl.TypeBusinessWeeklyOpen[];
4191
4227
  })) | null): Promise<void>;
4228
+ /** Set resale price for an owned star gift */
4229
+ setResaleStarGiftPrice(params: {
4230
+ /** Star gift to update the price of */
4231
+ gift: InputStarGift;
4232
+ /** New price of the gift (in stars), or `null` to unlist */
4233
+ price: number | null;
4234
+ }): Promise<void>;
4192
4235
  /**
4193
4236
  * Transfer a unique star gift.
4194
4237
  *
@@ -4197,15 +4240,13 @@ export interface TelegramClient extends ITelegramClient {
4197
4240
  * > For GUI clients, you should refer to the method's source code and
4198
4241
  * > present the payment form to the user.
4199
4242
  *
4200
- * **Available**: 👤 users only
4201
- *
4202
4243
  * @returns Service message about the transferred gift, if one was generated.
4203
4244
  */
4204
4245
  transferStarGift(params: {
4205
4246
  /** Star gift to transfer */
4206
4247
  gift: InputStarGift;
4207
4248
  /** ID of the user to transfer the gift to */
4208
- recepient: InputPeerLike;
4249
+ recipient: InputPeerLike;
4209
4250
  /**
4210
4251
  * Whether to dispatch the new message event
4211
4252
  * to the client's update handler.
@@ -4220,8 +4261,6 @@ export interface TelegramClient extends ITelegramClient {
4220
4261
  * > For GUI clients, you should refer to the method's source code and
4221
4262
  * > present the payment form to the user.
4222
4263
  *
4223
- * **Available**: 👤 users only
4224
- *
4225
4264
  * @returns Service message about the upgraded gift, if one was generated.
4226
4265
  */
4227
4266
  upgradeStarGift(params: {
@@ -4998,7 +5037,7 @@ export interface TelegramClient extends ITelegramClient {
4998
5037
  * **Available**: ✅ both users and bots
4999
5038
  *
5000
5039
  * @param peerId The peer identifier that you want to extract the `InputPeer` from.
5001
- * @param [force=false] Whether to force re-fetch the peer from the server (only for usernames and phone numbers)
5040
+ * @param [force=false] Whether to force re-fetch the peer from the server
5002
5041
  */
5003
5042
  resolvePeer(peerId: InputPeerLike, force?: boolean): Promise<tl.TypeInputPeer>;
5004
5043
  /**
@@ -5013,6 +5052,16 @@ export interface TelegramClient extends ITelegramClient {
5013
5052
  *
5014
5053
  */
5015
5054
  resolveChannel(peerId: InputPeerLike, force?: boolean): Promise<tl.TypeInputChannel>;
5055
+ /**
5056
+ * Get the `InputPeer` by user's phone number.
5057
+ * Useful when an `InputPeer` is needed in Raw API.
5058
+ *
5059
+ * **Available**: ✅ both users and bots
5060
+ *
5061
+ * @param phone Phone number of the user
5062
+ * @param [force=false] Whether to force re-fetch the peer from the server
5063
+ */
5064
+ resolvePhoneNumber(phone: string, force?: boolean): Promise<tl.TypeInputPeer>;
5016
5065
  /**
5017
5066
  * Set an emoji status for the current user
5018
5067
  *
@@ -21,9 +21,10 @@ import { SendCopyGroupParams } from './methods/messages/send-copy-group.js';
21
21
  import { SendCopyParams } from './methods/messages/send-copy.js';
22
22
  import { QuoteParamsFrom } from './methods/messages/send-quote.js';
23
23
  import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
24
+ import { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/premium/get-resale-star-gifts.js';
24
25
  import { CanSendStoryResult } from './methods/stories/can-send-story.js';
25
26
  import { ITelegramStorageProvider } from './storage/provider.js';
26
- import { AllStories, ArrayPaginated, ArrayWithTotal, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputFileLike, InputInlineResult, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SavedStarGift, SentCode, StarGift, StarGiftUnique, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js';
27
+ import { AllStories, ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputFileLike, InputInlineResult, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SavedStarGift, SentCode, StarGift, StarGiftUnique, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js';
27
28
  import { ParsedUpdateHandlerParams } from './updates/parsed.js';
28
29
  import { RawUpdateInfo } from './updates/types.js';
29
30
  import { InputStringSessionData } from './utils/string-session.js';
@@ -3864,6 +3865,17 @@ export interface TelegramClient extends ITelegramClient {
3864
3865
  * @param peerId Peer ID to boost
3865
3866
  */
3866
3867
  applyBoost(peerId: InputPeerLike): Promise<void>;
3868
+ buyResaleGift(params: {
3869
+ /** Slug of the star gift to buy */
3870
+ slug: string;
3871
+ /** ID of the user to buy the gift for */
3872
+ recipient: InputPeerLike;
3873
+ /**
3874
+ * Whether to dispatch the new message event
3875
+ * to the client's update handler.
3876
+ */
3877
+ shouldDispatch?: true;
3878
+ }): Promise<Message | null>;
3867
3879
  /**
3868
3880
  * Check if the current user can apply boost to some channel
3869
3881
  *
@@ -3959,6 +3971,30 @@ export interface TelegramClient extends ITelegramClient {
3959
3971
  *
3960
3972
  */
3961
3973
  getMyBoostSlots(): Promise<BoostSlot[]>;
3974
+ /**
3975
+ * Get a list of star gifts up for resale
3976
+ */
3977
+ getResaleOptions(params: {
3978
+ /** ID of the gift to get resale options for */
3979
+ giftId: tl.Long;
3980
+ /**
3981
+ * Sorting attribute
3982
+ *
3983
+ * - `price`: Sort by price
3984
+ * - `num`: Sort by its unique number
3985
+ */
3986
+ sort?: 'price' | 'num';
3987
+ /**
3988
+ * Hash of the `attributes` field, as returned by the server in the first response
3989
+ */
3990
+ attributesHash?: Long;
3991
+ /** Attributes to filter for */
3992
+ attributes?: tl.TypeStarGiftAttributeId[] | InputStarGiftAttributeIds;
3993
+ /** Offset for pagination */
3994
+ offset?: string;
3995
+ /** Limit for pagination */
3996
+ limit?: number;
3997
+ }): Promise<ArrayPaginatedWithMeta<StarGiftUnique, string, ResaleStarGiftsMeta>>;
3962
3998
  /** Get one or more saved star gifts by their IDs */
3963
3999
  getSavedStarGiftsById(gifts: MaybeArray<InputStarGift>): Promise<SavedStarGift[]>;
3964
4000
  /**
@@ -4189,6 +4225,13 @@ export interface TelegramClient extends ITelegramClient {
4189
4225
  /** Business work intervals, raw intervals */
4190
4226
  intervals: tl.TypeBusinessWeeklyOpen[];
4191
4227
  })) | null): Promise<void>;
4228
+ /** Set resale price for an owned star gift */
4229
+ setResaleStarGiftPrice(params: {
4230
+ /** Star gift to update the price of */
4231
+ gift: InputStarGift;
4232
+ /** New price of the gift (in stars), or `null` to unlist */
4233
+ price: number | null;
4234
+ }): Promise<void>;
4192
4235
  /**
4193
4236
  * Transfer a unique star gift.
4194
4237
  *
@@ -4197,15 +4240,13 @@ export interface TelegramClient extends ITelegramClient {
4197
4240
  * > For GUI clients, you should refer to the method's source code and
4198
4241
  * > present the payment form to the user.
4199
4242
  *
4200
- * **Available**: 👤 users only
4201
- *
4202
4243
  * @returns Service message about the transferred gift, if one was generated.
4203
4244
  */
4204
4245
  transferStarGift(params: {
4205
4246
  /** Star gift to transfer */
4206
4247
  gift: InputStarGift;
4207
4248
  /** ID of the user to transfer the gift to */
4208
- recepient: InputPeerLike;
4249
+ recipient: InputPeerLike;
4209
4250
  /**
4210
4251
  * Whether to dispatch the new message event
4211
4252
  * to the client's update handler.
@@ -4220,8 +4261,6 @@ export interface TelegramClient extends ITelegramClient {
4220
4261
  * > For GUI clients, you should refer to the method's source code and
4221
4262
  * > present the payment form to the user.
4222
4263
  *
4223
- * **Available**: 👤 users only
4224
- *
4225
4264
  * @returns Service message about the upgraded gift, if one was generated.
4226
4265
  */
4227
4266
  upgradeStarGift(params: {
@@ -4998,7 +5037,7 @@ export interface TelegramClient extends ITelegramClient {
4998
5037
  * **Available**: ✅ both users and bots
4999
5038
  *
5000
5039
  * @param peerId The peer identifier that you want to extract the `InputPeer` from.
5001
- * @param [force=false] Whether to force re-fetch the peer from the server (only for usernames and phone numbers)
5040
+ * @param [force=false] Whether to force re-fetch the peer from the server
5002
5041
  */
5003
5042
  resolvePeer(peerId: InputPeerLike, force?: boolean): Promise<tl.TypeInputPeer>;
5004
5043
  /**
@@ -5013,6 +5052,16 @@ export interface TelegramClient extends ITelegramClient {
5013
5052
  *
5014
5053
  */
5015
5054
  resolveChannel(peerId: InputPeerLike, force?: boolean): Promise<tl.TypeInputChannel>;
5055
+ /**
5056
+ * Get the `InputPeer` by user's phone number.
5057
+ * Useful when an `InputPeer` is needed in Raw API.
5058
+ *
5059
+ * **Available**: ✅ both users and bots
5060
+ *
5061
+ * @param phone Phone number of the user
5062
+ * @param [force=false] Whether to force re-fetch the peer from the server
5063
+ */
5064
+ resolvePhoneNumber(phone: string, force?: boolean): Promise<tl.TypeInputPeer>;
5016
5065
  /**
5017
5066
  * Set an emoji status for the current user
5018
5067
  *
@@ -32,7 +32,8 @@ export interface ITelegramClient {
32
32
  readonly platform: ICorePlatform;
33
33
  prepare(): Promise<void>;
34
34
  connect(): Promise<void>;
35
- close(): Promise<void>;
35
+ disconnect(): Promise<void>;
36
+ destroy(): Promise<void>;
36
37
  notifyLoggedIn(auth: tl.auth.TypeAuthorization | tl.RawUser): Promise<tl.RawUser>;
37
38
  notifyLoggedOut(): Promise<void>;
38
39
  notifyChannelOpened(channelId: number, pts?: number): Promise<boolean>;
@@ -32,7 +32,8 @@ export interface ITelegramClient {
32
32
  readonly platform: ICorePlatform;
33
33
  prepare(): Promise<void>;
34
34
  connect(): Promise<void>;
35
- close(): Promise<void>;
35
+ disconnect(): Promise<void>;
36
+ destroy(): Promise<void>;
36
37
  notifyLoggedIn(auth: tl.auth.TypeAuthorization | tl.RawUser): Promise<tl.RawUser>;
37
38
  notifyLoggedOut(): Promise<void>;
38
39
  notifyChannelOpened(channelId: number, pts?: number): Promise<boolean>;
@@ -6,8 +6,9 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const Long = require("long");
9
+ const peerUtils = require("../../../utils/peer-utils.cjs");
9
10
  const filters = require("../../types/peers/chat-event/filters.cjs");
10
- const peerUtils = require("../../utils/peer-utils.cjs");
11
+ const peerUtils$1 = require("../../utils/peer-utils.cjs");
11
12
  const resolvePeerMany = require("../users/resolve-peer-many.cjs");
12
13
  const resolvePeer = require("../users/resolve-peer.cjs");
13
14
  const index = require("../../types/peers/chat-event/index.cjs");
@@ -15,7 +16,7 @@ const peersIndex = require("../../types/peers/peers-index.cjs");
15
16
  async function getChatEventLog(client, chatId, params) {
16
17
  const { maxId = Long.ZERO, minId = Long.ZERO, query = "", limit = 100, users, filters: filters$1 } = params ?? {};
17
18
  const channel = await resolvePeer.resolveChannel(client, chatId);
18
- const admins = users ? await resolvePeerMany.resolvePeerMany(client, users, peerUtils.toInputUser) : void 0;
19
+ const admins = users ? await resolvePeerMany.resolvePeerMany(client, users, peerUtils$1.toInputUser) : void 0;
19
20
  const { serverFilter, localFilter } = filters.normalizeChatEventFilters(filters$1);
20
21
  const res = await client.call({
21
22
  _: "channels.getAdminLog",
@@ -30,8 +31,9 @@ async function getChatEventLog(client, chatId, params) {
30
31
  if (!res.events.length) return [];
31
32
  const peers = peersIndex.PeersIndex.from(res);
32
33
  const results = [];
34
+ const chatIdNum = peerUtils.toggleChannelIdMark(peerUtils.getMarkedPeerId(channel));
33
35
  for (const evt of res.events) {
34
- const parsed = new index.ChatEvent(evt, peers);
36
+ const parsed = new index.ChatEvent(evt, peers, chatIdNum);
35
37
  if (localFilter && (!parsed.action || !localFilter[parsed.action.type])) {
36
38
  continue;
37
39
  }
@@ -1,4 +1,5 @@
1
1
  import Long from "long";
2
+ import { toggleChannelIdMark, getMarkedPeerId } from "../../../utils/peer-utils.js";
2
3
  import { normalizeChatEventFilters } from "../../types/peers/chat-event/filters.js";
3
4
  import { toInputUser } from "../../utils/peer-utils.js";
4
5
  import { resolvePeerMany } from "../users/resolve-peer-many.js";
@@ -23,8 +24,9 @@ async function getChatEventLog(client, chatId, params) {
23
24
  if (!res.events.length) return [];
24
25
  const peers = PeersIndex.from(res);
25
26
  const results = [];
27
+ const chatIdNum = toggleChannelIdMark(getMarkedPeerId(channel));
26
28
  for (const evt of res.events) {
27
- const parsed = new ChatEvent$2(evt, peers);
29
+ const parsed = new ChatEvent$2(evt, peers, chatIdNum);
28
30
  if (localFilter && (!parsed.action || !localFilter[parsed.action.type])) {
29
31
  continue;
30
32
  }
@@ -112,7 +112,7 @@ async function* downloadAsIterable(client, input, params) {
112
112
  _: isWeb ? "upload.getWebFile" : "upload.getFile",
113
113
  // eslint-disable-next-line
114
114
  location,
115
- offset: chunkSize * chunk,
115
+ offset: offset + chunkSize * chunk,
116
116
  limit: chunkSize
117
117
  },
118
118
  {
@@ -105,7 +105,7 @@ async function* downloadAsIterable(client, input, params) {
105
105
  _: isWeb ? "upload.getWebFile" : "upload.getFile",
106
106
  // eslint-disable-next-line
107
107
  location,
108
- offset: chunkSize * chunk,
108
+ offset: offset + chunkSize * chunk,
109
109
  limit: chunkSize
110
110
  },
111
111
  {