@mtcute/core 0.21.1 → 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 (143) hide show
  1. package/client.cjs +13 -8
  2. package/client.js +13 -8
  3. package/highlevel/client.d.cts +27 -49
  4. package/highlevel/client.d.ts +27 -49
  5. package/highlevel/methods/auth/sign-in-qr.cjs +4 -4
  6. package/highlevel/methods/files/download-iterable.cjs +25 -0
  7. package/highlevel/methods/files/download-iterable.js +25 -0
  8. package/highlevel/methods/files/upload-file.js +1 -1
  9. package/highlevel/methods/messages/forward-messages.cjs +2 -1
  10. package/highlevel/methods/messages/forward-messages.d.cts +6 -0
  11. package/highlevel/methods/messages/forward-messages.d.ts +6 -0
  12. package/highlevel/methods/messages/forward-messages.js +2 -1
  13. package/highlevel/methods/messages/get-web-page-preview.cjs +22 -0
  14. package/highlevel/methods/messages/get-web-page-preview.d.cts +9 -0
  15. package/highlevel/methods/messages/get-web-page-preview.d.ts +9 -0
  16. package/highlevel/methods/messages/get-web-page-preview.js +17 -0
  17. package/highlevel/methods/messages/send-common.d.cts +5 -0
  18. package/highlevel/methods/messages/send-common.d.ts +5 -0
  19. package/highlevel/methods/messages/send-media-group.cjs +2 -1
  20. package/highlevel/methods/messages/send-media-group.js +2 -1
  21. package/highlevel/methods/messages/send-media.cjs +2 -1
  22. package/highlevel/methods/messages/send-media.js +2 -1
  23. package/highlevel/methods/messages/send-text.cjs +2 -1
  24. package/highlevel/methods/messages/send-text.js +2 -1
  25. package/highlevel/methods/premium/pin-star-gift.cjs +24 -0
  26. package/highlevel/methods/premium/pin-star-gift.d.cts +13 -0
  27. package/highlevel/methods/premium/pin-star-gift.d.ts +13 -0
  28. package/highlevel/methods/premium/pin-star-gift.js +19 -0
  29. package/highlevel/methods/{premium/get-star-gifts.cjs → users/get-peer-settings.cjs} +10 -6
  30. package/highlevel/methods/users/get-peer-settings.d.cts +4 -0
  31. package/highlevel/methods/users/get-peer-settings.d.ts +4 -0
  32. package/highlevel/methods/users/get-peer-settings.js +14 -0
  33. package/highlevel/methods/users/resolve-peer.cjs +16 -31
  34. package/highlevel/methods/users/resolve-peer.js +7 -22
  35. package/highlevel/methods.d.cts +3 -2
  36. package/highlevel/methods.d.ts +3 -2
  37. package/highlevel/storage/repository/peers.d.cts +2 -3
  38. package/highlevel/storage/repository/peers.d.ts +2 -3
  39. package/highlevel/storage/service/peers.cjs +10 -4
  40. package/highlevel/storage/service/peers.d.cts +1 -0
  41. package/highlevel/storage/service/peers.d.ts +1 -0
  42. package/highlevel/storage/service/peers.js +10 -4
  43. package/highlevel/types/bots/keyboards/factories.cjs +4 -4
  44. package/highlevel/types/media/document.cjs +1 -1
  45. package/highlevel/types/media/document.js +1 -1
  46. package/highlevel/types/media/web-page.cjs +40 -3
  47. package/highlevel/types/media/web-page.d.cts +23 -1
  48. package/highlevel/types/media/web-page.d.ts +23 -1
  49. package/highlevel/types/media/web-page.js +41 -4
  50. package/highlevel/types/messages/message-media.cjs +1 -1
  51. package/highlevel/types/messages/message-media.d.cts +2 -2
  52. package/highlevel/types/messages/message-media.d.ts +2 -2
  53. package/highlevel/types/messages/message-media.js +2 -2
  54. package/highlevel/types/messages/message.cjs +4 -0
  55. package/highlevel/types/messages/message.d.cts +2 -0
  56. package/highlevel/types/messages/message.d.ts +2 -0
  57. package/highlevel/types/messages/message.js +4 -0
  58. package/highlevel/types/peers/chat-event/actions.cjs +5 -0
  59. package/highlevel/types/peers/chat-event/actions.js +5 -0
  60. package/highlevel/types/peers/chat.cjs +4 -0
  61. package/highlevel/types/peers/chat.d.cts +2 -0
  62. package/highlevel/types/peers/chat.d.ts +2 -0
  63. package/highlevel/types/peers/chat.js +4 -0
  64. package/highlevel/types/peers/full-chat.cjs +4 -0
  65. package/highlevel/types/peers/full-chat.d.cts +2 -0
  66. package/highlevel/types/peers/full-chat.d.ts +2 -0
  67. package/highlevel/types/peers/full-chat.js +4 -0
  68. package/highlevel/types/peers/index.d.cts +1 -0
  69. package/highlevel/types/peers/index.d.ts +1 -0
  70. package/highlevel/types/peers/peer-settings.cjs +101 -0
  71. package/highlevel/types/peers/peer-settings.d.cts +84 -0
  72. package/highlevel/types/peers/peer-settings.d.ts +84 -0
  73. package/highlevel/types/peers/peer-settings.js +96 -0
  74. package/highlevel/types/peers/user.cjs +4 -0
  75. package/highlevel/types/peers/user.d.cts +2 -0
  76. package/highlevel/types/peers/user.d.ts +2 -0
  77. package/highlevel/types/peers/user.js +4 -0
  78. package/highlevel/types/premium/saved-star-gift.cjs +4 -1
  79. package/highlevel/types/premium/saved-star-gift.d.cts +2 -3
  80. package/highlevel/types/premium/saved-star-gift.d.ts +2 -3
  81. package/highlevel/types/premium/saved-star-gift.js +5 -2
  82. package/highlevel/types/premium/stars-transaction.cjs +14 -0
  83. package/highlevel/types/premium/stars-transaction.d.cts +14 -0
  84. package/highlevel/types/premium/stars-transaction.d.ts +14 -0
  85. package/highlevel/types/premium/stars-transaction.js +14 -0
  86. package/highlevel/types/stories/story-viewer.cjs +1 -1
  87. package/highlevel/types/stories/story-viewer.js +1 -1
  88. package/highlevel/types/updates/history-read-update.cjs +1 -0
  89. package/highlevel/types/updates/history-read-update.js +1 -0
  90. package/highlevel/updates/manager.js +2 -2
  91. package/highlevel/utils/file-utils.js +1 -1
  92. package/highlevel/utils/inline-utils.cjs +5 -5
  93. package/highlevel/utils/inline-utils.js +1 -1
  94. package/highlevel/worker/storage.cjs +2 -0
  95. package/highlevel/worker/storage.d.cts +1 -0
  96. package/highlevel/worker/storage.d.ts +1 -0
  97. package/highlevel/worker/storage.js +2 -0
  98. package/index.cjs +3 -1
  99. package/index.js +5 -3
  100. package/methods.cjs +6 -4
  101. package/methods.js +6 -4
  102. package/network/authorization.js +2 -2
  103. package/network/network-manager.cjs +1 -1
  104. package/network/network-manager.js +1 -1
  105. package/network/persistent-connection.cjs +6 -4
  106. package/network/persistent-connection.js +6 -4
  107. package/network/session-connection.cjs +14 -7
  108. package/network/session-connection.d.cts +1 -1
  109. package/network/session-connection.d.ts +1 -1
  110. package/network/session-connection.js +15 -8
  111. package/package.json +4 -4
  112. package/storage/memory/repository/peers.cjs +2 -2
  113. package/storage/memory/repository/peers.d.cts +1 -1
  114. package/storage/memory/repository/peers.d.ts +1 -1
  115. package/storage/memory/repository/peers.js +2 -2
  116. package/storage/sqlite/repository/peers.cjs +3 -5
  117. package/storage/sqlite/repository/peers.d.cts +1 -2
  118. package/storage/sqlite/repository/peers.d.ts +1 -2
  119. package/storage/sqlite/repository/peers.js +3 -5
  120. package/utils/binary/asn1-parser.js +1 -1
  121. package/utils/binary/compat.cjs +150 -0
  122. package/utils/binary/compat.d.cts +13 -0
  123. package/utils/binary/compat.d.ts +13 -0
  124. package/utils/binary/compat.js +145 -0
  125. package/utils/binary/compat.test.d.cts +1 -0
  126. package/utils/binary/compat.test.d.ts +1 -0
  127. package/utils/binary/serialization.cjs +59 -0
  128. package/utils/binary/serialization.d.cts +10 -0
  129. package/utils/binary/serialization.d.ts +10 -0
  130. package/utils/binary/serialization.js +54 -0
  131. package/utils/index.d.cts +2 -0
  132. package/utils/index.d.ts +2 -0
  133. package/utils/long-utils.js +1 -1
  134. package/utils/peer-utils.js +1 -1
  135. package/utils.cjs +8 -0
  136. package/utils.js +8 -0
  137. package/highlevel/methods/premium/get-star-gifts.d.cts +0 -23
  138. package/highlevel/methods/premium/get-star-gifts.d.ts +0 -23
  139. package/highlevel/methods/premium/get-star-gifts.js +0 -10
  140. package/highlevel/methods/premium/iter-star-gifts.cjs +0 -29
  141. package/highlevel/methods/premium/iter-star-gifts.d.cts +0 -26
  142. package/highlevel/methods/premium/iter-star-gifts.d.ts +0 -26
  143. package/highlevel/methods/premium/iter-star-gifts.js +0 -24
@@ -0,0 +1,84 @@
1
+ import { tl } from '@mtcute/tl';
2
+ import { PeersIndex } from './peers-index.js';
3
+ import { User } from './user.js';
4
+ /**
5
+ * Action bar that should be displayed in the chat with the user,
6
+ * containing the suggested actions to do with the user.
7
+ */
8
+ export type ChatActionBar = {
9
+ /** The user is an administrator of a chat to which we sent a join request */
10
+ type: 'join_request';
11
+ /** Title of the chat */
12
+ chatTitle: string;
13
+ /** Whether the chat is a broadcast channel */
14
+ isBroadcast: boolean;
15
+ /** Date when the join request was sent */
16
+ requestDate: Date;
17
+ } | {
18
+ /** The chat is a recently created group chat to which new members are suggested to be invited */
19
+ type: 'invite_members';
20
+ } | {
21
+ /**
22
+ * The chat is with a user, and adding them to contacts is suggested
23
+ * (normally this happens when they added us to their contacts)
24
+ */
25
+ type: 'add_contact';
26
+ /** Whether we will need to explicitly share phone number with the user when adding them to contacts */
27
+ needPhoneNumberPrivacyException: boolean;
28
+ } | {
29
+ /**
30
+ * The chat is with a user, and sharing a phone number with them is suggested
31
+ * (normally this happens when they shared their phone number with us)
32
+ */
33
+ type: 'share_phone_number';
34
+ } | {
35
+ /** This chat is with a new user who is not in our contacts, and either adding them to contacts or block+report-ing them is suggested */
36
+ type: 'add_or_report';
37
+ /** Whether we can report this user for spamming */
38
+ canReportSpam?: boolean;
39
+ /** Whether this chat was automatically archived and we can unarchive it */
40
+ canUnarchive: boolean;
41
+ } | {
42
+ /** This chat is managed with a business bot */
43
+ type: 'business_bot';
44
+ /** The business bot that manages this chat */
45
+ bot: User;
46
+ /** Deep link to the bot's management menu */
47
+ manageUrl: string;
48
+ };
49
+ export declare class PeerSettings {
50
+ readonly raw: tl.RawPeerSettings;
51
+ readonly _peers?: PeersIndex | undefined;
52
+ constructor(raw: tl.RawPeerSettings, _peers?: PeersIndex | undefined);
53
+ /** Action bar that should be displayed in the chat with the user */
54
+ get actionBar(): ChatActionBar | null;
55
+ /** Distance in meters between us and the user */
56
+ get geoDistance(): number | null;
57
+ /**
58
+ * Price of paid messages to this peer for the current user
59
+ * (note that this might differ from {@link User.paidMessagePrice},
60
+ * because the user might have added us to their contacts or wrote first,
61
+ * in which case the messages are free regardless)
62
+ */
63
+ get paidMessagePrice(): tl.Long | null;
64
+ /**
65
+ * Month and year when the user registered.
66
+ * Only available for users who contacted us first.
67
+ */
68
+ get registrationDate(): string | null;
69
+ /**
70
+ * ISO country code of the user's phone number.
71
+ * Only available for users who contacted us first.
72
+ */
73
+ get phoneCountry(): string | null;
74
+ /**
75
+ * Date when the user has last changed their name.
76
+ * Only available for users who contacted us first.
77
+ */
78
+ get nameChangeDate(): Date | null;
79
+ /**
80
+ * Date when the user has last changed their photo.
81
+ * Only available for users who contacted us first.
82
+ */
83
+ get photoChangeDate(): Date | null;
84
+ }
@@ -0,0 +1,96 @@
1
+ import { makeInspectable } from "../../utils/inspectable.js";
2
+ import { memoizeGetters } from "../../utils/memoize.js";
3
+ import { User as User$2 } from "./user.js";
4
+ class PeerSettings {
5
+ constructor(raw, _peers) {
6
+ this.raw = raw;
7
+ this._peers = _peers;
8
+ }
9
+ /** Action bar that should be displayed in the chat with the user */
10
+ get actionBar() {
11
+ if (this.raw.requestChatTitle) {
12
+ return {
13
+ type: "join_request",
14
+ chatTitle: this.raw.requestChatTitle,
15
+ isBroadcast: this.raw.requestChatBroadcast,
16
+ requestDate: new Date(this.raw.requestChatDate ?? 0)
17
+ };
18
+ }
19
+ if (this.raw.reportGeo) {
20
+ return null;
21
+ }
22
+ if (this.raw.inviteMembers) {
23
+ return { type: "invite_members" };
24
+ }
25
+ if (this.raw.shareContact) {
26
+ return { type: "share_phone_number" };
27
+ }
28
+ if (this.raw.blockContact || this.raw.reportSpam) {
29
+ return {
30
+ type: "add_or_report",
31
+ canReportSpam: this.raw.reportSpam,
32
+ canUnarchive: this.raw.autoarchived
33
+ };
34
+ }
35
+ if (this.raw.addContact) {
36
+ return {
37
+ type: "add_contact",
38
+ needPhoneNumberPrivacyException: this.raw.needContactsException
39
+ };
40
+ }
41
+ if (this.raw.businessBotId && this._peers) {
42
+ return {
43
+ type: "business_bot",
44
+ bot: new User$2(this._peers.user(this.raw.businessBotId)),
45
+ manageUrl: this.raw.businessBotManageUrl ?? ""
46
+ };
47
+ }
48
+ return null;
49
+ }
50
+ /** Distance in meters between us and the user */
51
+ get geoDistance() {
52
+ return this.raw.geoDistance ?? null;
53
+ }
54
+ /**
55
+ * Price of paid messages to this peer for the current user
56
+ * (note that this might differ from {@link User.paidMessagePrice},
57
+ * because the user might have added us to their contacts or wrote first,
58
+ * in which case the messages are free regardless)
59
+ */
60
+ get paidMessagePrice() {
61
+ return this.raw.chargePaidMessageStars ?? null;
62
+ }
63
+ /**
64
+ * Month and year when the user registered.
65
+ * Only available for users who contacted us first.
66
+ */
67
+ get registrationDate() {
68
+ return this.raw.registrationMonth ?? null;
69
+ }
70
+ /**
71
+ * ISO country code of the user's phone number.
72
+ * Only available for users who contacted us first.
73
+ */
74
+ get phoneCountry() {
75
+ return this.raw.phoneCountry ?? null;
76
+ }
77
+ /**
78
+ * Date when the user has last changed their name.
79
+ * Only available for users who contacted us first.
80
+ */
81
+ get nameChangeDate() {
82
+ return this.raw.nameChangeDate ? new Date(this.raw.nameChangeDate * 1e3) : null;
83
+ }
84
+ /**
85
+ * Date when the user has last changed their photo.
86
+ * Only available for users who contacted us first.
87
+ */
88
+ get photoChangeDate() {
89
+ return this.raw.photoChangeDate ? new Date(this.raw.photoChangeDate * 1e3) : null;
90
+ }
91
+ }
92
+ const PeerSettings$1 = /* @__PURE__ */ makeInspectable(PeerSettings);
93
+ const PeerSettings$2 = /* @__PURE__ */ memoizeGetters(PeerSettings$1, ["actionBar"]);
94
+ export {
95
+ PeerSettings$2 as PeerSettings
96
+ };
@@ -370,6 +370,10 @@ class User {
370
370
  get profileColors() {
371
371
  return this.raw.profileColor ? new chatColors.ChatColors(this.raw.id, this.raw.profileColor) : null;
372
372
  }
373
+ /** If this user has paid messages enabled, price of one message in stars */
374
+ get paidMessagePrice() {
375
+ return this.raw.sendPaidMessagesStars ?? null;
376
+ }
373
377
  /**
374
378
  * Create a mention for the user.
375
379
  *
@@ -212,6 +212,8 @@ export declare class User {
212
212
  * If `null`, a generic header should be used instead
213
213
  */
214
214
  get profileColors(): ChatColors | null;
215
+ /** If this user has paid messages enabled, price of one message in stars */
216
+ get paidMessagePrice(): tl.Long | null;
215
217
  /**
216
218
  * Create a mention for the user.
217
219
  *
@@ -212,6 +212,8 @@ export declare class User {
212
212
  * If `null`, a generic header should be used instead
213
213
  */
214
214
  get profileColors(): ChatColors | null;
215
+ /** If this user has paid messages enabled, price of one message in stars */
216
+ get paidMessagePrice(): tl.Long | null;
215
217
  /**
216
218
  * Create a mention for the user.
217
219
  *
@@ -363,6 +363,10 @@ class User {
363
363
  get profileColors() {
364
364
  return this.raw.profileColor ? new ChatColors$1(this.raw.id, this.raw.profileColor) : null;
365
365
  }
366
+ /** If this user has paid messages enabled, price of one message in stars */
367
+ get paidMessagePrice() {
368
+ return this.raw.sendPaidMessagesStars ?? null;
369
+ }
366
370
  /**
367
371
  * Create a mention for the user.
368
372
  *
@@ -27,6 +27,10 @@ class SavedStarGift {
27
27
  get refunded() {
28
28
  return this.raw.refunded;
29
29
  }
30
+ /** Whether this gift is pinned to the top of the list */
31
+ get pinned() {
32
+ return this.raw.pinnedToTop;
33
+ }
30
34
  /** Whether this gift can be upgraded to a unique gift */
31
35
  get canUpgrade() {
32
36
  return this.raw.canUpgrade;
@@ -78,4 +82,3 @@ class SavedStarGift {
78
82
  const SavedStarGift$1 = /* @__PURE__ */ inspectable.makeInspectable(SavedStarGift);
79
83
  const SavedStarGift$2 = /* @__PURE__ */ memoize.memoizeGetters(SavedStarGift$1, ["sender", "gift"]);
80
84
  exports.SavedStarGift = SavedStarGift$2;
81
- exports.UserStarGift = SavedStarGift;
@@ -14,6 +14,8 @@ export declare class SavedStarGift {
14
14
  get unsaved(): boolean;
15
15
  /** Whether this gift was refunded */
16
16
  get refunded(): boolean;
17
+ /** Whether this gift is pinned to the top of the list */
18
+ get pinned(): boolean;
17
19
  /** Whether this gift can be upgraded to a unique gift */
18
20
  get canUpgrade(): boolean;
19
21
  /** Sender of the gift */
@@ -37,6 +39,3 @@ export declare class SavedStarGift {
37
39
  /** Date when the gift can be exported to blockchain */
38
40
  get canExportAt(): Date | null;
39
41
  }
40
- export {
41
- /** @deprecated alias for {@link SavedStarGift} */
42
- SavedStarGift as UserStarGift, };
@@ -14,6 +14,8 @@ export declare class SavedStarGift {
14
14
  get unsaved(): boolean;
15
15
  /** Whether this gift was refunded */
16
16
  get refunded(): boolean;
17
+ /** Whether this gift is pinned to the top of the list */
18
+ get pinned(): boolean;
17
19
  /** Whether this gift can be upgraded to a unique gift */
18
20
  get canUpgrade(): boolean;
19
21
  /** Sender of the gift */
@@ -37,6 +39,3 @@ export declare class SavedStarGift {
37
39
  /** Date when the gift can be exported to blockchain */
38
40
  get canExportAt(): Date | null;
39
41
  }
40
- export {
41
- /** @deprecated alias for {@link SavedStarGift} */
42
- SavedStarGift as UserStarGift, };
@@ -20,6 +20,10 @@ class SavedStarGift {
20
20
  get refunded() {
21
21
  return this.raw.refunded;
22
22
  }
23
+ /** Whether this gift is pinned to the top of the list */
24
+ get pinned() {
25
+ return this.raw.pinnedToTop;
26
+ }
23
27
  /** Whether this gift can be upgraded to a unique gift */
24
28
  get canUpgrade() {
25
29
  return this.raw.canUpgrade;
@@ -71,6 +75,5 @@ class SavedStarGift {
71
75
  const SavedStarGift$1 = /* @__PURE__ */ makeInspectable(SavedStarGift);
72
76
  const SavedStarGift$2 = /* @__PURE__ */ memoizeGetters(SavedStarGift$1, ["sender", "gift"]);
73
77
  export {
74
- SavedStarGift$2 as SavedStarGift,
75
- SavedStarGift as UserStarGift
78
+ SavedStarGift$2 as SavedStarGift
76
79
  };
@@ -96,6 +96,20 @@ class StarsTransaction {
96
96
  messageId: this.raw.giveawayPostId
97
97
  };
98
98
  }
99
+ if (this.raw.paidMessages) {
100
+ return {
101
+ type: "paid_message",
102
+ peer: peer$1,
103
+ count: this.raw.paidMessages
104
+ };
105
+ }
106
+ if (this.raw.premiumGiftMonths) {
107
+ return {
108
+ type: "premium_gift",
109
+ peer: peer$1,
110
+ months: this.raw.premiumGiftMonths
111
+ };
112
+ }
99
113
  if (this.raw.stargift) {
100
114
  if (this.raw.stargift._ === "starGift") {
101
115
  return {
@@ -21,6 +21,8 @@ import { StarGift } from './stars-gift.js';
21
21
  * - `star_gift`: This transaction is either a star gift to a user (if outgoing), or converting a star gift to stars (if incoming)
22
22
  * - `star_gift_upgrade`: This transaction is for a star gift upgrade
23
23
  * - `star_gift_transfer`: This transaction is for a star gift transfer
24
+ * - `paid_message`: This transaction is a payment for a paid message
25
+ * - `premium_gift`: This transaction is a payment for a premium gift to a user
24
26
  * - `api_*`: This transaction is a payment for paid API features
25
27
  * - `api_floodskip`: This transaction is a payment for a paid bot broadcast
26
28
  */
@@ -123,6 +125,18 @@ export type StarsTransactionType = {
123
125
  recepient: Peer;
124
126
  /** The upgraded gift */
125
127
  gift: StarGiftUnique;
128
+ } | {
129
+ type: 'paid_message';
130
+ /** Related peer */
131
+ peer: Peer;
132
+ /** The number of messages paid for */
133
+ count: number;
134
+ } | {
135
+ type: 'premium_gift';
136
+ /** Related peer */
137
+ peer: Peer;
138
+ /** Number of months paid for */
139
+ months: number;
126
140
  } | {
127
141
  type: 'api_floodskip';
128
142
  /** The number of billed API calls */
@@ -21,6 +21,8 @@ import { StarGift } from './stars-gift.js';
21
21
  * - `star_gift`: This transaction is either a star gift to a user (if outgoing), or converting a star gift to stars (if incoming)
22
22
  * - `star_gift_upgrade`: This transaction is for a star gift upgrade
23
23
  * - `star_gift_transfer`: This transaction is for a star gift transfer
24
+ * - `paid_message`: This transaction is a payment for a paid message
25
+ * - `premium_gift`: This transaction is a payment for a premium gift to a user
24
26
  * - `api_*`: This transaction is a payment for paid API features
25
27
  * - `api_floodskip`: This transaction is a payment for a paid bot broadcast
26
28
  */
@@ -123,6 +125,18 @@ export type StarsTransactionType = {
123
125
  recepient: Peer;
124
126
  /** The upgraded gift */
125
127
  gift: StarGiftUnique;
128
+ } | {
129
+ type: 'paid_message';
130
+ /** Related peer */
131
+ peer: Peer;
132
+ /** The number of messages paid for */
133
+ count: number;
134
+ } | {
135
+ type: 'premium_gift';
136
+ /** Related peer */
137
+ peer: Peer;
138
+ /** Number of months paid for */
139
+ months: number;
126
140
  } | {
127
141
  type: 'api_floodskip';
128
142
  /** The number of billed API calls */
@@ -89,6 +89,20 @@ class StarsTransaction {
89
89
  messageId: this.raw.giveawayPostId
90
90
  };
91
91
  }
92
+ if (this.raw.paidMessages) {
93
+ return {
94
+ type: "paid_message",
95
+ peer,
96
+ count: this.raw.paidMessages
97
+ };
98
+ }
99
+ if (this.raw.premiumGiftMonths) {
100
+ return {
101
+ type: "premium_gift",
102
+ peer,
103
+ months: this.raw.premiumGiftMonths
104
+ };
105
+ }
92
106
  if (this.raw.stargift) {
93
107
  if (this.raw.stargift._ === "starGift") {
94
108
  return {
@@ -8,9 +8,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const errors = require("../../../types/errors.cjs");
9
9
  const memoize = require("../../utils/memoize.cjs");
10
10
  const story = require("./story.cjs");
11
+ const inspectable = require("../../utils/inspectable.cjs");
11
12
  const message = require("../messages/message.cjs");
12
13
  const peer = require("../peers/peer.cjs");
13
- const inspectable = require("../../utils/inspectable.cjs");
14
14
  const types = require("../reactions/types.cjs");
15
15
  const user = require("../peers/user.cjs");
16
16
  const peersIndex = require("../peers/peers-index.cjs");
@@ -1,9 +1,9 @@
1
1
  import { MtTypeAssertionError } from "../../../types/errors.js";
2
2
  import { memoizeGetters } from "../../utils/memoize.js";
3
3
  import { Story as Story$2 } from "./story.js";
4
+ import { makeInspectable } from "../../utils/inspectable.js";
4
5
  import { Message as Message$2 } from "../messages/message.js";
5
6
  import { parsePeer } from "../peers/peer.js";
6
- import { makeInspectable } from "../../utils/inspectable.js";
7
7
  import { toReactionEmoji } from "../reactions/types.js";
8
8
  import { User as User$2 } from "../peers/user.js";
9
9
  import { PeersIndex } from "../peers/peers-index.js";
@@ -64,6 +64,7 @@ class HistoryReadUpdate {
64
64
  case "updateReadHistoryInbox":
65
65
  case "updateReadChannelInbox":
66
66
  return this.raw.stillUnreadCount;
67
+ // `updateReadChannelDiscussionInbox` does not contain that data for some reason
67
68
  case "updateReadChannelDiscussionInbox":
68
69
  case "updateReadHistoryOutbox":
69
70
  case "updateReadChannelOutbox":
@@ -57,6 +57,7 @@ class HistoryReadUpdate {
57
57
  case "updateReadHistoryInbox":
58
58
  case "updateReadChannelInbox":
59
59
  return this.raw.stillUnreadCount;
60
+ // `updateReadChannelDiscussionInbox` does not contain that data for some reason
60
61
  case "updateReadChannelDiscussionInbox":
61
62
  case "updateReadHistoryOutbox":
62
63
  case "updateReadChannelOutbox":
@@ -5,12 +5,12 @@ import { MtArgumentError } from "../../types/errors.js";
5
5
  import { assertNever } from "../../types/utils.js";
6
6
  import { EarlyTimer } from "../../utils/early-timer.js";
7
7
  import { SortedLinkedList } from "../../utils/linked-list.js";
8
- import { parseMarkedPeerId, getBarePeerId, getMarkedPeerId, toggleChannelIdMark } from "../../utils/peer-utils.js";
8
+ import { toggleChannelIdMark, parseMarkedPeerId, getBarePeerId, getMarkedPeerId } from "../../utils/peer-utils.js";
9
9
  import "@mtcute/tl-runtime";
10
10
  import { _getChannelsBatched } from "../methods/chats/batched-queries.js";
11
11
  import { PeersIndex } from "../types/peers/peers-index.js";
12
12
  import { RawUpdateInfo } from "./types.js";
13
- import { extractChannelIdFromUpdate, toPendingUpdate, messageToUpdate, isMessageEmpty, createDummyUpdatesContainer } from "./utils.js";
13
+ import { toPendingUpdate, messageToUpdate, isMessageEmpty, createDummyUpdatesContainer, extractChannelIdFromUpdate } from "./utils.js";
14
14
  import { toInputChannel } from "../utils/peer-utils.js";
15
15
  const KEEP_ALIVE_INTERVAL = 15 * 60 * 1e3;
16
16
  const UPDATES_TOO_LONG = { _: "updatesTooLong" };
@@ -1,4 +1,4 @@
1
- import { hex, u8, utf8 } from "@fuman/utils";
1
+ import { u8, utf8, hex } from "@fuman/utils";
2
2
  import { MtArgumentError } from "../../types/errors.js";
3
3
  function determinePartSize(fileSize) {
4
4
  if (fileSize <= 262078465) return 128;
@@ -5,11 +5,11 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
5
5
  }
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
- const utils$1 = require("@fuman/utils");
8
+ const utils = require("@fuman/utils");
9
9
  const tlRuntime = require("@mtcute/tl-runtime");
10
- const utils = require("../../types/utils.cjs");
10
+ const utils$1 = require("../../types/utils.cjs");
11
11
  function parseInlineMessageId(id) {
12
- const buf = utils$1.base64.decode(id, true);
12
+ const buf = utils.base64.decode(id, true);
13
13
  const reader = tlRuntime.TlBinaryReader.manual(buf);
14
14
  if (buf.length === 20) {
15
15
  return {
@@ -44,9 +44,9 @@ function encodeInlineMessageId(id) {
44
44
  writer.long(id.accessHash);
45
45
  break;
46
46
  default:
47
- utils.assertNever();
47
+ utils$1.assertNever();
48
48
  }
49
- return utils$1.base64.encode(writer.result(), true);
49
+ return utils.base64.encode(writer.result(), true);
50
50
  }
51
51
  function normalizeInlineId(id) {
52
52
  if (typeof id === "string") {
@@ -1,5 +1,5 @@
1
1
  import { base64 } from "@fuman/utils";
2
- import { TlBinaryWriter, TlBinaryReader } from "@mtcute/tl-runtime";
2
+ import { TlBinaryReader, TlBinaryWriter } from "@mtcute/tl-runtime";
3
3
  import { assertNever } from "../../types/utils.js";
4
4
  function parseInlineMessageId(id) {
5
5
  const buf = base64.decode(id, true);
@@ -54,6 +54,7 @@ class PeersServiceProxy {
54
54
  this.getByPhone = bind("getByPhone");
55
55
  this.getByUsername = bind("getByUsername");
56
56
  this.getCompleteById = bind("getCompleteById");
57
+ this.getMinAccessHash = bind("getMinAccessHash");
57
58
  }
58
59
  updatePeersFrom;
59
60
  store;
@@ -61,6 +62,7 @@ class PeersServiceProxy {
61
62
  getByPhone;
62
63
  getByUsername;
63
64
  getCompleteById;
65
+ getMinAccessHash;
64
66
  }
65
67
  class TelegramStorageProxy {
66
68
  constructor(_invoker) {
@@ -25,6 +25,7 @@ declare class PeersServiceProxy implements PublicPart<PeersService> {
25
25
  readonly getByPhone: PeersService['getByPhone'];
26
26
  readonly getByUsername: PeersService['getByUsername'];
27
27
  readonly getCompleteById: PeersService['getCompleteById'];
28
+ readonly getMinAccessHash: PeersService['getMinAccessHash'];
28
29
  constructor(_invoker: WorkerInvoker);
29
30
  }
30
31
  export declare class TelegramStorageProxy implements PublicPart<TelegramStorageManager> {
@@ -25,6 +25,7 @@ declare class PeersServiceProxy implements PublicPart<PeersService> {
25
25
  readonly getByPhone: PeersService['getByPhone'];
26
26
  readonly getByUsername: PeersService['getByUsername'];
27
27
  readonly getCompleteById: PeersService['getCompleteById'];
28
+ readonly getMinAccessHash: PeersService['getMinAccessHash'];
28
29
  constructor(_invoker: WorkerInvoker);
29
30
  }
30
31
  export declare class TelegramStorageProxy implements PublicPart<TelegramStorageManager> {
@@ -47,6 +47,7 @@ class PeersServiceProxy {
47
47
  this.getByPhone = bind("getByPhone");
48
48
  this.getByUsername = bind("getByUsername");
49
49
  this.getCompleteById = bind("getCompleteById");
50
+ this.getMinAccessHash = bind("getMinAccessHash");
50
51
  }
51
52
  updatePeersFrom;
52
53
  store;
@@ -54,6 +55,7 @@ class PeersServiceProxy {
54
55
  getByPhone;
55
56
  getByUsername;
56
57
  getCompleteById;
58
+ getMinAccessHash;
57
59
  }
58
60
  class TelegramStorageProxy {
59
61
  constructor(_invoker) {
package/index.cjs CHANGED
@@ -77,6 +77,7 @@ const chatlistPreview = require("./highlevel/types/peers/chatlist-preview.cjs");
77
77
  const forumTopic = require("./highlevel/types/peers/forum-topic.cjs");
78
78
  const fullChat = require("./highlevel/types/peers/full-chat.cjs");
79
79
  const fullUser = require("./highlevel/types/peers/full-user.cjs");
80
+ const peerSettings = require("./highlevel/types/peers/peer-settings.cjs");
80
81
  const peer = require("./highlevel/types/peers/peer.cjs");
81
82
  const peersIndex = require("./highlevel/types/peers/peers-index.cjs");
82
83
  const user = require("./highlevel/types/peers/user.cjs");
@@ -205,6 +206,7 @@ exports.Venue = venue.Venue;
205
206
  exports.Video = video.Video;
206
207
  exports.Voice = voice.Voice;
207
208
  exports.WebPage = webPage.WebPage;
209
+ exports.WebPageMedia = webPage.WebPageMedia;
208
210
  exports.Dialog = dialog.Dialog;
209
211
  exports.DraftMessage = draftMessage.DraftMessage;
210
212
  exports.FactCheck = factCheck.FactCheck;
@@ -243,6 +245,7 @@ exports.ChatlistPreview = chatlistPreview.ChatlistPreview;
243
245
  exports.ForumTopic = forumTopic.ForumTopic;
244
246
  exports.FullChat = fullChat.FullChat;
245
247
  exports.FullUser = fullUser.FullUser;
248
+ exports.PeerSettings = peerSettings.PeerSettings;
246
249
  exports.parsePeer = peer.parsePeer;
247
250
  exports.PeersIndex = peersIndex.PeersIndex;
248
251
  exports.User = user.User;
@@ -257,7 +260,6 @@ exports.BusinessLocation = businessLocation.BusinessLocation;
257
260
  exports.BusinessWorkHours = businessWorkHours.BusinessWorkHours;
258
261
  exports.businessWorkHoursDaysToRaw = businessWorkHours.businessWorkHoursDaysToRaw;
259
262
  exports.SavedStarGift = savedStarGift.SavedStarGift;
260
- exports.UserStarGift = savedStarGift.UserStarGift;
261
263
  exports.StarGiftUnique = starsGiftUnique.StarGiftUnique;
262
264
  exports.StarGiftUniqueAttribute = starsGiftUnique.StarGiftUniqueAttribute;
263
265
  exports.StarGiftUniqueBackdrop = starsGiftUnique.StarGiftUniqueBackdrop;
package/index.js CHANGED
@@ -33,7 +33,7 @@ import { Thumbnail } from "./highlevel/types/media/thumbnail.js";
33
33
  import { Venue } from "./highlevel/types/media/venue.js";
34
34
  import { Video } from "./highlevel/types/media/video.js";
35
35
  import { Voice } from "./highlevel/types/media/voice.js";
36
- import { WebPage } from "./highlevel/types/media/web-page.js";
36
+ import { WebPage, WebPageMedia } from "./highlevel/types/media/web-page.js";
37
37
  import { Dialog } from "./highlevel/types/messages/dialog.js";
38
38
  import { DraftMessage } from "./highlevel/types/messages/draft-message.js";
39
39
  import { FactCheck } from "./highlevel/types/messages/fact-check.js";
@@ -70,6 +70,7 @@ import { ChatlistPreview } from "./highlevel/types/peers/chatlist-preview.js";
70
70
  import { ForumTopic } from "./highlevel/types/peers/forum-topic.js";
71
71
  import { FullChat } from "./highlevel/types/peers/full-chat.js";
72
72
  import { FullUser } from "./highlevel/types/peers/full-user.js";
73
+ import { PeerSettings } from "./highlevel/types/peers/peer-settings.js";
73
74
  import { parsePeer } from "./highlevel/types/peers/peer.js";
74
75
  import { PeersIndex } from "./highlevel/types/peers/peers-index.js";
75
76
  import { User } from "./highlevel/types/peers/user.js";
@@ -82,7 +83,7 @@ import { BusinessConnection } from "./highlevel/types/premium/business-connectio
82
83
  import { BusinessIntro } from "./highlevel/types/premium/business-intro.js";
83
84
  import { BusinessLocation } from "./highlevel/types/premium/business-location.js";
84
85
  import { BusinessWorkHours, businessWorkHoursDaysToRaw } from "./highlevel/types/premium/business-work-hours.js";
85
- import { SavedStarGift, UserStarGift } from "./highlevel/types/premium/saved-star-gift.js";
86
+ import { SavedStarGift } from "./highlevel/types/premium/saved-star-gift.js";
86
87
  import { StarGiftUnique, StarGiftUniqueAttribute, StarGiftUniqueBackdrop, StarGiftUniqueOriginalDetails } from "./highlevel/types/premium/stars-gift-unique.js";
87
88
  import { StarGift } from "./highlevel/types/premium/stars-gift.js";
88
89
  import { StarsStatus } from "./highlevel/types/premium/stars-status.js";
@@ -242,6 +243,7 @@ export {
242
243
  PaidMedia,
243
244
  PaidPeerReaction,
244
245
  PeerReaction,
246
+ PeerSettings,
245
247
  PeerStories,
246
248
  PeersIndex,
247
249
  Photo,
@@ -291,7 +293,6 @@ export {
291
293
  TransportError,
292
294
  UpdatesManager,
293
295
  User,
294
- UserStarGift,
295
296
  UserStatusUpdate,
296
297
  UserTypingUpdate,
297
298
  Venue,
@@ -299,6 +300,7 @@ export {
299
300
  Voice,
300
301
  WebDocument,
301
302
  WebPage,
303
+ WebPageMedia,
302
304
  WebviewResult,
303
305
  _actionFromTl,
304
306
  _messageActionFromTl,