@mtcute/core 0.21.0 → 0.22.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 (153) hide show
  1. package/client.cjs +13 -8
  2. package/client.js +13 -8
  3. package/highlevel/base.cjs +3 -3
  4. package/highlevel/base.js +3 -3
  5. package/highlevel/client.d.cts +27 -49
  6. package/highlevel/client.d.ts +27 -49
  7. package/highlevel/methods/auth/sign-in-qr.cjs +4 -4
  8. package/highlevel/methods/files/download-iterable.cjs +25 -0
  9. package/highlevel/methods/files/download-iterable.js +25 -0
  10. package/highlevel/methods/files/upload-file.js +1 -1
  11. package/highlevel/methods/messages/forward-messages.cjs +2 -1
  12. package/highlevel/methods/messages/forward-messages.d.cts +6 -0
  13. package/highlevel/methods/messages/forward-messages.d.ts +6 -0
  14. package/highlevel/methods/messages/forward-messages.js +2 -1
  15. package/highlevel/methods/messages/get-web-page-preview.cjs +22 -0
  16. package/highlevel/methods/messages/get-web-page-preview.d.cts +9 -0
  17. package/highlevel/methods/messages/get-web-page-preview.d.ts +9 -0
  18. package/highlevel/methods/messages/get-web-page-preview.js +17 -0
  19. package/highlevel/methods/messages/send-common.d.cts +5 -0
  20. package/highlevel/methods/messages/send-common.d.ts +5 -0
  21. package/highlevel/methods/messages/send-media-group.cjs +2 -1
  22. package/highlevel/methods/messages/send-media-group.js +2 -1
  23. package/highlevel/methods/messages/send-media.cjs +2 -1
  24. package/highlevel/methods/messages/send-media.js +2 -1
  25. package/highlevel/methods/messages/send-paid-reaction.cjs +8 -2
  26. package/highlevel/methods/messages/send-paid-reaction.d.cts +8 -2
  27. package/highlevel/methods/messages/send-paid-reaction.d.ts +8 -2
  28. package/highlevel/methods/messages/send-paid-reaction.js +8 -2
  29. package/highlevel/methods/messages/send-text.cjs +2 -1
  30. package/highlevel/methods/messages/send-text.js +2 -1
  31. package/highlevel/methods/premium/pin-star-gift.cjs +24 -0
  32. package/highlevel/methods/premium/pin-star-gift.d.cts +13 -0
  33. package/highlevel/methods/premium/pin-star-gift.d.ts +13 -0
  34. package/highlevel/methods/premium/pin-star-gift.js +19 -0
  35. package/highlevel/methods/{premium/get-star-gifts.cjs → users/get-peer-settings.cjs} +10 -6
  36. package/highlevel/methods/users/get-peer-settings.d.cts +4 -0
  37. package/highlevel/methods/users/get-peer-settings.d.ts +4 -0
  38. package/highlevel/methods/users/get-peer-settings.js +14 -0
  39. package/highlevel/methods/users/resolve-peer.cjs +16 -31
  40. package/highlevel/methods/users/resolve-peer.js +7 -22
  41. package/highlevel/methods.d.cts +3 -2
  42. package/highlevel/methods.d.ts +3 -2
  43. package/highlevel/storage/repository/peers.d.cts +2 -3
  44. package/highlevel/storage/repository/peers.d.ts +2 -3
  45. package/highlevel/storage/service/peers.cjs +10 -4
  46. package/highlevel/storage/service/peers.d.cts +1 -0
  47. package/highlevel/storage/service/peers.d.ts +1 -0
  48. package/highlevel/storage/service/peers.js +10 -4
  49. package/highlevel/types/bots/keyboards/factories.cjs +4 -4
  50. package/highlevel/types/media/document.cjs +1 -1
  51. package/highlevel/types/media/document.js +1 -1
  52. package/highlevel/types/media/web-page.cjs +40 -3
  53. package/highlevel/types/media/web-page.d.cts +23 -1
  54. package/highlevel/types/media/web-page.d.ts +23 -1
  55. package/highlevel/types/media/web-page.js +41 -4
  56. package/highlevel/types/messages/message-media.cjs +1 -1
  57. package/highlevel/types/messages/message-media.d.cts +2 -2
  58. package/highlevel/types/messages/message-media.d.ts +2 -2
  59. package/highlevel/types/messages/message-media.js +2 -2
  60. package/highlevel/types/messages/message.cjs +4 -0
  61. package/highlevel/types/messages/message.d.cts +2 -0
  62. package/highlevel/types/messages/message.d.ts +2 -0
  63. package/highlevel/types/messages/message.js +4 -0
  64. package/highlevel/types/peers/chat-event/actions.cjs +5 -0
  65. package/highlevel/types/peers/chat-event/actions.js +5 -0
  66. package/highlevel/types/peers/chat.cjs +4 -0
  67. package/highlevel/types/peers/chat.d.cts +2 -0
  68. package/highlevel/types/peers/chat.d.ts +2 -0
  69. package/highlevel/types/peers/chat.js +4 -0
  70. package/highlevel/types/peers/full-chat.cjs +4 -0
  71. package/highlevel/types/peers/full-chat.d.cts +2 -0
  72. package/highlevel/types/peers/full-chat.d.ts +2 -0
  73. package/highlevel/types/peers/full-chat.js +4 -0
  74. package/highlevel/types/peers/index.d.cts +1 -0
  75. package/highlevel/types/peers/index.d.ts +1 -0
  76. package/highlevel/types/peers/peer-settings.cjs +101 -0
  77. package/highlevel/types/peers/peer-settings.d.cts +84 -0
  78. package/highlevel/types/peers/peer-settings.d.ts +84 -0
  79. package/highlevel/types/peers/peer-settings.js +96 -0
  80. package/highlevel/types/peers/user.cjs +4 -0
  81. package/highlevel/types/peers/user.d.cts +2 -0
  82. package/highlevel/types/peers/user.d.ts +2 -0
  83. package/highlevel/types/peers/user.js +4 -0
  84. package/highlevel/types/premium/saved-star-gift.cjs +4 -1
  85. package/highlevel/types/premium/saved-star-gift.d.cts +2 -3
  86. package/highlevel/types/premium/saved-star-gift.d.ts +2 -3
  87. package/highlevel/types/premium/saved-star-gift.js +5 -2
  88. package/highlevel/types/premium/stars-gift-unique.cjs +4 -0
  89. package/highlevel/types/premium/stars-gift-unique.d.cts +2 -0
  90. package/highlevel/types/premium/stars-gift-unique.d.ts +2 -0
  91. package/highlevel/types/premium/stars-gift-unique.js +4 -0
  92. package/highlevel/types/premium/stars-transaction.cjs +14 -0
  93. package/highlevel/types/premium/stars-transaction.d.cts +14 -0
  94. package/highlevel/types/premium/stars-transaction.d.ts +14 -0
  95. package/highlevel/types/premium/stars-transaction.js +14 -0
  96. package/highlevel/types/stories/story-viewer.cjs +1 -1
  97. package/highlevel/types/stories/story-viewer.js +1 -1
  98. package/highlevel/types/updates/history-read-update.cjs +1 -0
  99. package/highlevel/types/updates/history-read-update.js +1 -0
  100. package/highlevel/updates/manager.js +2 -2
  101. package/highlevel/utils/file-utils.js +1 -1
  102. package/highlevel/utils/inline-utils.cjs +5 -5
  103. package/highlevel/utils/inline-utils.js +1 -1
  104. package/highlevel/worker/storage.cjs +2 -0
  105. package/highlevel/worker/storage.d.cts +1 -0
  106. package/highlevel/worker/storage.d.ts +1 -0
  107. package/highlevel/worker/storage.js +2 -0
  108. package/index.cjs +3 -1
  109. package/index.js +5 -3
  110. package/methods.cjs +6 -4
  111. package/methods.js +6 -4
  112. package/network/authorization.js +2 -2
  113. package/network/network-manager.cjs +1 -1
  114. package/network/network-manager.js +1 -1
  115. package/network/persistent-connection.cjs +6 -4
  116. package/network/persistent-connection.js +6 -4
  117. package/network/session-connection.cjs +14 -7
  118. package/network/session-connection.d.cts +1 -1
  119. package/network/session-connection.d.ts +1 -1
  120. package/network/session-connection.js +15 -8
  121. package/package.json +4 -4
  122. package/storage/memory/repository/peers.cjs +2 -2
  123. package/storage/memory/repository/peers.d.cts +1 -1
  124. package/storage/memory/repository/peers.d.ts +1 -1
  125. package/storage/memory/repository/peers.js +2 -2
  126. package/storage/sqlite/repository/peers.cjs +3 -5
  127. package/storage/sqlite/repository/peers.d.cts +1 -2
  128. package/storage/sqlite/repository/peers.d.ts +1 -2
  129. package/storage/sqlite/repository/peers.js +3 -5
  130. package/utils/binary/asn1-parser.js +1 -1
  131. package/utils/binary/compat.cjs +150 -0
  132. package/utils/binary/compat.d.cts +13 -0
  133. package/utils/binary/compat.d.ts +13 -0
  134. package/utils/binary/compat.js +145 -0
  135. package/utils/binary/compat.test.d.cts +1 -0
  136. package/utils/binary/compat.test.d.ts +1 -0
  137. package/utils/binary/serialization.cjs +59 -0
  138. package/utils/binary/serialization.d.cts +10 -0
  139. package/utils/binary/serialization.d.ts +10 -0
  140. package/utils/binary/serialization.js +54 -0
  141. package/utils/index.d.cts +2 -0
  142. package/utils/index.d.ts +2 -0
  143. package/utils/long-utils.js +1 -1
  144. package/utils/peer-utils.js +1 -1
  145. package/utils.cjs +8 -0
  146. package/utils.js +8 -0
  147. package/highlevel/methods/premium/get-star-gifts.d.cts +0 -23
  148. package/highlevel/methods/premium/get-star-gifts.d.ts +0 -23
  149. package/highlevel/methods/premium/get-star-gifts.js +0 -10
  150. package/highlevel/methods/premium/iter-star-gifts.cjs +0 -29
  151. package/highlevel/methods/premium/iter-star-gifts.d.cts +0 -26
  152. package/highlevel/methods/premium/iter-star-gifts.d.ts +0 -26
  153. package/highlevel/methods/premium/iter-star-gifts.js +0 -24
package/client.cjs CHANGED
@@ -150,6 +150,7 @@ const getMessages = require("./highlevel/methods/messages/get-messages.cjs");
150
150
  const getReactionUsers = require("./highlevel/methods/messages/get-reaction-users.cjs");
151
151
  const getReplyTo = require("./highlevel/methods/messages/get-reply-to.cjs");
152
152
  const getScheduledMessages = require("./highlevel/methods/messages/get-scheduled-messages.cjs");
153
+ const getWebPagePreview = require("./highlevel/methods/messages/get-web-page-preview.cjs");
153
154
  const iterHistory = require("./highlevel/methods/messages/iter-history.cjs");
154
155
  const iterReactionUsers = require("./highlevel/methods/messages/iter-reaction-users.cjs");
155
156
  const iterSearchGlobal = require("./highlevel/methods/messages/iter-search-global.cjs");
@@ -202,13 +203,12 @@ const getSavedStarGiftsById = require("./highlevel/methods/premium/get-saved-sta
202
203
  const getSavedStarGifts = require("./highlevel/methods/premium/get-saved-star-gifts.cjs");
203
204
  const getStarGiftOptions = require("./highlevel/methods/premium/get-star-gift-options.cjs");
204
205
  const getStarGiftWithdrawalUrl = require("./highlevel/methods/premium/get-star-gift-withdrawal-url.cjs");
205
- const getStarGifts = require("./highlevel/methods/premium/get-star-gifts.cjs");
206
206
  const getStarsTransactions = require("./highlevel/methods/premium/get-stars-transactions.cjs");
207
207
  const getUniqueStarGift = require("./highlevel/methods/premium/get-unique-star-gift.cjs");
208
208
  const iterBoosters = require("./highlevel/methods/premium/iter-boosters.cjs");
209
209
  const iterSavedStarGifts = require("./highlevel/methods/premium/iter-saved-star-gifts.cjs");
210
- const iterStarGifts = require("./highlevel/methods/premium/iter-star-gifts.cjs");
211
210
  const iterStarsTransactions = require("./highlevel/methods/premium/iter-stars-transactions.cjs");
211
+ const pinStarGift = require("./highlevel/methods/premium/pin-star-gift.cjs");
212
212
  const sendStarGift = require("./highlevel/methods/premium/send-star-gift.cjs");
213
213
  const setBusinessIntro = require("./highlevel/methods/premium/set-business-intro.cjs");
214
214
  const setBusinessWorkHours = require("./highlevel/methods/premium/set-business-work-hours.cjs");
@@ -252,6 +252,7 @@ const getCommonChats = require("./highlevel/methods/users/get-common-chats.cjs")
252
252
  const getGlobalTtl = require("./highlevel/methods/users/get-global-ttl.cjs");
253
253
  const getMe = require("./highlevel/methods/users/get-me.cjs");
254
254
  const getMyUsername = require("./highlevel/methods/users/get-my-username.cjs");
255
+ const getPeerSettings = require("./highlevel/methods/users/get-peer-settings.cjs");
255
256
  const getProfilePhoto = require("./highlevel/methods/users/get-profile-photo.cjs");
256
257
  const getProfilePhotos = require("./highlevel/methods/users/get-profile-photos.cjs");
257
258
  const getUsers = require("./highlevel/methods/users/get-users.cjs");
@@ -315,6 +316,7 @@ class TelegramClient {
315
316
  }
316
317
  Object.defineProperty(this, "log", { value: this._client.log });
317
318
  Object.defineProperty(this, "storage", { value: this._client.storage });
319
+ Object.defineProperty(this, "timers", { value: this._client.timers });
318
320
  Object.defineProperty(this, "stopSignal", { value: this._client.stopSignal });
319
321
  Object.defineProperty(this, "appConfig", { value: this._client.appConfig });
320
322
  Object.defineProperty(this, "onServerUpdate", { value: this._client.onServerUpdate });
@@ -881,6 +883,9 @@ TelegramClient.prototype.getReplyTo = function(...args) {
881
883
  TelegramClient.prototype.getScheduledMessages = function(...args) {
882
884
  return getScheduledMessages.getScheduledMessages(this._client, ...args);
883
885
  };
886
+ TelegramClient.prototype.getWebPagePreview = function(...args) {
887
+ return getWebPagePreview.getWebPagePreview(this._client, ...args);
888
+ };
884
889
  TelegramClient.prototype.iterHistory = function(...args) {
885
890
  return iterHistory.iterHistory(this._client, ...args);
886
891
  };
@@ -1070,9 +1075,6 @@ TelegramClient.prototype.getStarGiftOptions = function(...args) {
1070
1075
  TelegramClient.prototype.getStarGiftWithdrawalUrl = function(...args) {
1071
1076
  return getStarGiftWithdrawalUrl.getStarGiftWithdrawalUrl(this._client, ...args);
1072
1077
  };
1073
- TelegramClient.prototype.getStarGifts = function(...args) {
1074
- return getStarGifts.getStarGifts(this._client, ...args);
1075
- };
1076
1078
  TelegramClient.prototype.getStarsTransactions = function(...args) {
1077
1079
  return getStarsTransactions.getStarsTransactions(this._client, ...args);
1078
1080
  };
@@ -1085,12 +1087,12 @@ TelegramClient.prototype.iterBoosters = function(...args) {
1085
1087
  TelegramClient.prototype.iterSavedStarGifts = function(...args) {
1086
1088
  return iterSavedStarGifts.iterSavedStarGifts(this._client, ...args);
1087
1089
  };
1088
- TelegramClient.prototype.iterStarGifts = function(...args) {
1089
- return iterStarGifts.iterStarGifts(this._client, ...args);
1090
- };
1091
1090
  TelegramClient.prototype.iterStarsTransactions = function(...args) {
1092
1091
  return iterStarsTransactions.iterStarsTransactions(this._client, ...args);
1093
1092
  };
1093
+ TelegramClient.prototype.togglePinnedStarGifts = function(...args) {
1094
+ return pinStarGift.togglePinnedStarGifts(this._client, ...args);
1095
+ };
1094
1096
  TelegramClient.prototype.sendStarGift = function(...args) {
1095
1097
  return sendStarGift.sendStarGift(this._client, ...args);
1096
1098
  };
@@ -1226,6 +1228,9 @@ TelegramClient.prototype.getMe = function(...args) {
1226
1228
  TelegramClient.prototype.getMyUsername = function(...args) {
1227
1229
  return getMyUsername.getMyUsername(this._client, ...args);
1228
1230
  };
1231
+ TelegramClient.prototype.getPeerSettings = function(...args) {
1232
+ return getPeerSettings.getPeerSettings(this._client, ...args);
1233
+ };
1229
1234
  TelegramClient.prototype.getProfilePhoto = function(...args) {
1230
1235
  return getProfilePhoto.getProfilePhoto(this._client, ...args);
1231
1236
  };
package/client.js CHANGED
@@ -143,6 +143,7 @@ import { getMessages } from "./highlevel/methods/messages/get-messages.js";
143
143
  import { getReactionUsers } from "./highlevel/methods/messages/get-reaction-users.js";
144
144
  import { getReplyTo } from "./highlevel/methods/messages/get-reply-to.js";
145
145
  import { getScheduledMessages } from "./highlevel/methods/messages/get-scheduled-messages.js";
146
+ import { getWebPagePreview } from "./highlevel/methods/messages/get-web-page-preview.js";
146
147
  import { iterHistory } from "./highlevel/methods/messages/iter-history.js";
147
148
  import { iterReactionUsers } from "./highlevel/methods/messages/iter-reaction-users.js";
148
149
  import { iterSearchGlobal } from "./highlevel/methods/messages/iter-search-global.js";
@@ -195,13 +196,12 @@ import { getSavedStarGiftsById } from "./highlevel/methods/premium/get-saved-sta
195
196
  import { getSavedStarGifts } from "./highlevel/methods/premium/get-saved-star-gifts.js";
196
197
  import { getStarGiftOptions } from "./highlevel/methods/premium/get-star-gift-options.js";
197
198
  import { getStarGiftWithdrawalUrl } from "./highlevel/methods/premium/get-star-gift-withdrawal-url.js";
198
- import { getStarGifts } from "./highlevel/methods/premium/get-star-gifts.js";
199
199
  import { getStarsTransactions } from "./highlevel/methods/premium/get-stars-transactions.js";
200
200
  import { getUniqueStarGift } from "./highlevel/methods/premium/get-unique-star-gift.js";
201
201
  import { iterBoosters } from "./highlevel/methods/premium/iter-boosters.js";
202
202
  import { iterSavedStarGifts } from "./highlevel/methods/premium/iter-saved-star-gifts.js";
203
- import { iterStarGifts } from "./highlevel/methods/premium/iter-star-gifts.js";
204
203
  import { iterStarsTransactions } from "./highlevel/methods/premium/iter-stars-transactions.js";
204
+ import { togglePinnedStarGifts } from "./highlevel/methods/premium/pin-star-gift.js";
205
205
  import { sendStarGift } from "./highlevel/methods/premium/send-star-gift.js";
206
206
  import { setBusinessIntro } from "./highlevel/methods/premium/set-business-intro.js";
207
207
  import { setBusinessWorkHours } from "./highlevel/methods/premium/set-business-work-hours.js";
@@ -245,6 +245,7 @@ import { getCommonChats } from "./highlevel/methods/users/get-common-chats.js";
245
245
  import { getGlobalTtl } from "./highlevel/methods/users/get-global-ttl.js";
246
246
  import { getMe } from "./highlevel/methods/users/get-me.js";
247
247
  import { getMyUsername } from "./highlevel/methods/users/get-my-username.js";
248
+ import { getPeerSettings } from "./highlevel/methods/users/get-peer-settings.js";
248
249
  import { getProfilePhoto } from "./highlevel/methods/users/get-profile-photo.js";
249
250
  import { getProfilePhotos } from "./highlevel/methods/users/get-profile-photos.js";
250
251
  import { getUsers } from "./highlevel/methods/users/get-users.js";
@@ -308,6 +309,7 @@ class TelegramClient {
308
309
  }
309
310
  Object.defineProperty(this, "log", { value: this._client.log });
310
311
  Object.defineProperty(this, "storage", { value: this._client.storage });
312
+ Object.defineProperty(this, "timers", { value: this._client.timers });
311
313
  Object.defineProperty(this, "stopSignal", { value: this._client.stopSignal });
312
314
  Object.defineProperty(this, "appConfig", { value: this._client.appConfig });
313
315
  Object.defineProperty(this, "onServerUpdate", { value: this._client.onServerUpdate });
@@ -874,6 +876,9 @@ TelegramClient.prototype.getReplyTo = function(...args) {
874
876
  TelegramClient.prototype.getScheduledMessages = function(...args) {
875
877
  return getScheduledMessages(this._client, ...args);
876
878
  };
879
+ TelegramClient.prototype.getWebPagePreview = function(...args) {
880
+ return getWebPagePreview(this._client, ...args);
881
+ };
877
882
  TelegramClient.prototype.iterHistory = function(...args) {
878
883
  return iterHistory(this._client, ...args);
879
884
  };
@@ -1063,9 +1068,6 @@ TelegramClient.prototype.getStarGiftOptions = function(...args) {
1063
1068
  TelegramClient.prototype.getStarGiftWithdrawalUrl = function(...args) {
1064
1069
  return getStarGiftWithdrawalUrl(this._client, ...args);
1065
1070
  };
1066
- TelegramClient.prototype.getStarGifts = function(...args) {
1067
- return getStarGifts(this._client, ...args);
1068
- };
1069
1071
  TelegramClient.prototype.getStarsTransactions = function(...args) {
1070
1072
  return getStarsTransactions(this._client, ...args);
1071
1073
  };
@@ -1078,12 +1080,12 @@ TelegramClient.prototype.iterBoosters = function(...args) {
1078
1080
  TelegramClient.prototype.iterSavedStarGifts = function(...args) {
1079
1081
  return iterSavedStarGifts(this._client, ...args);
1080
1082
  };
1081
- TelegramClient.prototype.iterStarGifts = function(...args) {
1082
- return iterStarGifts(this._client, ...args);
1083
- };
1084
1083
  TelegramClient.prototype.iterStarsTransactions = function(...args) {
1085
1084
  return iterStarsTransactions(this._client, ...args);
1086
1085
  };
1086
+ TelegramClient.prototype.togglePinnedStarGifts = function(...args) {
1087
+ return togglePinnedStarGifts(this._client, ...args);
1088
+ };
1087
1089
  TelegramClient.prototype.sendStarGift = function(...args) {
1088
1090
  return sendStarGift(this._client, ...args);
1089
1091
  };
@@ -1219,6 +1221,9 @@ TelegramClient.prototype.getMe = function(...args) {
1219
1221
  TelegramClient.prototype.getMyUsername = function(...args) {
1220
1222
  return getMyUsername(this._client, ...args);
1221
1223
  };
1224
+ TelegramClient.prototype.getPeerSettings = function(...args) {
1225
+ return getPeerSettings(this._client, ...args);
1226
+ };
1222
1227
  TelegramClient.prototype.getProfilePhoto = function(...args) {
1223
1228
  return getProfilePhoto(this._client, ...args);
1224
1229
  };
@@ -134,9 +134,9 @@ class BaseTelegramClient {
134
134
  this.log.prefix = "[USER n/a] ";
135
135
  await this.storage.self.store(null);
136
136
  const primaryDc = this.mt.network.getPrimaryDcId();
137
- for (const dc of this.mt.network.config.getCached()?.dcOptions ?? []) {
138
- if (dc.id === primaryDc) continue;
139
- await this.mt.storage.provider.authKeys.deleteByDc(dc.id);
137
+ for (const dcId of [1, 2, 3, 4, 5]) {
138
+ if (dcId === primaryDc) continue;
139
+ await this.mt.storage.provider.authKeys.deleteByDc(dcId);
140
140
  }
141
141
  }
142
142
  async notifyChannelOpened(channelId, pts) {
package/highlevel/base.js CHANGED
@@ -127,9 +127,9 @@ class BaseTelegramClient {
127
127
  this.log.prefix = "[USER n/a] ";
128
128
  await this.storage.self.store(null);
129
129
  const primaryDc = this.mt.network.getPrimaryDcId();
130
- for (const dc of this.mt.network.config.getCached()?.dcOptions ?? []) {
131
- if (dc.id === primaryDc) continue;
132
- await this.mt.storage.provider.authKeys.deleteByDc(dc.id);
130
+ for (const dcId of [1, 2, 3, 4, 5]) {
131
+ if (dcId === primaryDc) continue;
132
+ await this.mt.storage.provider.authKeys.deleteByDc(dcId);
133
133
  }
134
134
  }
135
135
  async notifyChannelOpened(channelId, pts) {
@@ -23,7 +23,7 @@ import { QuoteParamsFrom } from './methods/messages/send-quote.js';
23
23
  import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
24
24
  import { CanSendStoryResult } from './methods/stories/can-send-story.js';
25
25
  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, 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, UserStarGift, UserStatusUpdate, UserTypingUpdate, WebviewResult } from './types/index.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
27
  import { ParsedUpdateHandlerParams } from './updates/parsed.js';
28
28
  import { RawUpdateInfo } from './updates/types.js';
29
29
  import { InputStringSessionData } from './utils/string-session.js';
@@ -36,7 +36,6 @@ import { sendMediaGroup } from './methods/messages/send-media-group.js';
36
36
  import { sendMedia } from './methods/messages/send-media.js';
37
37
  import { sendText } from './methods/messages/send-text.js';
38
38
  import { getBoosts } from './methods/premium/get-boosts.js';
39
- import { getStarGifts } from './methods/premium/get-star-gifts.js';
40
39
  import { getStarsTransactions } from './methods/premium/get-stars-transactions.js';
41
40
  import { getAllStories } from './methods/stories/get-all-stories.js';
42
41
  import { getProfileStories } from './methods/stories/get-profile-stories.js';
@@ -3026,6 +3025,14 @@ export interface TelegramClient extends ITelegramClient {
3026
3025
  * @param messageIds Scheduled messages IDs
3027
3026
  */
3028
3027
  getScheduledMessages(chatId: InputPeerLike, messageIds: MaybeArray<number>): Promise<(Message | null)[]>;
3028
+ /**
3029
+ * Get a preview of a web page contained in the message
3030
+ *
3031
+ * **Available**: 👤 users only
3032
+ *
3033
+ * @param text Text of the message, or simply the link for which the preview should be retrieved
3034
+ */
3035
+ getWebPagePreview(text: InputText): Promise<WebPageMedia | null>;
3029
3036
  /**
3030
3037
  * Iterate over chat history. Wrapper over {@link getHistory}
3031
3038
  *
@@ -3521,8 +3528,14 @@ export interface TelegramClient extends ITelegramClient {
3521
3528
  * The message is normally available for users, but may not be available for bots in PMs.
3522
3529
  */
3523
3530
  sendPaidReaction(params: InputMessageId & {
3524
- /** Whether to send the reaction anonymously */
3531
+ /**
3532
+ * Whether to send the reaction anonymously
3533
+ */
3525
3534
  anonymous?: boolean;
3535
+ /**
3536
+ * Peer as which to send the reaction, mutually exclusive with `anonymous`
3537
+ */
3538
+ asPeer?: InputPeerLike;
3526
3539
  /**
3527
3540
  * Number of reactions to send
3528
3541
  *
@@ -3981,27 +3994,6 @@ export interface TelegramClient extends ITelegramClient {
3981
3994
  /** 2FA password */
3982
3995
  password: string;
3983
3996
  }): Promise<string>;
3984
- /**
3985
- * Get a list of gifts sent to a user.
3986
- *
3987
- * **Available**: ✅ both users and bots
3988
- *
3989
- * @param userId User whose gifts to fetch
3990
- * @deprecated Use {@link getSavedStarGifts} instead
3991
- * @returns Gifts sent to the user
3992
- */
3993
- getStarGifts(userId: InputPeerLike, params?: {
3994
- /**
3995
- * Offset for pagination.
3996
- */
3997
- offset?: string;
3998
- /**
3999
- * Maximum number of gifts to fetch.
4000
- *
4001
- * @default 100
4002
- */
4003
- limit?: number;
4004
- }): Promise<ArrayPaginated<SavedStarGift, string>>;
4005
3997
  /**
4006
3998
  * Get Telegram Stars transactions for a given peer.
4007
3999
  *
@@ -4085,31 +4077,6 @@ export interface TelegramClient extends ITelegramClient {
4085
4077
  /** Limit for pagination */
4086
4078
  limit?: number;
4087
4079
  }): AsyncIterableIterator<SavedStarGift>;
4088
- /**
4089
- * Iterate over gifts sent to a given user.
4090
- *
4091
- * Wrapper over {@link getStarGifts}
4092
- *
4093
- * **Available**: 👤 users only
4094
- *
4095
- * @param peerId Peer ID
4096
- * @param params Additional parameters
4097
- */
4098
- iterStarGifts(peerId: InputPeerLike, params?: Parameters<typeof getStarGifts>[2] & {
4099
- /**
4100
- * Total number of gifts to fetch
4101
- *
4102
- * @default Infinity, i.e. fetch all gifts
4103
- */
4104
- limit?: number;
4105
- /**
4106
- * Number of gifts to fetch per request
4107
- * Usually you don't need to change this
4108
- *
4109
- * @default 100
4110
- */
4111
- chunkSize?: number;
4112
- }): AsyncIterableIterator<UserStarGift>;
4113
4080
  /**
4114
4081
  * Iterate over Telegram Stars transactions for a given peer.
4115
4082
  *
@@ -4138,6 +4105,15 @@ export interface TelegramClient extends ITelegramClient {
4138
4105
  */
4139
4106
  chunkSize?: number;
4140
4107
  }): AsyncIterableIterator<StarsTransaction>;
4108
+ /**
4109
+ * Toggles whether one or more star gift is pinned to the top of the list
4110
+ */
4111
+ togglePinnedStarGifts(params: {
4112
+ /** One or more gifts to pin */
4113
+ gifts: MaybeArray<InputStarGift>;
4114
+ /** Peer where the gift is sent */
4115
+ peer: InputPeerLike;
4116
+ }): Promise<void>;
4141
4117
  /**
4142
4118
  * Send a star gift to a user.
4143
4119
  *
@@ -4901,6 +4877,8 @@ export interface TelegramClient extends ITelegramClient {
4901
4877
  *
4902
4878
  */
4903
4879
  getMyUsername(): Promise<string | null>;
4880
+ /** Get {@link PeerSettings} for a peer */
4881
+ getPeerSettings(peerId: InputPeerLike): Promise<PeerSettings>;
4904
4882
  /**
4905
4883
  * Get a single profile picture of a user by its ID
4906
4884
  *
@@ -23,7 +23,7 @@ import { QuoteParamsFrom } from './methods/messages/send-quote.js';
23
23
  import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
24
24
  import { CanSendStoryResult } from './methods/stories/can-send-story.js';
25
25
  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, 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, UserStarGift, UserStatusUpdate, UserTypingUpdate, WebviewResult } from './types/index.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
27
  import { ParsedUpdateHandlerParams } from './updates/parsed.js';
28
28
  import { RawUpdateInfo } from './updates/types.js';
29
29
  import { InputStringSessionData } from './utils/string-session.js';
@@ -36,7 +36,6 @@ import { sendMediaGroup } from './methods/messages/send-media-group.js';
36
36
  import { sendMedia } from './methods/messages/send-media.js';
37
37
  import { sendText } from './methods/messages/send-text.js';
38
38
  import { getBoosts } from './methods/premium/get-boosts.js';
39
- import { getStarGifts } from './methods/premium/get-star-gifts.js';
40
39
  import { getStarsTransactions } from './methods/premium/get-stars-transactions.js';
41
40
  import { getAllStories } from './methods/stories/get-all-stories.js';
42
41
  import { getProfileStories } from './methods/stories/get-profile-stories.js';
@@ -3026,6 +3025,14 @@ export interface TelegramClient extends ITelegramClient {
3026
3025
  * @param messageIds Scheduled messages IDs
3027
3026
  */
3028
3027
  getScheduledMessages(chatId: InputPeerLike, messageIds: MaybeArray<number>): Promise<(Message | null)[]>;
3028
+ /**
3029
+ * Get a preview of a web page contained in the message
3030
+ *
3031
+ * **Available**: 👤 users only
3032
+ *
3033
+ * @param text Text of the message, or simply the link for which the preview should be retrieved
3034
+ */
3035
+ getWebPagePreview(text: InputText): Promise<WebPageMedia | null>;
3029
3036
  /**
3030
3037
  * Iterate over chat history. Wrapper over {@link getHistory}
3031
3038
  *
@@ -3521,8 +3528,14 @@ export interface TelegramClient extends ITelegramClient {
3521
3528
  * The message is normally available for users, but may not be available for bots in PMs.
3522
3529
  */
3523
3530
  sendPaidReaction(params: InputMessageId & {
3524
- /** Whether to send the reaction anonymously */
3531
+ /**
3532
+ * Whether to send the reaction anonymously
3533
+ */
3525
3534
  anonymous?: boolean;
3535
+ /**
3536
+ * Peer as which to send the reaction, mutually exclusive with `anonymous`
3537
+ */
3538
+ asPeer?: InputPeerLike;
3526
3539
  /**
3527
3540
  * Number of reactions to send
3528
3541
  *
@@ -3981,27 +3994,6 @@ export interface TelegramClient extends ITelegramClient {
3981
3994
  /** 2FA password */
3982
3995
  password: string;
3983
3996
  }): Promise<string>;
3984
- /**
3985
- * Get a list of gifts sent to a user.
3986
- *
3987
- * **Available**: ✅ both users and bots
3988
- *
3989
- * @param userId User whose gifts to fetch
3990
- * @deprecated Use {@link getSavedStarGifts} instead
3991
- * @returns Gifts sent to the user
3992
- */
3993
- getStarGifts(userId: InputPeerLike, params?: {
3994
- /**
3995
- * Offset for pagination.
3996
- */
3997
- offset?: string;
3998
- /**
3999
- * Maximum number of gifts to fetch.
4000
- *
4001
- * @default 100
4002
- */
4003
- limit?: number;
4004
- }): Promise<ArrayPaginated<SavedStarGift, string>>;
4005
3997
  /**
4006
3998
  * Get Telegram Stars transactions for a given peer.
4007
3999
  *
@@ -4085,31 +4077,6 @@ export interface TelegramClient extends ITelegramClient {
4085
4077
  /** Limit for pagination */
4086
4078
  limit?: number;
4087
4079
  }): AsyncIterableIterator<SavedStarGift>;
4088
- /**
4089
- * Iterate over gifts sent to a given user.
4090
- *
4091
- * Wrapper over {@link getStarGifts}
4092
- *
4093
- * **Available**: 👤 users only
4094
- *
4095
- * @param peerId Peer ID
4096
- * @param params Additional parameters
4097
- */
4098
- iterStarGifts(peerId: InputPeerLike, params?: Parameters<typeof getStarGifts>[2] & {
4099
- /**
4100
- * Total number of gifts to fetch
4101
- *
4102
- * @default Infinity, i.e. fetch all gifts
4103
- */
4104
- limit?: number;
4105
- /**
4106
- * Number of gifts to fetch per request
4107
- * Usually you don't need to change this
4108
- *
4109
- * @default 100
4110
- */
4111
- chunkSize?: number;
4112
- }): AsyncIterableIterator<UserStarGift>;
4113
4080
  /**
4114
4081
  * Iterate over Telegram Stars transactions for a given peer.
4115
4082
  *
@@ -4138,6 +4105,15 @@ export interface TelegramClient extends ITelegramClient {
4138
4105
  */
4139
4106
  chunkSize?: number;
4140
4107
  }): AsyncIterableIterator<StarsTransaction>;
4108
+ /**
4109
+ * Toggles whether one or more star gift is pinned to the top of the list
4110
+ */
4111
+ togglePinnedStarGifts(params: {
4112
+ /** One or more gifts to pin */
4113
+ gifts: MaybeArray<InputStarGift>;
4114
+ /** Peer where the gift is sent */
4115
+ peer: InputPeerLike;
4116
+ }): Promise<void>;
4141
4117
  /**
4142
4118
  * Send a star gift to a user.
4143
4119
  *
@@ -4901,6 +4877,8 @@ export interface TelegramClient extends ITelegramClient {
4901
4877
  *
4902
4878
  */
4903
4879
  getMyUsername(): Promise<string | null>;
4880
+ /** Get {@link PeerSettings} for a peer */
4881
+ getPeerSettings(peerId: InputPeerLike): Promise<PeerSettings>;
4904
4882
  /**
4905
4883
  * Get a single profile picture of a user by its ID
4906
4884
  *
@@ -7,9 +7,9 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const utils = require("@fuman/utils");
9
9
  const tl = require("@mtcute/tl");
10
- const miscUtils$1 = require("../../../utils/misc-utils.cjs");
10
+ const miscUtils = require("../../../utils/misc-utils.cjs");
11
11
  const typeAssertions = require("../../../utils/type-assertions.cjs");
12
- const miscUtils = require("../../utils/misc-utils.cjs");
12
+ const miscUtils$1 = require("../../utils/misc-utils.cjs");
13
13
  const checkPassword = require("./check-password.cjs");
14
14
  const user = require("../../types/peers/user.cjs");
15
15
  async function signInQr(client, params) {
@@ -30,7 +30,7 @@ async function signInQr(client, params) {
30
30
  async function handle2fa(input) {
31
31
  const isDynamic = typeof input === "function";
32
32
  while (true) {
33
- const password = await miscUtils.resolveMaybeDynamic(input);
33
+ const password = await miscUtils$1.resolveMaybeDynamic(input);
34
34
  try {
35
35
  return await checkPassword.checkPassword(client, {
36
36
  password,
@@ -81,7 +81,7 @@ async function signInQr(client, params) {
81
81
  waiter = new utils.Deferred();
82
82
  await Promise.race([
83
83
  waiter.promise,
84
- miscUtils$1.sleepWithAbort(res.expires * 1e3 - Date.now(), client.stopSignal)
84
+ miscUtils.sleepWithAbort(res.expires * 1e3 - Date.now(), client.stopSignal)
85
85
  ]);
86
86
  break;
87
87
  case "auth.loginTokenMigrateTo": {
@@ -9,9 +9,11 @@ const utils = require("@fuman/utils");
9
9
  const fileId = require("@mtcute/file-id");
10
10
  const tl = require("@mtcute/tl");
11
11
  const errors = require("../../../types/errors.cjs");
12
+ const peerUtils = require("../../../utils/peer-utils.cjs");
12
13
  const convertFileId = require("../../utils/convert-file-id.cjs");
13
14
  const fileUtils = require("../../utils/file-utils.cjs");
14
15
  const fileLocation = require("../../types/files/file-location.cjs");
16
+ const errors$1 = require("../../types/errors.cjs");
15
17
  const SMALL_FILE_MAX_SIZE = 131072;
16
18
  const REQUESTS_PER_CONNECTION = 3;
17
19
  async function* downloadAsIterable(client, input, params) {
@@ -47,6 +49,29 @@ async function* downloadAsIterable(client, input, params) {
47
49
  location = input;
48
50
  }
49
51
  const isWeb = tl.tl.isAnyInputWebFileLocation(location);
52
+ if (location._ === "inputPeerPhotoFileLocation") {
53
+ if (location.peer._ === "mtcute.dummyInputPeerMinUser" || location.peer._ === "mtcute.dummyInputPeerMinChannel") {
54
+ const peerId = location.peer._ === "mtcute.dummyInputPeerMinUser" ? location.peer.userId : peerUtils.toggleChannelIdMark(location.peer.channelId);
55
+ const accessHash = await client.storage.peers.getMinAccessHash(peerId);
56
+ if (!accessHash) {
57
+ throw new errors$1.MtPeerNotFoundError(`Peer ${peerId} not found`);
58
+ }
59
+ location = {
60
+ _: "inputPeerPhotoFileLocation",
61
+ peer: location.peer._ === "mtcute.dummyInputPeerMinUser" ? {
62
+ _: "inputPeerUser",
63
+ userId: location.peer.userId,
64
+ accessHash
65
+ } : {
66
+ _: "inputPeerChannel",
67
+ channelId: location.peer.channelId,
68
+ accessHash
69
+ },
70
+ photoId: location.photoId,
71
+ big: location.big
72
+ };
73
+ }
74
+ }
50
75
  const primaryDcId = await client.getPrimaryDcId();
51
76
  if (!dcId) dcId = primaryDcId;
52
77
  const partSizeKb = params?.partSize ?? (fileSize ? fileUtils.determinePartSize(fileSize) : 64);
@@ -2,9 +2,11 @@ import { ConditionVariable } from "@fuman/utils";
2
2
  import { parseFileId } from "@mtcute/file-id";
3
3
  import { tl } from "@mtcute/tl";
4
4
  import { MtArgumentError, MtUnsupportedError } from "../../../types/errors.js";
5
+ import { toggleChannelIdMark } from "../../../utils/peer-utils.js";
5
6
  import { fileIdToInputWebFileLocation, fileIdToInputFileLocation } from "../../utils/convert-file-id.js";
6
7
  import { determinePartSize } from "../../utils/file-utils.js";
7
8
  import { FileLocation as FileLocation$1 } from "../../types/files/file-location.js";
9
+ import { MtPeerNotFoundError } from "../../types/errors.js";
8
10
  const SMALL_FILE_MAX_SIZE = 131072;
9
11
  const REQUESTS_PER_CONNECTION = 3;
10
12
  async function* downloadAsIterable(client, input, params) {
@@ -40,6 +42,29 @@ async function* downloadAsIterable(client, input, params) {
40
42
  location = input;
41
43
  }
42
44
  const isWeb = tl.isAnyInputWebFileLocation(location);
45
+ if (location._ === "inputPeerPhotoFileLocation") {
46
+ if (location.peer._ === "mtcute.dummyInputPeerMinUser" || location.peer._ === "mtcute.dummyInputPeerMinChannel") {
47
+ const peerId = location.peer._ === "mtcute.dummyInputPeerMinUser" ? location.peer.userId : toggleChannelIdMark(location.peer.channelId);
48
+ const accessHash = await client.storage.peers.getMinAccessHash(peerId);
49
+ if (!accessHash) {
50
+ throw new MtPeerNotFoundError(`Peer ${peerId} not found`);
51
+ }
52
+ location = {
53
+ _: "inputPeerPhotoFileLocation",
54
+ peer: location.peer._ === "mtcute.dummyInputPeerMinUser" ? {
55
+ _: "inputPeerUser",
56
+ userId: location.peer.userId,
57
+ accessHash
58
+ } : {
59
+ _: "inputPeerChannel",
60
+ channelId: location.peer.channelId,
61
+ accessHash
62
+ },
63
+ photoId: location.photoId,
64
+ big: location.big
65
+ };
66
+ }
67
+ }
43
68
  const primaryDcId = await client.getPrimaryDcId();
44
69
  if (!dcId) dcId = primaryDcId;
45
70
  const partSizeKb = params?.partSize ?? (fileSize ? determinePartSize(fileSize) : 64);
@@ -2,7 +2,7 @@ import { Bytes, webReadableToFuman, read } from "@fuman/io";
2
2
  import { AsyncLock } from "@fuman/utils";
3
3
  import { MtArgumentError } from "../../../types/errors.js";
4
4
  import { randomLong } from "../../../utils/long-utils.js";
5
- import { guessFileMime, MIME_TO_EXTENSION } from "../../utils/file-type.js";
5
+ import { MIME_TO_EXTENSION, guessFileMime } from "../../utils/file-type.js";
6
6
  import { determinePartSize, isProbablyPlainText } from "../../utils/file-utils.js";
7
7
  const OVERRIDE_MIME = {
8
8
  // tg doesn't interpret `audio/opus` files as voice messages for some reason
@@ -47,7 +47,8 @@ async function forwardMessagesById(client, params) {
47
47
  sendAs: sendAs ? await resolvePeer.resolvePeer(client, sendAs) : void 0,
48
48
  quickReplyShortcut: sendCommon._normalizeQuickReplyShortcut(params.quickReply),
49
49
  allowPaidFloodskip,
50
- videoTimestamp
50
+ videoTimestamp,
51
+ allowPaidStars: params.allowPaidMessages
51
52
  });
52
53
  utils.assertIsUpdatesGroup("messages.forwardMessages", res);
53
54
  client.handleClientUpdate(res, !params.shouldDispatch);
@@ -1,3 +1,4 @@
1
+ import { tl } from '@mtcute/tl';
1
2
  import { ITelegramClient } from '../../client.types.js';
2
3
  import { InputPeerLike, Message } from '../../types/index.js';
3
4
  export interface ForwardMessageOptions {
@@ -57,6 +58,11 @@ export interface ForwardMessageOptions {
57
58
  * The Stars will be withdrawn from the bot's balance.
58
59
  */
59
60
  allowPaidFloodskip?: boolean;
61
+ /**
62
+ * Whether to allow payment for messages.
63
+ * If set, the value represents the maximum number of stars to be paid
64
+ */
65
+ allowPaidMessages?: tl.Long;
60
66
  /** Video timestamp to use for the forwarded video */
61
67
  videoTimestamp?: number;
62
68
  }
@@ -1,3 +1,4 @@
1
+ import { tl } from '@mtcute/tl';
1
2
  import { ITelegramClient } from '../../client.types.js';
2
3
  import { InputPeerLike, Message } from '../../types/index.js';
3
4
  export interface ForwardMessageOptions {
@@ -57,6 +58,11 @@ export interface ForwardMessageOptions {
57
58
  * The Stars will be withdrawn from the bot's balance.
58
59
  */
59
60
  allowPaidFloodskip?: boolean;
61
+ /**
62
+ * Whether to allow payment for messages.
63
+ * If set, the value represents the maximum number of stars to be paid
64
+ */
65
+ allowPaidMessages?: tl.Long;
60
66
  /** Video timestamp to use for the forwarded video */
61
67
  videoTimestamp?: number;
62
68
  }
@@ -40,7 +40,8 @@ async function forwardMessagesById(client, params) {
40
40
  sendAs: sendAs ? await resolvePeer(client, sendAs) : void 0,
41
41
  quickReplyShortcut: _normalizeQuickReplyShortcut(params.quickReply),
42
42
  allowPaidFloodskip,
43
- videoTimestamp
43
+ videoTimestamp,
44
+ allowPaidStars: params.allowPaidMessages
44
45
  });
45
46
  assertIsUpdatesGroup("messages.forwardMessages", res);
46
47
  client.handleClientUpdate(res, !params.shouldDispatch);