@mtcute/core 0.19.7 → 0.20.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 (111) hide show
  1. package/client.cjs +24 -0
  2. package/client.js +24 -0
  3. package/highlevel/base.cjs +2 -2
  4. package/highlevel/base.js +2 -2
  5. package/highlevel/client.d.cts +68 -9
  6. package/highlevel/client.d.ts +68 -9
  7. package/highlevel/methods/files/normalize-input-media.cjs +12 -2
  8. package/highlevel/methods/files/normalize-input-media.js +12 -2
  9. package/highlevel/methods/messages/forward-messages.cjs +4 -2
  10. package/highlevel/methods/messages/forward-messages.d.cts +2 -0
  11. package/highlevel/methods/messages/forward-messages.d.ts +2 -0
  12. package/highlevel/methods/messages/forward-messages.js +4 -2
  13. package/highlevel/methods/premium/_normalize-input-star-gift.cjs +23 -0
  14. package/highlevel/methods/premium/_normalize-input-star-gift.d.cts +4 -0
  15. package/highlevel/methods/premium/_normalize-input-star-gift.d.ts +4 -0
  16. package/highlevel/methods/premium/_normalize-input-star-gift.js +18 -0
  17. package/highlevel/methods/premium/accept-star-gift.cjs +4 -3
  18. package/highlevel/methods/premium/accept-star-gift.d.cts +3 -3
  19. package/highlevel/methods/premium/accept-star-gift.d.ts +3 -3
  20. package/highlevel/methods/premium/accept-star-gift.js +4 -3
  21. package/highlevel/methods/premium/get-saved-star-gifts-by-id.cjs +21 -0
  22. package/highlevel/methods/premium/get-saved-star-gifts-by-id.d.cts +6 -0
  23. package/highlevel/methods/premium/get-saved-star-gifts-by-id.d.ts +6 -0
  24. package/highlevel/methods/premium/get-saved-star-gifts-by-id.js +16 -0
  25. package/highlevel/methods/premium/get-saved-star-gifts.cjs +32 -0
  26. package/highlevel/methods/premium/get-saved-star-gifts.d.cts +24 -0
  27. package/highlevel/methods/premium/get-saved-star-gifts.d.ts +24 -0
  28. package/highlevel/methods/premium/get-saved-star-gifts.js +27 -0
  29. package/highlevel/methods/premium/get-star-gift-withdrawal-url.cjs +23 -0
  30. package/highlevel/methods/premium/get-star-gift-withdrawal-url.d.cts +8 -0
  31. package/highlevel/methods/premium/get-star-gift-withdrawal-url.d.ts +8 -0
  32. package/highlevel/methods/premium/get-star-gift-withdrawal-url.js +18 -0
  33. package/highlevel/methods/premium/get-unique-star-gift.cjs +20 -0
  34. package/highlevel/methods/premium/get-unique-star-gift.d.cts +6 -0
  35. package/highlevel/methods/premium/get-unique-star-gift.d.ts +6 -0
  36. package/highlevel/methods/premium/get-unique-star-gift.js +15 -0
  37. package/highlevel/methods/premium/iter-saved-star-gifts.cjs +33 -0
  38. package/highlevel/methods/premium/iter-saved-star-gifts.d.cts +27 -0
  39. package/highlevel/methods/premium/iter-saved-star-gifts.d.ts +27 -0
  40. package/highlevel/methods/premium/iter-saved-star-gifts.js +28 -0
  41. package/highlevel/methods/premium/send-star-gift.cjs +2 -2
  42. package/highlevel/methods/premium/send-star-gift.d.cts +2 -2
  43. package/highlevel/methods/premium/send-star-gift.d.ts +2 -2
  44. package/highlevel/methods/premium/send-star-gift.js +3 -3
  45. package/highlevel/methods/premium/transfer-star-gift.cjs +4 -4
  46. package/highlevel/methods/premium/transfer-star-gift.d.cts +3 -3
  47. package/highlevel/methods/premium/transfer-star-gift.d.ts +3 -3
  48. package/highlevel/methods/premium/transfer-star-gift.js +5 -5
  49. package/highlevel/methods/premium/upgrade-star-gift.cjs +3 -3
  50. package/highlevel/methods/premium/upgrade-star-gift.d.cts +2 -2
  51. package/highlevel/methods/premium/upgrade-star-gift.d.ts +2 -2
  52. package/highlevel/methods/premium/upgrade-star-gift.js +3 -3
  53. package/highlevel/methods/users/set-emoji-status.cjs +8 -1
  54. package/highlevel/methods/users/set-emoji-status.d.cts +2 -0
  55. package/highlevel/methods/users/set-emoji-status.d.ts +2 -0
  56. package/highlevel/methods/users/set-emoji-status.js +8 -1
  57. package/highlevel/methods.d.cts +6 -0
  58. package/highlevel/methods.d.ts +6 -0
  59. package/highlevel/types/media/input-media/types.d.cts +4 -0
  60. package/highlevel/types/media/input-media/types.d.ts +4 -0
  61. package/highlevel/types/media/video.cjs +8 -0
  62. package/highlevel/types/media/video.d.cts +3 -0
  63. package/highlevel/types/media/video.d.ts +3 -0
  64. package/highlevel/types/media/video.js +8 -0
  65. package/highlevel/types/messages/message-action.cjs +22 -1
  66. package/highlevel/types/messages/message-action.d.cts +4 -0
  67. package/highlevel/types/messages/message-action.d.ts +4 -0
  68. package/highlevel/types/messages/message-action.js +22 -1
  69. package/highlevel/types/peers/chat.cjs +3 -1
  70. package/highlevel/types/peers/chat.js +3 -1
  71. package/highlevel/types/peers/full-chat.cjs +8 -0
  72. package/highlevel/types/peers/full-chat.d.cts +4 -0
  73. package/highlevel/types/peers/full-chat.d.ts +4 -0
  74. package/highlevel/types/peers/full-chat.js +8 -0
  75. package/highlevel/types/peers/user.cjs +3 -1
  76. package/highlevel/types/peers/user.js +3 -1
  77. package/highlevel/types/premium/index.d.cts +1 -0
  78. package/highlevel/types/premium/index.d.ts +1 -0
  79. package/highlevel/types/premium/saved-star-gift.cjs +80 -0
  80. package/highlevel/types/premium/saved-star-gift.d.cts +39 -0
  81. package/highlevel/types/premium/saved-star-gift.d.ts +39 -0
  82. package/highlevel/types/premium/saved-star-gift.js +75 -0
  83. package/highlevel/types/premium/stars-gift-unique.cjs +18 -5
  84. package/highlevel/types/premium/stars-gift-unique.d.cts +11 -5
  85. package/highlevel/types/premium/stars-gift-unique.d.ts +11 -5
  86. package/highlevel/types/premium/stars-gift-unique.js +18 -5
  87. package/highlevel/types/premium/stars-gift.d.cts +12 -1
  88. package/highlevel/types/premium/stars-gift.d.ts +12 -1
  89. package/highlevel/types/reactions/emoji-status.cjs +38 -1
  90. package/highlevel/types/reactions/emoji-status.d.cts +23 -2
  91. package/highlevel/types/reactions/emoji-status.d.ts +23 -2
  92. package/highlevel/types/reactions/emoji-status.js +39 -2
  93. package/highlevel/types/stories/interactive/index.cjs +4 -0
  94. package/highlevel/types/stories/interactive/index.d.cts +3 -2
  95. package/highlevel/types/stories/interactive/index.d.ts +3 -2
  96. package/highlevel/types/stories/interactive/index.js +4 -0
  97. package/highlevel/types/stories/interactive/star-gift.cjs +22 -0
  98. package/highlevel/types/stories/interactive/star-gift.d.cts +12 -0
  99. package/highlevel/types/stories/interactive/star-gift.d.ts +12 -0
  100. package/highlevel/types/stories/interactive/star-gift.js +17 -0
  101. package/highlevel/updates/manager.cjs +11 -9
  102. package/highlevel/updates/manager.d.cts +1 -3
  103. package/highlevel/updates/manager.d.ts +1 -3
  104. package/highlevel/updates/manager.js +11 -9
  105. package/index.cjs +5 -0
  106. package/index.js +6 -1
  107. package/methods.cjs +12 -0
  108. package/methods.js +12 -0
  109. package/network/network-manager.cjs +1 -1
  110. package/network/network-manager.js +1 -1
  111. package/package.json +2 -2
@@ -7,12 +7,12 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const typeAssertions = require("../../../utils/type-assertions.cjs");
9
9
  const findInUpdate = require("../messages/find-in-update.cjs");
10
+ const _normalizeInputStarGift = require("./_normalize-input-star-gift.cjs");
10
11
  async function upgradeStarGift(client, params) {
11
- const { message, keepOriginalDetails, shouldDispatch } = params;
12
- const msgId = typeof message === "number" ? message : message.id;
12
+ const { gift, keepOriginalDetails, shouldDispatch } = params;
13
13
  const invoice = {
14
14
  _: "inputInvoiceStarGiftUpgrade",
15
- msgId,
15
+ stargift: await _normalizeInputStarGift._normalizeInputStarGift(client, gift),
16
16
  keepOriginalDetails
17
17
  };
18
18
  const form = await client.call({
@@ -1,4 +1,5 @@
1
1
  import { ITelegramClient } from '../../client.types.js';
2
+ import { InputStarGift } from '../../types/index.js';
2
3
  import { Message } from '../../types/messages/message.js';
3
4
  /**
4
5
  * Upgrades a star gift to a unique gift.
@@ -11,8 +12,7 @@ import { Message } from '../../types/messages/message.js';
11
12
  * @returns Service message about the upgraded gift
12
13
  */
13
14
  export declare function upgradeStarGift(client: ITelegramClient, params: {
14
- /** ID of the message containing the gift */
15
- message: number | Message;
15
+ gift: InputStarGift;
16
16
  /**
17
17
  * Whether to retain the original details of the gift
18
18
  * (like sender, recipient, date, message)
@@ -1,4 +1,5 @@
1
1
  import { ITelegramClient } from '../../client.types.js';
2
+ import { InputStarGift } from '../../types/index.js';
2
3
  import { Message } from '../../types/messages/message.js';
3
4
  /**
4
5
  * Upgrades a star gift to a unique gift.
@@ -11,8 +12,7 @@ import { Message } from '../../types/messages/message.js';
11
12
  * @returns Service message about the upgraded gift
12
13
  */
13
14
  export declare function upgradeStarGift(client: ITelegramClient, params: {
14
- /** ID of the message containing the gift */
15
- message: number | Message;
15
+ gift: InputStarGift;
16
16
  /**
17
17
  * Whether to retain the original details of the gift
18
18
  * (like sender, recipient, date, message)
@@ -1,11 +1,11 @@
1
1
  import { assertTypeIs } from "../../../utils/type-assertions.js";
2
2
  import { _findMessageInUpdate } from "../messages/find-in-update.js";
3
+ import { _normalizeInputStarGift } from "./_normalize-input-star-gift.js";
3
4
  async function upgradeStarGift(client, params) {
4
- const { message, keepOriginalDetails, shouldDispatch } = params;
5
- const msgId = typeof message === "number" ? message : message.id;
5
+ const { gift, keepOriginalDetails, shouldDispatch } = params;
6
6
  const invoice = {
7
7
  _: "inputInvoiceStarGiftUpgrade",
8
- msgId,
8
+ stargift: await _normalizeInputStarGift(client, gift),
9
9
  keepOriginalDetails
10
10
  };
11
11
  const form = await client.call({
@@ -22,7 +22,8 @@ async function setEmojiStatus(client, params) {
22
22
  const {
23
23
  peerId,
24
24
  emoji,
25
- until
25
+ until,
26
+ isCollectible
26
27
  } = params;
27
28
  const peer = await resolvePeer.resolvePeer(client, peerId);
28
29
  let emojiStatus;
@@ -34,6 +35,12 @@ async function setEmojiStatus(client, params) {
34
35
  documentId: emoji,
35
36
  until: miscUtils.normalizeDate(until)
36
37
  };
38
+ } else if (isCollectible) {
39
+ emojiStatus = {
40
+ _: "inputEmojiStatusCollectible",
41
+ collectibleId: emoji,
42
+ until: miscUtils.normalizeDate(until)
43
+ };
37
44
  } else {
38
45
  emojiStatus = {
39
46
  _: "emojiStatus",
@@ -25,6 +25,8 @@ export declare function setEmojiStatus(client: ITelegramClient, params: {
25
25
  peerId: InputPeerLike;
26
26
  /** Custom emoji ID or `null` to remove the emoji */
27
27
  emoji: tl.Long | null;
28
+ /** When true, `emoji` is the ID of the collectible emoji */
29
+ isCollectible?: boolean;
28
30
  /**
29
31
  * Date when the emoji status should expire (only if `emoji` is not `null`)
30
32
  */
@@ -25,6 +25,8 @@ export declare function setEmojiStatus(client: ITelegramClient, params: {
25
25
  peerId: InputPeerLike;
26
26
  /** Custom emoji ID or `null` to remove the emoji */
27
27
  emoji: tl.Long | null;
28
+ /** When true, `emoji` is the ID of the collectible emoji */
29
+ isCollectible?: boolean;
28
30
  /**
29
31
  * Date when the emoji status should expire (only if `emoji` is not `null`)
30
32
  */
@@ -15,7 +15,8 @@ async function setEmojiStatus(client, params) {
15
15
  const {
16
16
  peerId,
17
17
  emoji,
18
- until
18
+ until,
19
+ isCollectible
19
20
  } = params;
20
21
  const peer = await resolvePeer(client, peerId);
21
22
  let emojiStatus;
@@ -27,6 +28,12 @@ async function setEmojiStatus(client, params) {
27
28
  documentId: emoji,
28
29
  until: normalizeDate(until)
29
30
  };
31
+ } else if (isCollectible) {
32
+ emojiStatus = {
33
+ _: "inputEmojiStatusCollectible",
34
+ collectibleId: emoji,
35
+ until: normalizeDate(until)
36
+ };
30
37
  } else {
31
38
  emojiStatus = {
32
39
  _: "emojiStatus",
@@ -208,6 +208,7 @@ export { verifyPasswordEmail } from './methods/password/password-email.js';
208
208
  export { resendPasswordEmail } from './methods/password/password-email.js';
209
209
  export { cancelPasswordEmail } from './methods/password/password-email.js';
210
210
  export { removeCloudPassword } from './methods/password/remove-cloud-password.js';
211
+ export { _normalizeInputStarGift } from './methods/premium/_normalize-input-star-gift.js';
211
212
  export { acceptStarGift } from './methods/premium/accept-star-gift.js';
212
213
  export { applyBoost } from './methods/premium/apply-boost.js';
213
214
  export { canApplyBoost } from './methods/premium/can-apply-boost.js';
@@ -220,10 +221,15 @@ export { getBoosts } from './methods/premium/get-boosts.js';
220
221
  export { getBusinessChatLinks } from './methods/premium/get-business-chat-links.js';
221
222
  export { getBusinessConnection } from './methods/premium/get-business-connection.js';
222
223
  export { getMyBoostSlots } from './methods/premium/get-my-boost-slots.js';
224
+ export { getSavedStarGiftsById } from './methods/premium/get-saved-star-gifts-by-id.js';
225
+ export { getSavedStarGifts } from './methods/premium/get-saved-star-gifts.js';
223
226
  export { getStarGiftOptions } from './methods/premium/get-star-gift-options.js';
227
+ export { getStarGiftWithdrawalUrl } from './methods/premium/get-star-gift-withdrawal-url.js';
224
228
  export { getStarGifts } from './methods/premium/get-star-gifts.js';
225
229
  export { getStarsTransactions } from './methods/premium/get-stars-transactions.js';
230
+ export { getUniqueStarGift } from './methods/premium/get-unique-star-gift.js';
226
231
  export { iterBoosters } from './methods/premium/iter-boosters.js';
232
+ export { iterSavedStarGifts } from './methods/premium/iter-saved-star-gifts.js';
227
233
  export { iterStarGifts } from './methods/premium/iter-star-gifts.js';
228
234
  export { iterStarsTransactions } from './methods/premium/iter-stars-transactions.js';
229
235
  export { sendStarGift } from './methods/premium/send-star-gift.js';
@@ -208,6 +208,7 @@ export { verifyPasswordEmail } from './methods/password/password-email.js';
208
208
  export { resendPasswordEmail } from './methods/password/password-email.js';
209
209
  export { cancelPasswordEmail } from './methods/password/password-email.js';
210
210
  export { removeCloudPassword } from './methods/password/remove-cloud-password.js';
211
+ export { _normalizeInputStarGift } from './methods/premium/_normalize-input-star-gift.js';
211
212
  export { acceptStarGift } from './methods/premium/accept-star-gift.js';
212
213
  export { applyBoost } from './methods/premium/apply-boost.js';
213
214
  export { canApplyBoost } from './methods/premium/can-apply-boost.js';
@@ -220,10 +221,15 @@ export { getBoosts } from './methods/premium/get-boosts.js';
220
221
  export { getBusinessChatLinks } from './methods/premium/get-business-chat-links.js';
221
222
  export { getBusinessConnection } from './methods/premium/get-business-connection.js';
222
223
  export { getMyBoostSlots } from './methods/premium/get-my-boost-slots.js';
224
+ export { getSavedStarGiftsById } from './methods/premium/get-saved-star-gifts-by-id.js';
225
+ export { getSavedStarGifts } from './methods/premium/get-saved-star-gifts.js';
223
226
  export { getStarGiftOptions } from './methods/premium/get-star-gift-options.js';
227
+ export { getStarGiftWithdrawalUrl } from './methods/premium/get-star-gift-withdrawal-url.js';
224
228
  export { getStarGifts } from './methods/premium/get-star-gifts.js';
225
229
  export { getStarsTransactions } from './methods/premium/get-stars-transactions.js';
230
+ export { getUniqueStarGift } from './methods/premium/get-unique-star-gift.js';
226
231
  export { iterBoosters } from './methods/premium/iter-boosters.js';
232
+ export { iterSavedStarGifts } from './methods/premium/iter-saved-star-gifts.js';
227
233
  export { iterStarGifts } from './methods/premium/iter-star-gifts.js';
228
234
  export { iterStarsTransactions } from './methods/premium/iter-stars-transactions.js';
229
235
  export { sendStarGift } from './methods/premium/send-star-gift.js';
@@ -211,6 +211,10 @@ export interface InputMediaVideo extends FileMixin, CaptionMixin {
211
211
  * Whether this video should be hidden with a spoiler
212
212
  */
213
213
  spoiler?: boolean;
214
+ /** Cover for the video */
215
+ cover?: InputMediaPhoto;
216
+ /** Timestamp for the auto-generated cover (?) */
217
+ timestamp?: number;
214
218
  }
215
219
  /**
216
220
  * A geolocation to be sent
@@ -211,6 +211,10 @@ export interface InputMediaVideo extends FileMixin, CaptionMixin {
211
211
  * Whether this video should be hidden with a spoiler
212
212
  */
213
213
  spoiler?: boolean;
214
+ /** Cover for the video */
215
+ cover?: InputMediaPhoto;
216
+ /** Timestamp for the auto-generated cover (?) */
217
+ timestamp?: number;
214
218
  }
215
219
  /**
216
220
  * A geolocation to be sent
@@ -8,6 +8,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const fileId = require("@mtcute/file-id");
9
9
  const memoize = require("../../utils/memoize.cjs");
10
10
  const document = require("./document.cjs");
11
+ const photo = require("./photo.cjs");
11
12
  const inspectable = require("../../utils/inspectable.cjs");
12
13
  class Video extends document.RawDocument {
13
14
  constructor(doc, attr, media) {
@@ -74,6 +75,13 @@ class Video extends document.RawDocument {
74
75
  get codec() {
75
76
  return this.attr._ === "documentAttributeVideo" ? this.attr.videoCodec ?? null : null;
76
77
  }
78
+ get videoCover() {
79
+ if (!this.media || this.media.videoCover?._ !== "photo") return null;
80
+ return new photo.Photo(this.media.videoCover);
81
+ }
82
+ get videoTimestamp() {
83
+ return this.media?.videoTimestamp ?? null;
84
+ }
77
85
  }
78
86
  const Video$1 = /* @__PURE__ */ memoize.memoizeGetters(Video, ["fileName", "thumbnails", "fileId", "uniqueFileId", "isAnimation"]);
79
87
  const Video$2 = /* @__PURE__ */ inspectable.makeInspectable(Video$1, ["fileSize", "dcId"], ["inputMedia", "inputDocument"]);
@@ -1,6 +1,7 @@
1
1
  import { tl } from '@mtcute/tl';
2
2
  import { tdFileId } from '@mtcute/file-id';
3
3
  import { RawDocument } from './document.js';
4
+ import { Photo } from './photo.js';
4
5
  /**
5
6
  * A video, round video message or GIF animation.
6
7
  *
@@ -45,4 +46,6 @@ export declare class Video extends RawDocument {
45
46
  get ttlSeconds(): number | null;
46
47
  get videoStartTs(): number | null;
47
48
  get codec(): string | null;
49
+ get videoCover(): Photo | null;
50
+ get videoTimestamp(): number | null;
48
51
  }
@@ -1,6 +1,7 @@
1
1
  import { tl } from '@mtcute/tl';
2
2
  import { tdFileId } from '@mtcute/file-id';
3
3
  import { RawDocument } from './document.js';
4
+ import { Photo } from './photo.js';
4
5
  /**
5
6
  * A video, round video message or GIF animation.
6
7
  *
@@ -45,4 +46,6 @@ export declare class Video extends RawDocument {
45
46
  get ttlSeconds(): number | null;
46
47
  get videoStartTs(): number | null;
47
48
  get codec(): string | null;
49
+ get videoCover(): Photo | null;
50
+ get videoTimestamp(): number | null;
48
51
  }
@@ -1,6 +1,7 @@
1
1
  import { tdFileId } from "@mtcute/file-id";
2
2
  import { memoizeGetters } from "../../utils/memoize.js";
3
3
  import { RawDocument } from "./document.js";
4
+ import { Photo as Photo$2 } from "./photo.js";
4
5
  import { makeInspectable } from "../../utils/inspectable.js";
5
6
  class Video extends RawDocument {
6
7
  constructor(doc, attr, media) {
@@ -67,6 +68,13 @@ class Video extends RawDocument {
67
68
  get codec() {
68
69
  return this.attr._ === "documentAttributeVideo" ? this.attr.videoCodec ?? null : null;
69
70
  }
71
+ get videoCover() {
72
+ if (!this.media || this.media.videoCover?._ !== "photo") return null;
73
+ return new Photo$2(this.media.videoCover);
74
+ }
75
+ get videoTimestamp() {
76
+ return this.media?.videoTimestamp ?? null;
77
+ }
70
78
  }
71
79
  const Video$1 = /* @__PURE__ */ memoizeGetters(Video, ["fileName", "thumbnails", "fileId", "uniqueFileId", "isAnimation"]);
72
80
  const Video$2 = /* @__PURE__ */ makeInspectable(Video$1, ["fileSize", "dcId"], ["inputMedia", "inputDocument"]);
@@ -298,7 +298,28 @@ function _messageActionFromTl(act) {
298
298
  canUpgrade: act.canUpgrade,
299
299
  upgraded: act.upgraded,
300
300
  upgradeStars: act.upgradeStars ?? Long.ZERO,
301
- upgradeMsgId: act.upgradeMsgId ?? null
301
+ upgradeMsgId: act.upgradeMsgId ?? null,
302
+ fromId: act.fromId ? peerUtils.getMarkedPeerId(act.fromId) : void 0,
303
+ toId: act.peer ? peerUtils.getMarkedPeerId(act.peer) : void 0,
304
+ savedId: act.savedId
305
+ };
306
+ case "messageActionStarGiftUnique":
307
+ return {
308
+ type: "stars_gift",
309
+ nameHidden: false,
310
+ saved: act.saved,
311
+ converted: false,
312
+ convertStars: Long.ZERO,
313
+ refunded: act.refunded,
314
+ gift: act.gift._ === "starGift" ? new starsGift.StarGift(act.gift) : new starsGiftUnique.StarGiftUnique(act.gift, this._peers),
315
+ message: null,
316
+ canUpgrade: false,
317
+ upgraded: true,
318
+ upgradeStars: Long.ZERO,
319
+ upgradeMsgId: null,
320
+ fromId: act.fromId ? peerUtils.getMarkedPeerId(act.fromId) : void 0,
321
+ toId: act.peer ? peerUtils.getMarkedPeerId(act.peer) : void 0,
322
+ savedId: act.savedId
302
323
  };
303
324
  default:
304
325
  return null;
@@ -2,6 +2,7 @@ import { tl } from '@mtcute/tl';
2
2
  import { TextWithEntities } from '../misc/entities.js';
3
3
  import { Peer } from '../peers/peer.js';
4
4
  import { Message } from './message.js';
5
+ import { default as Long } from 'long';
5
6
  import { Photo } from '../media/photo.js';
6
7
  import { StarGiftUnique } from '../premium/stars-gift-unique.js';
7
8
  import { StarGift } from '../premium/stars-gift.js';
@@ -425,6 +426,9 @@ export interface ActionStarGift {
425
426
  gift: StarGift | StarGiftUnique;
426
427
  /** Message attached to the gift */
427
428
  message: TextWithEntities | null;
429
+ fromId?: number;
430
+ toId?: number;
431
+ savedId?: Long;
428
432
  }
429
433
  export type MessageAction = ActionChatCreated | ActionChannelCreated | ActionChatMigrateTo | ActionChannelMigrateFrom | ActionMessagePinned | ActionHistoryCleared | ActionGameScore | ActionContactJoined | ActionTitleChanged | ActionPhotoChanged | ActionPhotoDeleted | ActionUsersAdded | ActionUserLeft | ActionUserRemoved | ActionUserJoinedLink | ActionPaymentReceived | ActionPaymentSent | ActionCall | ActionScreenshotTaken | ActionBotAllowed | ActionGeoProximity | ActionGroupCallStarted | ActionGroupCallEnded | ActionGroupCallScheduled | ActionGroupInvite | ActionTtlChanged | ActionTopicCreated | ActionTopicEdited | ActionCustom | ActionThemeChanged | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGift | null;
430
434
  /** @internal */
@@ -2,6 +2,7 @@ import { tl } from '@mtcute/tl';
2
2
  import { TextWithEntities } from '../misc/entities.js';
3
3
  import { Peer } from '../peers/peer.js';
4
4
  import { Message } from './message.js';
5
+ import { default as Long } from 'long';
5
6
  import { Photo } from '../media/photo.js';
6
7
  import { StarGiftUnique } from '../premium/stars-gift-unique.js';
7
8
  import { StarGift } from '../premium/stars-gift.js';
@@ -425,6 +426,9 @@ export interface ActionStarGift {
425
426
  gift: StarGift | StarGiftUnique;
426
427
  /** Message attached to the gift */
427
428
  message: TextWithEntities | null;
429
+ fromId?: number;
430
+ toId?: number;
431
+ savedId?: Long;
428
432
  }
429
433
  export type MessageAction = ActionChatCreated | ActionChannelCreated | ActionChatMigrateTo | ActionChannelMigrateFrom | ActionMessagePinned | ActionHistoryCleared | ActionGameScore | ActionContactJoined | ActionTitleChanged | ActionPhotoChanged | ActionPhotoDeleted | ActionUsersAdded | ActionUserLeft | ActionUserRemoved | ActionUserJoinedLink | ActionPaymentReceived | ActionPaymentSent | ActionCall | ActionScreenshotTaken | ActionBotAllowed | ActionGeoProximity | ActionGroupCallStarted | ActionGroupCallEnded | ActionGroupCallScheduled | ActionGroupInvite | ActionTtlChanged | ActionTopicCreated | ActionTopicEdited | ActionCustom | ActionThemeChanged | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGift | null;
430
434
  /** @internal */
@@ -291,7 +291,28 @@ function _messageActionFromTl(act) {
291
291
  canUpgrade: act.canUpgrade,
292
292
  upgraded: act.upgraded,
293
293
  upgradeStars: act.upgradeStars ?? Long.ZERO,
294
- upgradeMsgId: act.upgradeMsgId ?? null
294
+ upgradeMsgId: act.upgradeMsgId ?? null,
295
+ fromId: act.fromId ? getMarkedPeerId(act.fromId) : void 0,
296
+ toId: act.peer ? getMarkedPeerId(act.peer) : void 0,
297
+ savedId: act.savedId
298
+ };
299
+ case "messageActionStarGiftUnique":
300
+ return {
301
+ type: "stars_gift",
302
+ nameHidden: false,
303
+ saved: act.saved,
304
+ converted: false,
305
+ convertStars: Long.ZERO,
306
+ refunded: act.refunded,
307
+ gift: act.gift._ === "starGift" ? new StarGift$2(act.gift) : new StarGiftUnique$2(act.gift, this._peers),
308
+ message: null,
309
+ canUpgrade: false,
310
+ upgraded: true,
311
+ upgradeStars: Long.ZERO,
312
+ upgradeMsgId: null,
313
+ fromId: act.fromId ? getMarkedPeerId(act.fromId) : void 0,
314
+ toId: act.peer ? getMarkedPeerId(act.peer) : void 0,
315
+ savedId: act.savedId
295
316
  };
296
317
  default:
297
318
  return null;
@@ -331,7 +331,9 @@ class Chat {
331
331
  */
332
332
  get emojiStatus() {
333
333
  if (this.raw._ !== "channel") return null;
334
- if (!this.raw.emojiStatus || this.raw.emojiStatus._ === "emojiStatusEmpty") return null;
334
+ if (!this.raw.emojiStatus || this.raw.emojiStatus._ === "emojiStatusEmpty" || this.raw.emojiStatus._ === "inputEmojiStatusCollectible") {
335
+ return null;
336
+ }
335
337
  return new emojiStatus.EmojiStatus(this.raw.emojiStatus);
336
338
  }
337
339
  /**
@@ -324,7 +324,9 @@ class Chat {
324
324
  */
325
325
  get emojiStatus() {
326
326
  if (this.raw._ !== "channel") return null;
327
- if (!this.raw.emojiStatus || this.raw.emojiStatus._ === "emojiStatusEmpty") return null;
327
+ if (!this.raw.emojiStatus || this.raw.emojiStatus._ === "emojiStatusEmpty" || this.raw.emojiStatus._ === "inputEmojiStatusCollectible") {
328
+ return null;
329
+ }
328
330
  return new EmojiStatus$1(this.raw.emojiStatus);
329
331
  }
330
332
  /**
@@ -298,6 +298,14 @@ class FullChat extends chat.Chat {
298
298
  if (this.full._ !== "channelFull" || !this.full.botVerification) return null;
299
299
  return new botVerification.BotVerification(this.full.botVerification);
300
300
  }
301
+ /** Whether star gifts are available in this chat */
302
+ get starGiftsAvailable() {
303
+ return this.full._ === "channelFull" && this.full.stargiftsAvailable;
304
+ }
305
+ /** Number of star gifts available in this chat */
306
+ get starGiftsCount() {
307
+ return this.full._ === "channelFull" ? this.full.stargiftsCount ?? 0 : 0;
308
+ }
301
309
  }
302
310
  const FullChat$1 = /* @__PURE__ */ memoize.memoizeGetters(FullChat, [
303
311
  "fullPhoto",
@@ -161,4 +161,8 @@ export declare class FullChat extends Chat {
161
161
  get stories(): PeerStories | null;
162
162
  /** Information about a bot-issued verification (if any) */
163
163
  get botVerification(): BotVerification | null;
164
+ /** Whether star gifts are available in this chat */
165
+ get starGiftsAvailable(): boolean;
166
+ /** Number of star gifts available in this chat */
167
+ get starGiftsCount(): number;
164
168
  }
@@ -161,4 +161,8 @@ export declare class FullChat extends Chat {
161
161
  get stories(): PeerStories | null;
162
162
  /** Information about a bot-issued verification (if any) */
163
163
  get botVerification(): BotVerification | null;
164
+ /** Whether star gifts are available in this chat */
165
+ get starGiftsAvailable(): boolean;
166
+ /** Number of star gifts available in this chat */
167
+ get starGiftsCount(): number;
164
168
  }
@@ -291,6 +291,14 @@ class FullChat extends Chat$2 {
291
291
  if (this.full._ !== "channelFull" || !this.full.botVerification) return null;
292
292
  return new BotVerification$1(this.full.botVerification);
293
293
  }
294
+ /** Whether star gifts are available in this chat */
295
+ get starGiftsAvailable() {
296
+ return this.full._ === "channelFull" && this.full.stargiftsAvailable;
297
+ }
298
+ /** Number of star gifts available in this chat */
299
+ get starGiftsCount() {
300
+ return this.full._ === "channelFull" ? this.full.stargiftsCount ?? 0 : 0;
301
+ }
294
302
  }
295
303
  const FullChat$1 = /* @__PURE__ */ memoizeGetters(FullChat, [
296
304
  "fullPhoto",
@@ -335,7 +335,9 @@ class User {
335
335
  * User's emoji status, if any.
336
336
  */
337
337
  get emojiStatus() {
338
- if (!this.raw.emojiStatus || this.raw.emojiStatus._ === "emojiStatusEmpty") return null;
338
+ if (!this.raw.emojiStatus || this.raw.emojiStatus._ === "emojiStatusEmpty" || this.raw.emojiStatus._ === "inputEmojiStatusCollectible") {
339
+ return null;
340
+ }
339
341
  return new emojiStatus.EmojiStatus(this.raw.emojiStatus);
340
342
  }
341
343
  /** Whether you have hidden (arhived) this user's stories */
@@ -328,7 +328,9 @@ class User {
328
328
  * User's emoji status, if any.
329
329
  */
330
330
  get emojiStatus() {
331
- if (!this.raw.emojiStatus || this.raw.emojiStatus._ === "emojiStatusEmpty") return null;
331
+ if (!this.raw.emojiStatus || this.raw.emojiStatus._ === "emojiStatusEmpty" || this.raw.emojiStatus._ === "inputEmojiStatusCollectible") {
332
+ return null;
333
+ }
332
334
  return new EmojiStatus$1(this.raw.emojiStatus);
333
335
  }
334
336
  /** Whether you have hidden (arhived) this user's stories */
@@ -7,6 +7,7 @@ export * from './business-connection.js';
7
7
  export * from './business-intro.js';
8
8
  export * from './business-location.js';
9
9
  export * from './business-work-hours.js';
10
+ export * from './saved-star-gift.js';
10
11
  export * from './stars-gift-unique.js';
11
12
  export * from './stars-gift.js';
12
13
  export * from './stars-status.js';
@@ -7,6 +7,7 @@ export * from './business-connection.js';
7
7
  export * from './business-intro.js';
8
8
  export * from './business-location.js';
9
9
  export * from './business-work-hours.js';
10
+ export * from './saved-star-gift.js';
10
11
  export * from './stars-gift-unique.js';
11
12
  export * from './stars-gift.js';
12
13
  export * from './stars-status.js';
@@ -0,0 +1,80 @@
1
+ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
+ globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
+ console.warn("[@mtcute/core] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
+ }
6
+ "use strict";
7
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ const inspectable = require("../../utils/inspectable.cjs");
9
+ const memoize = require("../../utils/memoize.cjs");
10
+ const peer = require("../peers/peer.cjs");
11
+ const starsGiftUnique = require("./stars-gift-unique.cjs");
12
+ const starsGift = require("./stars-gift.cjs");
13
+ class SavedStarGift {
14
+ constructor(raw, _peers) {
15
+ this.raw = raw;
16
+ this._peers = _peers;
17
+ }
18
+ /** Whether the sender name is hidden */
19
+ get nameHidden() {
20
+ return this.raw.nameHidden;
21
+ }
22
+ /** Whether this gift was not saved yet */
23
+ get unsaved() {
24
+ return this.raw.unsaved;
25
+ }
26
+ /** Whether this gift was refunded */
27
+ get refunded() {
28
+ return this.raw.refunded;
29
+ }
30
+ /** Whether this gift can be upgraded to a unique gift */
31
+ get canUpgrade() {
32
+ return this.raw.canUpgrade;
33
+ }
34
+ /** Sender of the gift */
35
+ get sender() {
36
+ return this.raw.fromId ? peer.parsePeer(this.raw.fromId, this._peers) : null;
37
+ }
38
+ /** Date when the gift was sent */
39
+ get date() {
40
+ return new Date(this.raw.date * 1e3);
41
+ }
42
+ /** The gift itself */
43
+ get gift() {
44
+ if (this.raw.gift._ === "starGift") {
45
+ return new starsGift.StarGift(this.raw.gift);
46
+ }
47
+ return new starsGiftUnique.StarGiftUnique(this.raw.gift, this._peers);
48
+ }
49
+ /** The attached message */
50
+ get message() {
51
+ return this.raw.message ?? null;
52
+ }
53
+ /** ID of the message where the gift was originally sent (if available) */
54
+ get messageId() {
55
+ return this.raw.msgId ?? null;
56
+ }
57
+ /** ID of the saved gift */
58
+ get savedId() {
59
+ return this.raw.savedId ?? null;
60
+ }
61
+ /** Amount of stars the gift can be converted to by the recipient */
62
+ get convertStars() {
63
+ return this.raw.convertStars ?? null;
64
+ }
65
+ /** Amount of stars needed to upgrade the gift to a unique gift */
66
+ get upgradeStars() {
67
+ return this.raw.upgradeStars ?? null;
68
+ }
69
+ /** Amount of stars needed to transfer the gift */
70
+ get transferStars() {
71
+ return this.raw.transferStars ?? null;
72
+ }
73
+ /** Date when the gift can be exported to blockchain */
74
+ get canExportAt() {
75
+ return this.raw.canExportAt ? new Date(this.raw.canExportAt * 1e3) : null;
76
+ }
77
+ }
78
+ const SavedStarGift$1 = /* @__PURE__ */ inspectable.makeInspectable(SavedStarGift);
79
+ const SavedStarGift$2 = /* @__PURE__ */ memoize.memoizeGetters(SavedStarGift$1, ["sender", "gift"]);
80
+ exports.SavedStarGift = SavedStarGift$2;
@@ -0,0 +1,39 @@
1
+ import { tl } from '@mtcute/tl';
2
+ import { TextWithEntities } from '../misc/entities.js';
3
+ import { Peer } from '../peers/peer.js';
4
+ import { PeersIndex } from '../peers/peers-index.js';
5
+ import { StarGiftUnique } from './stars-gift-unique.js';
6
+ import { StarGift } from './stars-gift.js';
7
+ export declare class SavedStarGift {
8
+ readonly raw: tl.RawSavedStarGift;
9
+ readonly _peers: PeersIndex;
10
+ constructor(raw: tl.RawSavedStarGift, _peers: PeersIndex);
11
+ /** Whether the sender name is hidden */
12
+ get nameHidden(): boolean;
13
+ /** Whether this gift was not saved yet */
14
+ get unsaved(): boolean;
15
+ /** Whether this gift was refunded */
16
+ get refunded(): boolean;
17
+ /** Whether this gift can be upgraded to a unique gift */
18
+ get canUpgrade(): boolean;
19
+ /** Sender of the gift */
20
+ get sender(): Peer | null;
21
+ /** Date when the gift was sent */
22
+ get date(): Date;
23
+ /** The gift itself */
24
+ get gift(): StarGift | StarGiftUnique;
25
+ /** The attached message */
26
+ get message(): TextWithEntities | null;
27
+ /** ID of the message where the gift was originally sent (if available) */
28
+ get messageId(): number | null;
29
+ /** ID of the saved gift */
30
+ get savedId(): tl.Long | null;
31
+ /** Amount of stars the gift can be converted to by the recipient */
32
+ get convertStars(): tl.Long | null;
33
+ /** Amount of stars needed to upgrade the gift to a unique gift */
34
+ get upgradeStars(): tl.Long | null;
35
+ /** Amount of stars needed to transfer the gift */
36
+ get transferStars(): tl.Long | null;
37
+ /** Date when the gift can be exported to blockchain */
38
+ get canExportAt(): Date | null;
39
+ }