@mtcute/core 0.25.7 → 0.26.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 (118) hide show
  1. package/client.cjs +20 -11
  2. package/client.js +23 -14
  3. package/highlevel/client.d.cts +80 -64
  4. package/highlevel/client.d.ts +80 -64
  5. package/highlevel/methods/files/normalize-input-media.cjs +13 -4
  6. package/highlevel/methods/files/normalize-input-media.js +13 -4
  7. package/highlevel/methods/forums/toggle-forum.cjs +0 -10
  8. package/highlevel/methods/forums/toggle-forum.d.cts +0 -10
  9. package/highlevel/methods/forums/toggle-forum.d.ts +0 -10
  10. package/highlevel/methods/forums/toggle-forum.js +0 -10
  11. package/highlevel/methods/premium/buy-resale-gift.cjs +3 -2
  12. package/highlevel/methods/premium/buy-resale-gift.d.cts +2 -0
  13. package/highlevel/methods/premium/buy-resale-gift.d.ts +2 -0
  14. package/highlevel/methods/premium/buy-resale-gift.js +3 -2
  15. package/highlevel/methods/premium/get-resale-star-gifts.cjs +2 -2
  16. package/highlevel/methods/premium/get-resale-star-gifts.d.cts +1 -1
  17. package/highlevel/methods/premium/get-resale-star-gifts.d.ts +1 -1
  18. package/highlevel/methods/premium/get-resale-star-gifts.js +2 -2
  19. package/highlevel/methods/premium/get-saved-star-gifts.cjs +2 -1
  20. package/highlevel/methods/premium/get-saved-star-gifts.d.cts +4 -2
  21. package/highlevel/methods/premium/get-saved-star-gifts.d.ts +4 -2
  22. package/highlevel/methods/premium/get-saved-star-gifts.js +2 -1
  23. package/highlevel/methods/{auth/run.cjs → premium/get-star-gift-value.cjs} +8 -5
  24. package/highlevel/methods/premium/get-star-gift-value.d.cts +9 -0
  25. package/highlevel/methods/premium/get-star-gift-value.d.ts +9 -0
  26. package/highlevel/methods/premium/get-star-gift-value.js +11 -0
  27. package/highlevel/methods/premium/get-stars-transactions.cjs +3 -2
  28. package/highlevel/methods/premium/get-stars-transactions.d.cts +2 -0
  29. package/highlevel/methods/premium/get-stars-transactions.d.ts +2 -0
  30. package/highlevel/methods/premium/get-stars-transactions.js +3 -2
  31. package/highlevel/methods/premium/iter-saved-star-gifts.cjs +15 -10
  32. package/highlevel/methods/premium/iter-saved-star-gifts.d.cts +13 -19
  33. package/highlevel/methods/premium/iter-saved-star-gifts.d.ts +13 -19
  34. package/highlevel/methods/premium/iter-saved-star-gifts.js +15 -10
  35. package/highlevel/methods/premium/prepay-star-gift-upgrade.cjs +30 -0
  36. package/highlevel/methods/premium/prepay-star-gift-upgrade.d.cts +23 -0
  37. package/highlevel/methods/premium/prepay-star-gift-upgrade.d.ts +23 -0
  38. package/highlevel/methods/premium/prepay-star-gift-upgrade.js +25 -0
  39. package/highlevel/methods/stickers/delete-sticker-from-set.d.cts +2 -4
  40. package/highlevel/methods/stickers/delete-sticker-from-set.d.ts +2 -4
  41. package/highlevel/methods/stickers/move-sticker-in-set.d.cts +2 -4
  42. package/highlevel/methods/stickers/move-sticker-in-set.d.ts +2 -4
  43. package/highlevel/methods/stickers/replace-sticker-in-set.d.cts +2 -4
  44. package/highlevel/methods/stickers/replace-sticker-in-set.d.ts +2 -4
  45. package/highlevel/methods/users/get-saved-music.cjs +38 -0
  46. package/highlevel/methods/users/get-saved-music.d.cts +13 -0
  47. package/highlevel/methods/users/get-saved-music.d.ts +13 -0
  48. package/highlevel/methods/users/get-saved-music.js +33 -0
  49. package/highlevel/methods/users/save-music-to-profile.cjs +57 -0
  50. package/highlevel/methods/users/save-music-to-profile.d.cts +19 -0
  51. package/highlevel/methods/users/save-music-to-profile.d.ts +19 -0
  52. package/highlevel/methods/users/save-music-to-profile.js +52 -0
  53. package/highlevel/methods/users/set-emoji-status.cjs +0 -8
  54. package/highlevel/methods/users/set-emoji-status.d.cts +0 -11
  55. package/highlevel/methods/users/set-emoji-status.d.ts +0 -11
  56. package/highlevel/methods/users/set-emoji-status.js +1 -9
  57. package/highlevel/methods.d.cts +6 -4
  58. package/highlevel/methods.d.ts +6 -4
  59. package/highlevel/types/files/utils.d.cts +7 -0
  60. package/highlevel/types/files/utils.d.ts +7 -0
  61. package/highlevel/types/media/document.d.cts +1 -1
  62. package/highlevel/types/media/document.d.ts +1 -1
  63. package/highlevel/types/messages/message-action.cjs +43 -21
  64. package/highlevel/types/messages/message-action.d.cts +58 -17
  65. package/highlevel/types/messages/message-action.d.ts +58 -17
  66. package/highlevel/types/messages/message-action.js +43 -21
  67. package/highlevel/types/peers/chat.cjs +5 -1
  68. package/highlevel/types/peers/chat.d.cts +5 -1
  69. package/highlevel/types/peers/chat.d.ts +5 -1
  70. package/highlevel/types/peers/chat.js +5 -1
  71. package/highlevel/types/peers/full-chat.cjs +4 -0
  72. package/highlevel/types/peers/full-chat.d.cts +2 -0
  73. package/highlevel/types/peers/full-chat.d.ts +2 -0
  74. package/highlevel/types/peers/full-chat.js +4 -0
  75. package/highlevel/types/peers/full-user.cjs +10 -1
  76. package/highlevel/types/peers/full-user.d.cts +3 -0
  77. package/highlevel/types/peers/full-user.d.ts +3 -0
  78. package/highlevel/types/peers/full-user.js +10 -1
  79. package/highlevel/types/premium/index.d.cts +1 -0
  80. package/highlevel/types/premium/index.d.ts +1 -0
  81. package/highlevel/types/premium/saved-star-gift.cjs +6 -0
  82. package/highlevel/types/premium/saved-star-gift.d.cts +4 -0
  83. package/highlevel/types/premium/saved-star-gift.d.ts +4 -0
  84. package/highlevel/types/premium/saved-star-gift.js +6 -0
  85. package/highlevel/types/premium/star-gift-value.cjs +65 -0
  86. package/highlevel/types/premium/star-gift-value.d.cts +41 -0
  87. package/highlevel/types/premium/star-gift-value.d.ts +41 -0
  88. package/highlevel/types/premium/star-gift-value.js +60 -0
  89. package/highlevel/types/premium/stars-gift-unique.cjs +10 -3
  90. package/highlevel/types/premium/stars-gift-unique.d.cts +1 -1
  91. package/highlevel/types/premium/stars-gift-unique.d.ts +1 -1
  92. package/highlevel/types/premium/stars-gift-unique.js +10 -3
  93. package/highlevel/types/premium/stars-transaction.cjs +9 -0
  94. package/highlevel/types/premium/stars-transaction.d.cts +10 -0
  95. package/highlevel/types/premium/stars-transaction.d.ts +10 -0
  96. package/highlevel/types/premium/stars-transaction.js +9 -0
  97. package/index.cjs +2 -0
  98. package/index.js +2 -0
  99. package/methods.cjs +10 -5
  100. package/methods.js +13 -8
  101. package/network/mtproto-session.cjs +1 -0
  102. package/network/mtproto-session.d.cts +1 -0
  103. package/network/mtproto-session.d.ts +1 -0
  104. package/network/mtproto-session.js +1 -0
  105. package/network/network-manager.cjs +1 -1
  106. package/network/network-manager.js +1 -1
  107. package/network/session-connection.cjs +27 -10
  108. package/network/session-connection.d.cts +1 -0
  109. package/network/session-connection.d.ts +1 -0
  110. package/network/session-connection.js +27 -10
  111. package/package.json +2 -2
  112. package/utils/binary/compat.cjs +35 -4
  113. package/utils/binary/compat.js +35 -4
  114. package/utils/binary/serialization.d.cts +3 -3
  115. package/utils/binary/serialization.d.ts +3 -3
  116. package/highlevel/methods/auth/run.d.cts +0 -16
  117. package/highlevel/methods/auth/run.d.ts +0 -16
  118. package/highlevel/methods/auth/run.js +0 -8
@@ -0,0 +1,52 @@
1
+ import { assert } from "@fuman/utils";
2
+ import { tdFileId } from "@mtcute/file-id";
3
+ import { tl } from "@mtcute/tl";
4
+ import { assertTrue } from "../../../utils/type-assertions.js";
5
+ import { fileIdToInputDocument } from "../../utils/convert-file-id.js";
6
+ import { _normalizeInputMedia } from "../files/normalize-input-media.js";
7
+ async function saveMusicToProfile(client, params) {
8
+ let after = params.after;
9
+ if (tdFileId.isFileIdLike(after)) {
10
+ after = fileIdToInputDocument(after);
11
+ }
12
+ let audio = params.audio;
13
+ if (tdFileId.isFileIdLike(audio)) {
14
+ audio = {
15
+ type: "audio",
16
+ file: audio
17
+ };
18
+ }
19
+ let audioId;
20
+ if (tl.isAnyInputDocument(audio)) {
21
+ audioId = audio;
22
+ } else {
23
+ const media = await _normalizeInputMedia(client, audio, {
24
+ progressCallback: params.progressCallback,
25
+ uploadPeer: { _: "inputPeerSelf" }
26
+ }, true);
27
+ assert(media._ === "inputMediaDocument");
28
+ audioId = media.id;
29
+ }
30
+ const res = await client.call({
31
+ _: "account.saveMusic",
32
+ id: audioId,
33
+ afterId: after
34
+ });
35
+ assertTrue("account.saveMusic", res);
36
+ }
37
+ async function unsaveMusicFromProfile(client, params) {
38
+ let audio = params.audio;
39
+ if (tdFileId.isFileIdLike(audio)) {
40
+ audio = fileIdToInputDocument(audio);
41
+ }
42
+ const res = await client.call({
43
+ _: "account.saveMusic",
44
+ id: audio,
45
+ unsave: true
46
+ });
47
+ assertTrue("account.saveMusic", res);
48
+ }
49
+ export {
50
+ saveMusicToProfile,
51
+ unsaveMusicFromProfile
52
+ };
@@ -11,13 +11,6 @@ const utils = require("../auth/utils.cjs");
11
11
  const resolvePeer = require("./resolve-peer.cjs");
12
12
  const miscUtils = require("../../utils/misc-utils.cjs");
13
13
  const peerUtils = require("../../utils/peer-utils.cjs");
14
- async function setMyEmojiStatus(client, emoji, params) {
15
- return setEmojiStatus(client, {
16
- peerId: "self",
17
- emoji,
18
- until: params?.until
19
- });
20
- }
21
14
  async function setEmojiStatus(client, params) {
22
15
  const {
23
16
  peerId,
@@ -72,4 +65,3 @@ async function setEmojiStatus(client, params) {
72
65
  }
73
66
  }
74
67
  exports.setEmojiStatus = setEmojiStatus;
75
- exports.setMyEmojiStatus = setMyEmojiStatus;
@@ -1,17 +1,6 @@
1
1
  import { tl } from '@mtcute/tl';
2
2
  import { ITelegramClient } from '../../client.types.js';
3
3
  import { InputPeerLike } from '../../types/peers/peer.js';
4
- /**
5
- * Set an emoji status for the current user
6
- *
7
- * @deprecated – use {@link setEmojiStatus} with `self` instead
8
- */
9
- export declare function setMyEmojiStatus(client: ITelegramClient, emoji: tl.Long | null, params?: {
10
- /**
11
- * Date when the emoji status should expire (only if `emoji` is not `null`)
12
- */
13
- until?: number | Date;
14
- }): Promise<void>;
15
4
  /**
16
5
  * Set an emoji status for the given user/chat
17
6
  *
@@ -1,17 +1,6 @@
1
1
  import { tl } from '@mtcute/tl';
2
2
  import { ITelegramClient } from '../../client.types.js';
3
3
  import { InputPeerLike } from '../../types/peers/peer.js';
4
- /**
5
- * Set an emoji status for the current user
6
- *
7
- * @deprecated – use {@link setEmojiStatus} with `self` instead
8
- */
9
- export declare function setMyEmojiStatus(client: ITelegramClient, emoji: tl.Long | null, params?: {
10
- /**
11
- * Date when the emoji status should expire (only if `emoji` is not `null`)
12
- */
13
- until?: number | Date;
14
- }): Promise<void>;
15
4
  /**
16
5
  * Set an emoji status for the given user/chat
17
6
  *
@@ -4,13 +4,6 @@ import { isSelfPeer } from "../auth/utils.js";
4
4
  import { resolvePeer } from "./resolve-peer.js";
5
5
  import { normalizeDate } from "../../utils/misc-utils.js";
6
6
  import { isInputPeerChannel, toInputChannel, isInputPeerUser, toInputUser } from "../../utils/peer-utils.js";
7
- async function setMyEmojiStatus(client, emoji, params) {
8
- return setEmojiStatus(client, {
9
- peerId: "self",
10
- emoji,
11
- until: params?.until
12
- });
13
- }
14
7
  async function setEmojiStatus(client, params) {
15
8
  const {
16
9
  peerId,
@@ -65,6 +58,5 @@ async function setEmojiStatus(client, params) {
65
58
  }
66
59
  }
67
60
  export {
68
- setEmojiStatus,
69
- setMyEmojiStatus
61
+ setEmojiStatus
70
62
  };
@@ -4,7 +4,6 @@ export { logOut } from './methods/auth/log-out.js';
4
4
  export type { LogOutResult } from './methods/auth/log-out.js';
5
5
  export { recoverPassword } from './methods/auth/recover-password.js';
6
6
  export { resendCode } from './methods/auth/resend-code.js';
7
- export { run } from './methods/auth/run.js';
8
7
  export { sendCode } from './methods/auth/send-code.js';
9
8
  export { sendRecoveryCode } from './methods/auth/send-recovery-code.js';
10
9
  export { signInBot } from './methods/auth/sign-in-bot.js';
@@ -115,7 +114,6 @@ export { iterForumTopics } from './methods/forums/iter-forum-topics.js';
115
114
  export { reorderPinnedForumTopics } from './methods/forums/reorder-pinned-forum-topics.js';
116
115
  export { toggleForumTopicClosed } from './methods/forums/toggle-forum-topic-closed.js';
117
116
  export { toggleForumTopicPinned } from './methods/forums/toggle-forum-topic-pinned.js';
118
- export { toggleForum } from './methods/forums/toggle-forum.js';
119
117
  export { updateForumSettings } from './methods/forums/toggle-forum.js';
120
118
  export { toggleGeneralTopicHidden } from './methods/forums/toggle-general-topic-hidden.js';
121
119
  export { createInviteLink } from './methods/invite-links/create-invite-link.js';
@@ -231,11 +229,12 @@ export { getBoosts } from './methods/premium/get-boosts.js';
231
229
  export { getBusinessChatLinks } from './methods/premium/get-business-chat-links.js';
232
230
  export { getBusinessConnection } from './methods/premium/get-business-connection.js';
233
231
  export { getMyBoostSlots } from './methods/premium/get-my-boost-slots.js';
234
- export { getResaleOptions } from './methods/premium/get-resale-star-gifts.js';
232
+ export { getStarGiftResaleOptions } from './methods/premium/get-resale-star-gifts.js';
235
233
  export type { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/premium/get-resale-star-gifts.js';
236
234
  export { getSavedStarGiftsById } from './methods/premium/get-saved-star-gifts-by-id.js';
237
235
  export { getSavedStarGifts } from './methods/premium/get-saved-star-gifts.js';
238
236
  export { getStarGiftOptions } from './methods/premium/get-star-gift-options.js';
237
+ export { getStarGiftValue } from './methods/premium/get-star-gift-value.js';
239
238
  export { getStarGiftWithdrawalUrl } from './methods/premium/get-star-gift-withdrawal-url.js';
240
239
  export { getStarsTransactions } from './methods/premium/get-stars-transactions.js';
241
240
  export { getUniqueStarGift } from './methods/premium/get-unique-star-gift.js';
@@ -243,6 +242,7 @@ export { iterBoosters } from './methods/premium/iter-boosters.js';
243
242
  export { iterSavedStarGifts } from './methods/premium/iter-saved-star-gifts.js';
244
243
  export { iterStarsTransactions } from './methods/premium/iter-stars-transactions.js';
245
244
  export { togglePinnedStarGifts } from './methods/premium/pin-star-gift.js';
245
+ export { prepayStarGiftUpgrade } from './methods/premium/prepay-star-gift-upgrade.js';
246
246
  export { sendStarGift } from './methods/premium/send-star-gift.js';
247
247
  export { setBusinessIntro } from './methods/premium/set-business-intro.js';
248
248
  export { setBusinessWorkHours } from './methods/premium/set-business-work-hours.js';
@@ -293,6 +293,7 @@ export { getMyUsername } from './methods/users/get-my-username.js';
293
293
  export { getPeerSettings } from './methods/users/get-peer-settings.js';
294
294
  export { getProfilePhoto } from './methods/users/get-profile-photo.js';
295
295
  export { getProfilePhotos } from './methods/users/get-profile-photos.js';
296
+ export { getSavedMusic } from './methods/users/get-saved-music.js';
296
297
  export { getUsers } from './methods/users/get-users.js';
297
298
  export { isPeerAvailable } from './methods/users/is-peer-available.js';
298
299
  export { iterProfilePhotos } from './methods/users/iter-profile-photos.js';
@@ -301,7 +302,8 @@ export { resolvePeer } from './methods/users/resolve-peer.js';
301
302
  export { resolveUser } from './methods/users/resolve-peer.js';
302
303
  export { resolveChannel } from './methods/users/resolve-peer.js';
303
304
  export { resolvePhoneNumber } from './methods/users/resolve-phone-number.js';
304
- export { setMyEmojiStatus } from './methods/users/set-emoji-status.js';
305
+ export { saveMusicToProfile } from './methods/users/save-music-to-profile.js';
306
+ export { unsaveMusicFromProfile } from './methods/users/save-music-to-profile.js';
305
307
  export { setEmojiStatus } from './methods/users/set-emoji-status.js';
306
308
  export { setGlobalTtl } from './methods/users/set-global-ttl.js';
307
309
  export { setMyBirthday } from './methods/users/set-my-birthday.js';
@@ -4,7 +4,6 @@ export { logOut } from './methods/auth/log-out.js';
4
4
  export type { LogOutResult } from './methods/auth/log-out.js';
5
5
  export { recoverPassword } from './methods/auth/recover-password.js';
6
6
  export { resendCode } from './methods/auth/resend-code.js';
7
- export { run } from './methods/auth/run.js';
8
7
  export { sendCode } from './methods/auth/send-code.js';
9
8
  export { sendRecoveryCode } from './methods/auth/send-recovery-code.js';
10
9
  export { signInBot } from './methods/auth/sign-in-bot.js';
@@ -115,7 +114,6 @@ export { iterForumTopics } from './methods/forums/iter-forum-topics.js';
115
114
  export { reorderPinnedForumTopics } from './methods/forums/reorder-pinned-forum-topics.js';
116
115
  export { toggleForumTopicClosed } from './methods/forums/toggle-forum-topic-closed.js';
117
116
  export { toggleForumTopicPinned } from './methods/forums/toggle-forum-topic-pinned.js';
118
- export { toggleForum } from './methods/forums/toggle-forum.js';
119
117
  export { updateForumSettings } from './methods/forums/toggle-forum.js';
120
118
  export { toggleGeneralTopicHidden } from './methods/forums/toggle-general-topic-hidden.js';
121
119
  export { createInviteLink } from './methods/invite-links/create-invite-link.js';
@@ -231,11 +229,12 @@ export { getBoosts } from './methods/premium/get-boosts.js';
231
229
  export { getBusinessChatLinks } from './methods/premium/get-business-chat-links.js';
232
230
  export { getBusinessConnection } from './methods/premium/get-business-connection.js';
233
231
  export { getMyBoostSlots } from './methods/premium/get-my-boost-slots.js';
234
- export { getResaleOptions } from './methods/premium/get-resale-star-gifts.js';
232
+ export { getStarGiftResaleOptions } from './methods/premium/get-resale-star-gifts.js';
235
233
  export type { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/premium/get-resale-star-gifts.js';
236
234
  export { getSavedStarGiftsById } from './methods/premium/get-saved-star-gifts-by-id.js';
237
235
  export { getSavedStarGifts } from './methods/premium/get-saved-star-gifts.js';
238
236
  export { getStarGiftOptions } from './methods/premium/get-star-gift-options.js';
237
+ export { getStarGiftValue } from './methods/premium/get-star-gift-value.js';
239
238
  export { getStarGiftWithdrawalUrl } from './methods/premium/get-star-gift-withdrawal-url.js';
240
239
  export { getStarsTransactions } from './methods/premium/get-stars-transactions.js';
241
240
  export { getUniqueStarGift } from './methods/premium/get-unique-star-gift.js';
@@ -243,6 +242,7 @@ export { iterBoosters } from './methods/premium/iter-boosters.js';
243
242
  export { iterSavedStarGifts } from './methods/premium/iter-saved-star-gifts.js';
244
243
  export { iterStarsTransactions } from './methods/premium/iter-stars-transactions.js';
245
244
  export { togglePinnedStarGifts } from './methods/premium/pin-star-gift.js';
245
+ export { prepayStarGiftUpgrade } from './methods/premium/prepay-star-gift-upgrade.js';
246
246
  export { sendStarGift } from './methods/premium/send-star-gift.js';
247
247
  export { setBusinessIntro } from './methods/premium/set-business-intro.js';
248
248
  export { setBusinessWorkHours } from './methods/premium/set-business-work-hours.js';
@@ -293,6 +293,7 @@ export { getMyUsername } from './methods/users/get-my-username.js';
293
293
  export { getPeerSettings } from './methods/users/get-peer-settings.js';
294
294
  export { getProfilePhoto } from './methods/users/get-profile-photo.js';
295
295
  export { getProfilePhotos } from './methods/users/get-profile-photos.js';
296
+ export { getSavedMusic } from './methods/users/get-saved-music.js';
296
297
  export { getUsers } from './methods/users/get-users.js';
297
298
  export { isPeerAvailable } from './methods/users/is-peer-available.js';
298
299
  export { iterProfilePhotos } from './methods/users/iter-profile-photos.js';
@@ -301,7 +302,8 @@ export { resolvePeer } from './methods/users/resolve-peer.js';
301
302
  export { resolveUser } from './methods/users/resolve-peer.js';
302
303
  export { resolveChannel } from './methods/users/resolve-peer.js';
303
304
  export { resolvePhoneNumber } from './methods/users/resolve-phone-number.js';
304
- export { setMyEmojiStatus } from './methods/users/set-emoji-status.js';
305
+ export { saveMusicToProfile } from './methods/users/save-music-to-profile.js';
306
+ export { unsaveMusicFromProfile } from './methods/users/save-music-to-profile.js';
305
307
  export { setEmojiStatus } from './methods/users/set-emoji-status.js';
306
308
  export { setGlobalTtl } from './methods/users/set-global-ttl.js';
307
309
  export { setMyBirthday } from './methods/users/set-my-birthday.js';
@@ -40,6 +40,13 @@ export type UploadFileLike = URL | Uint8Array | File | Blob | string | IReadable
40
40
  * - `td.RawFullRemoteFileLocation` (parsed File ID)
41
41
  */
42
42
  export type InputFileLike = UploadFileLike | UploadedFile | tl.TypeInputFile | tl.TypeInputMedia | tdFileId.RawFullRemoteFileLocation;
43
+ /**
44
+ * ID of an already uploaded document. Can be a:
45
+ * - `string` with a TDLib and Bot API compatible File ID
46
+ * - `td.RawFullRemoteFileLocation` (parsed File ID)
47
+ * - `tl.TypeInputDocument` (raw TL object)
48
+ */
49
+ export type InputDocumentId = string | tdFileId.RawFullRemoteFileLocation | tl.RawInputDocument;
43
50
  /**
44
51
  * File location which should be downloaded.
45
52
  * You can also provide TDLib and Bot API compatible File ID
@@ -40,6 +40,13 @@ export type UploadFileLike = URL | Uint8Array | File | Blob | string | IReadable
40
40
  * - `td.RawFullRemoteFileLocation` (parsed File ID)
41
41
  */
42
42
  export type InputFileLike = UploadFileLike | UploadedFile | tl.TypeInputFile | tl.TypeInputMedia | tdFileId.RawFullRemoteFileLocation;
43
+ /**
44
+ * ID of an already uploaded document. Can be a:
45
+ * - `string` with a TDLib and Bot API compatible File ID
46
+ * - `td.RawFullRemoteFileLocation` (parsed File ID)
47
+ * - `tl.TypeInputDocument` (raw TL object)
48
+ */
49
+ export type InputDocumentId = string | tdFileId.RawFullRemoteFileLocation | tl.RawInputDocument;
43
50
  /**
44
51
  * File location which should be downloaded.
45
52
  * You can also provide TDLib and Bot API compatible File ID
@@ -45,7 +45,7 @@ export declare abstract class RawDocument extends FileLocation {
45
45
  * Input document TL object generated from this object,
46
46
  * to be used with methods that use it
47
47
  */
48
- get inputDocument(): tl.TypeInputDocument;
48
+ get inputDocument(): tl.RawInputDocument;
49
49
  /**
50
50
  * Input media TL object generated from this object,
51
51
  * to be used inside {@link InputMediaLike} and
@@ -45,7 +45,7 @@ export declare abstract class RawDocument extends FileLocation {
45
45
  * Input document TL object generated from this object,
46
46
  * to be used with methods that use it
47
47
  */
48
- get inputDocument(): tl.TypeInputDocument;
48
+ get inputDocument(): tl.RawInputDocument;
49
49
  /**
50
50
  * Input media TL object generated from this object,
51
51
  * to be used inside {@link InputMediaLike} and
@@ -183,9 +183,17 @@ function _messageActionFromTl(act) {
183
183
  action: act.message
184
184
  };
185
185
  case "messageActionSetChatTheme":
186
+ if (act.theme._ === "chatThemeUniqueGift") {
187
+ utils.assert(act.theme.gift._ === "starGiftUnique");
188
+ return {
189
+ type: "theme_changed_unique",
190
+ gift: new starsGiftUnique.StarGiftUnique(act.theme.gift, this._peers),
191
+ themeSettings: act.theme.themeSettings
192
+ };
193
+ }
186
194
  return {
187
195
  type: "theme_changed",
188
- emoji: act.emoticon
196
+ emoji: act.theme.emoticon
189
197
  };
190
198
  case "messageActionChatJoinedByRequest":
191
199
  return {
@@ -286,10 +294,19 @@ function _messageActionFromTl(act) {
286
294
  boostPeer: peer.parsePeer(act.boostPeer, this._peers),
287
295
  giveawayMessageId: act.giveawayMsgId
288
296
  };
297
+ // todo: cleanup in the next breaking update
289
298
  case "messageActionStarGift":
290
299
  utils.assert(act.gift._ === "starGift");
300
+ if (act.prepaidUpgrade) {
301
+ return {
302
+ type: "star_gift_upgrade_paid",
303
+ gift: new starsGift.StarGift(act.gift, this._peers),
304
+ giftMsgId: act.giftMsgId ?? void 0,
305
+ upgradeMsgId: act.upgradeMsgId ?? null
306
+ };
307
+ }
291
308
  return {
292
- type: "stars_gift",
309
+ type: "star_gift_sent",
293
310
  nameHidden: act.nameHidden,
294
311
  saved: act.saved,
295
312
  converted: act.converted,
@@ -301,33 +318,38 @@ function _messageActionFromTl(act) {
301
318
  upgraded: act.upgraded,
302
319
  upgradeStars: act.upgradeStars ?? Long.ZERO,
303
320
  upgradeMsgId: act.upgradeMsgId ?? null,
304
- fromId: act.fromId ? peerUtils.getMarkedPeerId(act.fromId) : void 0,
305
- toId: act.peer ? peerUtils.getMarkedPeerId(act.peer) : void 0,
306
- savedId: act.savedId
321
+ savedId: act.savedId,
322
+ prepaidUpgradeHash: act.prepaidUpgradeHash ?? void 0
307
323
  };
308
- case "messageActionStarGiftUnique":
324
+ case "messageActionStarGiftUnique": {
309
325
  utils.assert(act.gift._ === "starGiftUnique");
310
- return {
311
- type: "stars_gift",
312
- nameHidden: false,
326
+ const common = {
313
327
  saved: act.saved,
314
- converted: false,
315
- convertStars: Long.ZERO,
316
328
  refunded: act.refunded,
317
329
  gift: new starsGiftUnique.StarGiftUnique(act.gift, this._peers),
318
- message: null,
319
- canUpgrade: false,
320
- upgraded: true,
321
- upgradeStars: Long.ZERO,
322
- upgradeMsgId: null,
323
- canTransferSince: act.canTransferAt ? new Date(act.canTransferAt * 1e3) : void 0,
324
- resaleStars: act.resaleAmount?._ === "starsAmount" ? act.resaleAmount.amount : void 0,
325
- resaleTon: act.resaleAmount?._ === "starsTonAmount" ? act.resaleAmount.amount : void 0,
330
+ canTransferAt: act.canTransferAt ? new Date(act.canTransferAt * 1e3) : void 0,
326
331
  canResellAt: act.canResellAt ? new Date(act.canResellAt * 1e3) : void 0,
327
- fromId: act.fromId ? peerUtils.getMarkedPeerId(act.fromId) : void 0,
328
- toId: act.peer ? peerUtils.getMarkedPeerId(act.peer) : void 0,
332
+ canExportAt: act.canExportAt ? new Date(act.canExportAt * 1e3) : void 0,
329
333
  savedId: act.savedId
330
334
  };
335
+ if (act.resaleAmount) {
336
+ return {
337
+ type: "star_gift_bought_resale",
338
+ ...common,
339
+ amount: act.resaleAmount
340
+ };
341
+ }
342
+ if (act.upgrade) {
343
+ return {
344
+ type: "star_gift_upgraded",
345
+ ...common
346
+ };
347
+ }
348
+ return {
349
+ type: "star_gift_transferred",
350
+ ...common
351
+ };
352
+ }
331
353
  case "messageActionPaidMessagesPrice":
332
354
  return {
333
355
  type: "messages_paid",
@@ -2,7 +2,6 @@ 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';
6
5
  import { Photo } from '../media/photo.js';
7
6
  import { StarGiftUnique } from '../premium/stars-gift-unique.js';
8
7
  import { StarGift } from '../premium/stars-gift.js';
@@ -244,6 +243,14 @@ export interface ActionThemeChanged {
244
243
  /** Emoji representing the new theme */
245
244
  emoji: string;
246
245
  }
246
+ /** Chat theme was changed to a unique star gift based one */
247
+ export interface ActionThemeChangedUnique {
248
+ readonly type: 'theme_changed_unique';
249
+ /** Unique star gift */
250
+ gift: StarGiftUnique;
251
+ /** Theme settings */
252
+ themeSettings: tl.TypeThemeSettings[];
253
+ }
247
254
  /** Data was sent from a WebView (user-side action) */
248
255
  export interface ActionWebviewDataSent {
249
256
  readonly type: 'webview_sent';
@@ -399,8 +406,8 @@ export interface ActionStarsPrize {
399
406
  giveawayMessageId: number;
400
407
  }
401
408
  /** A star gift was sent */
402
- export interface ActionStarGift {
403
- readonly type: 'stars_gift';
409
+ export interface ActionStarGiftSent {
410
+ readonly type: 'star_gift_sent';
404
411
  /** Whether the sender chose to send the gift anonymously */
405
412
  nameHidden: boolean;
406
413
  /** Whether this gift was saved to the recipient's profile */
@@ -414,6 +421,10 @@ export interface ActionStarGift {
414
421
  * (0 if the gift cannot be converted)
415
422
  */
416
423
  convertStars: tl.Long;
424
+ /** The gift itself */
425
+ gift: StarGift;
426
+ /** Message attached to the gift */
427
+ message: TextWithEntities | null;
417
428
  /** Whether this gift can be upgraded to a unique gift */
418
429
  canUpgrade: boolean;
419
430
  /** Whether this gift was upgraded to a unique gift */
@@ -422,21 +433,50 @@ export interface ActionStarGift {
422
433
  upgradeStars: tl.Long;
423
434
  /** If the gift was upgraded, ID of the message where this happened */
424
435
  upgradeMsgId: number | null;
425
- /** If the gift can be transferred, date when it can be re-sold */
426
- canTransferSince?: Date;
427
- /** Number of stars this gift is up for resell for */
428
- resaleStars?: tl.Long;
429
- /** Number of nanoton this gift is up for resell for */
430
- resaleTon?: tl.Long;
436
+ /** ID of the related saved profile gift */
437
+ savedId?: tl.Long;
438
+ /** If available, you can pay for this gift's upgrade by passing this hash to `prepayStarGiftUpgrade` */
439
+ prepaidUpgradeHash?: string;
440
+ }
441
+ /** A star gift upgrade was paid for */
442
+ export interface ActionStarGiftUpgradePaid {
443
+ readonly type: 'star_gift_upgrade_paid';
444
+ /** The gift itself */
445
+ gift: StarGift;
446
+ /** ID of the message where the gift was upgraded */
447
+ upgradeMsgId: number | null;
448
+ /** ID of the message containing the originally sent gift, if available */
449
+ giftMsgId?: number;
450
+ }
451
+ interface StarGiftUniqueCommon {
452
+ /** Whether this gift was saved to the recipient's profile */
453
+ saved: boolean;
454
+ /** Whether this gift was refunded */
455
+ refunded: boolean;
456
+ /** The gift itself */
457
+ gift: StarGiftUnique;
458
+ /** If the gift can be transferred, date when it will become available */
459
+ canTransferAt?: Date;
431
460
  /** If the gift can be re-sold, date when it will become available */
432
461
  canResellAt?: Date;
433
- /** The gift itself */
434
- gift: StarGift | StarGiftUnique;
435
- /** Message attached to the gift */
436
- message: TextWithEntities | null;
437
- fromId?: number;
438
- toId?: number;
439
- savedId?: Long;
462
+ /** If the gift can be exported to blockchain, date when it will become available */
463
+ canExportAt?: Date;
464
+ /** ID of the related saved profile gift */
465
+ savedId?: tl.Long;
466
+ }
467
+ /** A star gift was upgraded to a unique one */
468
+ export interface ActionStarGiftUpgraded extends StarGiftUniqueCommon {
469
+ readonly type: 'star_gift_upgraded';
470
+ }
471
+ /** A star gift was bought from a resale listing */
472
+ export interface ActionStarGiftBoughtResale extends StarGiftUniqueCommon {
473
+ readonly type: 'star_gift_bought_resale';
474
+ /** Number of stars/TON that were paid for the gift */
475
+ amount: tl.TypeStarsAmount;
476
+ }
477
+ /** A star gift was transferred */
478
+ export interface ActionStarGiftTransferred extends StarGiftUniqueCommon {
479
+ readonly type: 'star_gift_transferred';
440
480
  }
441
481
  /** Paid messages were paid for */
442
482
  export interface ActionPaidMessagesPaid {
@@ -482,6 +522,7 @@ export interface ActionTonGift {
482
522
  /** Transaction ID */
483
523
  transactionId?: string;
484
524
  }
485
- 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 | ActionPaidMessagesPaid | ActionPaidMessagesRefunded | ActionTodoCompletions | ActionTodoAppendTasks | ActionTonGift | null;
525
+ 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 | ActionThemeChangedUnique | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGiftSent | ActionStarGiftUpgradePaid | ActionStarGiftUpgraded | ActionStarGiftBoughtResale | ActionStarGiftTransferred | ActionPaidMessagesPaid | ActionPaidMessagesRefunded | ActionTodoCompletions | ActionTodoAppendTasks | ActionTonGift | null;
486
526
  /** @internal */
487
527
  export declare function _messageActionFromTl(this: Message, act: tl.TypeMessageAction): MessageAction;
528
+ export {};
@@ -2,7 +2,6 @@ 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';
6
5
  import { Photo } from '../media/photo.js';
7
6
  import { StarGiftUnique } from '../premium/stars-gift-unique.js';
8
7
  import { StarGift } from '../premium/stars-gift.js';
@@ -244,6 +243,14 @@ export interface ActionThemeChanged {
244
243
  /** Emoji representing the new theme */
245
244
  emoji: string;
246
245
  }
246
+ /** Chat theme was changed to a unique star gift based one */
247
+ export interface ActionThemeChangedUnique {
248
+ readonly type: 'theme_changed_unique';
249
+ /** Unique star gift */
250
+ gift: StarGiftUnique;
251
+ /** Theme settings */
252
+ themeSettings: tl.TypeThemeSettings[];
253
+ }
247
254
  /** Data was sent from a WebView (user-side action) */
248
255
  export interface ActionWebviewDataSent {
249
256
  readonly type: 'webview_sent';
@@ -399,8 +406,8 @@ export interface ActionStarsPrize {
399
406
  giveawayMessageId: number;
400
407
  }
401
408
  /** A star gift was sent */
402
- export interface ActionStarGift {
403
- readonly type: 'stars_gift';
409
+ export interface ActionStarGiftSent {
410
+ readonly type: 'star_gift_sent';
404
411
  /** Whether the sender chose to send the gift anonymously */
405
412
  nameHidden: boolean;
406
413
  /** Whether this gift was saved to the recipient's profile */
@@ -414,6 +421,10 @@ export interface ActionStarGift {
414
421
  * (0 if the gift cannot be converted)
415
422
  */
416
423
  convertStars: tl.Long;
424
+ /** The gift itself */
425
+ gift: StarGift;
426
+ /** Message attached to the gift */
427
+ message: TextWithEntities | null;
417
428
  /** Whether this gift can be upgraded to a unique gift */
418
429
  canUpgrade: boolean;
419
430
  /** Whether this gift was upgraded to a unique gift */
@@ -422,21 +433,50 @@ export interface ActionStarGift {
422
433
  upgradeStars: tl.Long;
423
434
  /** If the gift was upgraded, ID of the message where this happened */
424
435
  upgradeMsgId: number | null;
425
- /** If the gift can be transferred, date when it can be re-sold */
426
- canTransferSince?: Date;
427
- /** Number of stars this gift is up for resell for */
428
- resaleStars?: tl.Long;
429
- /** Number of nanoton this gift is up for resell for */
430
- resaleTon?: tl.Long;
436
+ /** ID of the related saved profile gift */
437
+ savedId?: tl.Long;
438
+ /** If available, you can pay for this gift's upgrade by passing this hash to `prepayStarGiftUpgrade` */
439
+ prepaidUpgradeHash?: string;
440
+ }
441
+ /** A star gift upgrade was paid for */
442
+ export interface ActionStarGiftUpgradePaid {
443
+ readonly type: 'star_gift_upgrade_paid';
444
+ /** The gift itself */
445
+ gift: StarGift;
446
+ /** ID of the message where the gift was upgraded */
447
+ upgradeMsgId: number | null;
448
+ /** ID of the message containing the originally sent gift, if available */
449
+ giftMsgId?: number;
450
+ }
451
+ interface StarGiftUniqueCommon {
452
+ /** Whether this gift was saved to the recipient's profile */
453
+ saved: boolean;
454
+ /** Whether this gift was refunded */
455
+ refunded: boolean;
456
+ /** The gift itself */
457
+ gift: StarGiftUnique;
458
+ /** If the gift can be transferred, date when it will become available */
459
+ canTransferAt?: Date;
431
460
  /** If the gift can be re-sold, date when it will become available */
432
461
  canResellAt?: Date;
433
- /** The gift itself */
434
- gift: StarGift | StarGiftUnique;
435
- /** Message attached to the gift */
436
- message: TextWithEntities | null;
437
- fromId?: number;
438
- toId?: number;
439
- savedId?: Long;
462
+ /** If the gift can be exported to blockchain, date when it will become available */
463
+ canExportAt?: Date;
464
+ /** ID of the related saved profile gift */
465
+ savedId?: tl.Long;
466
+ }
467
+ /** A star gift was upgraded to a unique one */
468
+ export interface ActionStarGiftUpgraded extends StarGiftUniqueCommon {
469
+ readonly type: 'star_gift_upgraded';
470
+ }
471
+ /** A star gift was bought from a resale listing */
472
+ export interface ActionStarGiftBoughtResale extends StarGiftUniqueCommon {
473
+ readonly type: 'star_gift_bought_resale';
474
+ /** Number of stars/TON that were paid for the gift */
475
+ amount: tl.TypeStarsAmount;
476
+ }
477
+ /** A star gift was transferred */
478
+ export interface ActionStarGiftTransferred extends StarGiftUniqueCommon {
479
+ readonly type: 'star_gift_transferred';
440
480
  }
441
481
  /** Paid messages were paid for */
442
482
  export interface ActionPaidMessagesPaid {
@@ -482,6 +522,7 @@ export interface ActionTonGift {
482
522
  /** Transaction ID */
483
523
  transactionId?: string;
484
524
  }
485
- 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 | ActionPaidMessagesPaid | ActionPaidMessagesRefunded | ActionTodoCompletions | ActionTodoAppendTasks | ActionTonGift | null;
525
+ 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 | ActionThemeChangedUnique | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGiftSent | ActionStarGiftUpgradePaid | ActionStarGiftUpgraded | ActionStarGiftBoughtResale | ActionStarGiftTransferred | ActionPaidMessagesPaid | ActionPaidMessagesRefunded | ActionTodoCompletions | ActionTodoAppendTasks | ActionTonGift | null;
486
526
  /** @internal */
487
527
  export declare function _messageActionFromTl(this: Message, act: tl.TypeMessageAction): MessageAction;
528
+ export {};