@mtcute/core 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/client.cjs +13 -8
  2. package/client.js +13 -8
  3. package/highlevel/base.cjs +3 -3
  4. package/highlevel/base.js +3 -3
  5. package/highlevel/client.d.cts +27 -49
  6. package/highlevel/client.d.ts +27 -49
  7. package/highlevel/methods/auth/sign-in-qr.cjs +4 -4
  8. package/highlevel/methods/files/download-iterable.cjs +25 -0
  9. package/highlevel/methods/files/download-iterable.js +25 -0
  10. package/highlevel/methods/files/upload-file.js +1 -1
  11. package/highlevel/methods/messages/forward-messages.cjs +2 -1
  12. package/highlevel/methods/messages/forward-messages.d.cts +6 -0
  13. package/highlevel/methods/messages/forward-messages.d.ts +6 -0
  14. package/highlevel/methods/messages/forward-messages.js +2 -1
  15. package/highlevel/methods/messages/get-web-page-preview.cjs +22 -0
  16. package/highlevel/methods/messages/get-web-page-preview.d.cts +9 -0
  17. package/highlevel/methods/messages/get-web-page-preview.d.ts +9 -0
  18. package/highlevel/methods/messages/get-web-page-preview.js +17 -0
  19. package/highlevel/methods/messages/send-common.d.cts +5 -0
  20. package/highlevel/methods/messages/send-common.d.ts +5 -0
  21. package/highlevel/methods/messages/send-media-group.cjs +2 -1
  22. package/highlevel/methods/messages/send-media-group.js +2 -1
  23. package/highlevel/methods/messages/send-media.cjs +2 -1
  24. package/highlevel/methods/messages/send-media.js +2 -1
  25. package/highlevel/methods/messages/send-paid-reaction.cjs +8 -2
  26. package/highlevel/methods/messages/send-paid-reaction.d.cts +8 -2
  27. package/highlevel/methods/messages/send-paid-reaction.d.ts +8 -2
  28. package/highlevel/methods/messages/send-paid-reaction.js +8 -2
  29. package/highlevel/methods/messages/send-text.cjs +2 -1
  30. package/highlevel/methods/messages/send-text.js +2 -1
  31. package/highlevel/methods/premium/pin-star-gift.cjs +24 -0
  32. package/highlevel/methods/premium/pin-star-gift.d.cts +13 -0
  33. package/highlevel/methods/premium/pin-star-gift.d.ts +13 -0
  34. package/highlevel/methods/premium/pin-star-gift.js +19 -0
  35. package/highlevel/methods/{premium/get-star-gifts.cjs → users/get-peer-settings.cjs} +10 -6
  36. package/highlevel/methods/users/get-peer-settings.d.cts +4 -0
  37. package/highlevel/methods/users/get-peer-settings.d.ts +4 -0
  38. package/highlevel/methods/users/get-peer-settings.js +14 -0
  39. package/highlevel/methods/users/resolve-peer.cjs +16 -31
  40. package/highlevel/methods/users/resolve-peer.js +7 -22
  41. package/highlevel/methods.d.cts +3 -2
  42. package/highlevel/methods.d.ts +3 -2
  43. package/highlevel/storage/repository/peers.d.cts +2 -3
  44. package/highlevel/storage/repository/peers.d.ts +2 -3
  45. package/highlevel/storage/service/peers.cjs +10 -4
  46. package/highlevel/storage/service/peers.d.cts +1 -0
  47. package/highlevel/storage/service/peers.d.ts +1 -0
  48. package/highlevel/storage/service/peers.js +10 -4
  49. package/highlevel/types/bots/keyboards/factories.cjs +4 -4
  50. package/highlevel/types/media/document.cjs +1 -1
  51. package/highlevel/types/media/document.js +1 -1
  52. package/highlevel/types/media/web-page.cjs +40 -3
  53. package/highlevel/types/media/web-page.d.cts +23 -1
  54. package/highlevel/types/media/web-page.d.ts +23 -1
  55. package/highlevel/types/media/web-page.js +41 -4
  56. package/highlevel/types/messages/message-media.cjs +1 -1
  57. package/highlevel/types/messages/message-media.d.cts +2 -2
  58. package/highlevel/types/messages/message-media.d.ts +2 -2
  59. package/highlevel/types/messages/message-media.js +2 -2
  60. package/highlevel/types/messages/message.cjs +4 -0
  61. package/highlevel/types/messages/message.d.cts +2 -0
  62. package/highlevel/types/messages/message.d.ts +2 -0
  63. package/highlevel/types/messages/message.js +4 -0
  64. package/highlevel/types/peers/chat-event/actions.cjs +5 -0
  65. package/highlevel/types/peers/chat-event/actions.js +5 -0
  66. package/highlevel/types/peers/chat.cjs +4 -0
  67. package/highlevel/types/peers/chat.d.cts +2 -0
  68. package/highlevel/types/peers/chat.d.ts +2 -0
  69. package/highlevel/types/peers/chat.js +4 -0
  70. package/highlevel/types/peers/full-chat.cjs +4 -0
  71. package/highlevel/types/peers/full-chat.d.cts +2 -0
  72. package/highlevel/types/peers/full-chat.d.ts +2 -0
  73. package/highlevel/types/peers/full-chat.js +4 -0
  74. package/highlevel/types/peers/index.d.cts +1 -0
  75. package/highlevel/types/peers/index.d.ts +1 -0
  76. package/highlevel/types/peers/peer-settings.cjs +101 -0
  77. package/highlevel/types/peers/peer-settings.d.cts +84 -0
  78. package/highlevel/types/peers/peer-settings.d.ts +84 -0
  79. package/highlevel/types/peers/peer-settings.js +96 -0
  80. package/highlevel/types/peers/user.cjs +4 -0
  81. package/highlevel/types/peers/user.d.cts +2 -0
  82. package/highlevel/types/peers/user.d.ts +2 -0
  83. package/highlevel/types/peers/user.js +4 -0
  84. package/highlevel/types/premium/saved-star-gift.cjs +4 -1
  85. package/highlevel/types/premium/saved-star-gift.d.cts +2 -3
  86. package/highlevel/types/premium/saved-star-gift.d.ts +2 -3
  87. package/highlevel/types/premium/saved-star-gift.js +5 -2
  88. package/highlevel/types/premium/stars-gift-unique.cjs +4 -0
  89. package/highlevel/types/premium/stars-gift-unique.d.cts +2 -0
  90. package/highlevel/types/premium/stars-gift-unique.d.ts +2 -0
  91. package/highlevel/types/premium/stars-gift-unique.js +4 -0
  92. package/highlevel/types/premium/stars-transaction.cjs +14 -0
  93. package/highlevel/types/premium/stars-transaction.d.cts +14 -0
  94. package/highlevel/types/premium/stars-transaction.d.ts +14 -0
  95. package/highlevel/types/premium/stars-transaction.js +14 -0
  96. package/highlevel/types/stories/story-viewer.cjs +1 -1
  97. package/highlevel/types/stories/story-viewer.js +1 -1
  98. package/highlevel/types/updates/history-read-update.cjs +1 -0
  99. package/highlevel/types/updates/history-read-update.js +1 -0
  100. package/highlevel/updates/manager.js +2 -2
  101. package/highlevel/utils/file-utils.js +1 -1
  102. package/highlevel/utils/inline-utils.cjs +5 -5
  103. package/highlevel/utils/inline-utils.js +1 -1
  104. package/highlevel/worker/storage.cjs +2 -0
  105. package/highlevel/worker/storage.d.cts +1 -0
  106. package/highlevel/worker/storage.d.ts +1 -0
  107. package/highlevel/worker/storage.js +2 -0
  108. package/index.cjs +3 -1
  109. package/index.js +5 -3
  110. package/methods.cjs +6 -4
  111. package/methods.js +6 -4
  112. package/network/authorization.js +2 -2
  113. package/network/network-manager.cjs +1 -1
  114. package/network/network-manager.js +1 -1
  115. package/network/persistent-connection.cjs +6 -4
  116. package/network/persistent-connection.js +6 -4
  117. package/network/session-connection.cjs +14 -7
  118. package/network/session-connection.d.cts +1 -1
  119. package/network/session-connection.d.ts +1 -1
  120. package/network/session-connection.js +15 -8
  121. package/package.json +4 -4
  122. package/storage/memory/repository/peers.cjs +2 -2
  123. package/storage/memory/repository/peers.d.cts +1 -1
  124. package/storage/memory/repository/peers.d.ts +1 -1
  125. package/storage/memory/repository/peers.js +2 -2
  126. package/storage/sqlite/repository/peers.cjs +3 -5
  127. package/storage/sqlite/repository/peers.d.cts +1 -2
  128. package/storage/sqlite/repository/peers.d.ts +1 -2
  129. package/storage/sqlite/repository/peers.js +3 -5
  130. package/utils/binary/asn1-parser.js +1 -1
  131. package/utils/binary/compat.cjs +150 -0
  132. package/utils/binary/compat.d.cts +13 -0
  133. package/utils/binary/compat.d.ts +13 -0
  134. package/utils/binary/compat.js +145 -0
  135. package/utils/binary/compat.test.d.cts +1 -0
  136. package/utils/binary/compat.test.d.ts +1 -0
  137. package/utils/binary/serialization.cjs +59 -0
  138. package/utils/binary/serialization.d.cts +10 -0
  139. package/utils/binary/serialization.d.ts +10 -0
  140. package/utils/binary/serialization.js +54 -0
  141. package/utils/index.d.cts +2 -0
  142. package/utils/index.d.ts +2 -0
  143. package/utils/long-utils.js +1 -1
  144. package/utils/peer-utils.js +1 -1
  145. package/utils.cjs +8 -0
  146. package/utils.js +8 -0
  147. package/highlevel/methods/premium/get-star-gifts.d.cts +0 -23
  148. package/highlevel/methods/premium/get-star-gifts.d.ts +0 -23
  149. package/highlevel/methods/premium/get-star-gifts.js +0 -10
  150. package/highlevel/methods/premium/iter-star-gifts.cjs +0 -29
  151. package/highlevel/methods/premium/iter-star-gifts.d.cts +0 -26
  152. package/highlevel/methods/premium/iter-star-gifts.d.ts +0 -26
  153. package/highlevel/methods/premium/iter-star-gifts.js +0 -24
@@ -0,0 +1,101 @@
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 user = require("./user.cjs");
11
+ class PeerSettings {
12
+ constructor(raw, _peers) {
13
+ this.raw = raw;
14
+ this._peers = _peers;
15
+ }
16
+ /** Action bar that should be displayed in the chat with the user */
17
+ get actionBar() {
18
+ if (this.raw.requestChatTitle) {
19
+ return {
20
+ type: "join_request",
21
+ chatTitle: this.raw.requestChatTitle,
22
+ isBroadcast: this.raw.requestChatBroadcast,
23
+ requestDate: new Date(this.raw.requestChatDate ?? 0)
24
+ };
25
+ }
26
+ if (this.raw.reportGeo) {
27
+ return null;
28
+ }
29
+ if (this.raw.inviteMembers) {
30
+ return { type: "invite_members" };
31
+ }
32
+ if (this.raw.shareContact) {
33
+ return { type: "share_phone_number" };
34
+ }
35
+ if (this.raw.blockContact || this.raw.reportSpam) {
36
+ return {
37
+ type: "add_or_report",
38
+ canReportSpam: this.raw.reportSpam,
39
+ canUnarchive: this.raw.autoarchived
40
+ };
41
+ }
42
+ if (this.raw.addContact) {
43
+ return {
44
+ type: "add_contact",
45
+ needPhoneNumberPrivacyException: this.raw.needContactsException
46
+ };
47
+ }
48
+ if (this.raw.businessBotId && this._peers) {
49
+ return {
50
+ type: "business_bot",
51
+ bot: new user.User(this._peers.user(this.raw.businessBotId)),
52
+ manageUrl: this.raw.businessBotManageUrl ?? ""
53
+ };
54
+ }
55
+ return null;
56
+ }
57
+ /** Distance in meters between us and the user */
58
+ get geoDistance() {
59
+ return this.raw.geoDistance ?? null;
60
+ }
61
+ /**
62
+ * Price of paid messages to this peer for the current user
63
+ * (note that this might differ from {@link User.paidMessagePrice},
64
+ * because the user might have added us to their contacts or wrote first,
65
+ * in which case the messages are free regardless)
66
+ */
67
+ get paidMessagePrice() {
68
+ return this.raw.chargePaidMessageStars ?? null;
69
+ }
70
+ /**
71
+ * Month and year when the user registered.
72
+ * Only available for users who contacted us first.
73
+ */
74
+ get registrationDate() {
75
+ return this.raw.registrationMonth ?? null;
76
+ }
77
+ /**
78
+ * ISO country code of the user's phone number.
79
+ * Only available for users who contacted us first.
80
+ */
81
+ get phoneCountry() {
82
+ return this.raw.phoneCountry ?? null;
83
+ }
84
+ /**
85
+ * Date when the user has last changed their name.
86
+ * Only available for users who contacted us first.
87
+ */
88
+ get nameChangeDate() {
89
+ return this.raw.nameChangeDate ? new Date(this.raw.nameChangeDate * 1e3) : null;
90
+ }
91
+ /**
92
+ * Date when the user has last changed their photo.
93
+ * Only available for users who contacted us first.
94
+ */
95
+ get photoChangeDate() {
96
+ return this.raw.photoChangeDate ? new Date(this.raw.photoChangeDate * 1e3) : null;
97
+ }
98
+ }
99
+ const PeerSettings$1 = /* @__PURE__ */ inspectable.makeInspectable(PeerSettings);
100
+ const PeerSettings$2 = /* @__PURE__ */ memoize.memoizeGetters(PeerSettings$1, ["actionBar"]);
101
+ exports.PeerSettings = PeerSettings$2;
@@ -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,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
  };
@@ -152,6 +152,10 @@ class StarGiftUnique {
152
152
  get ownerAddress() {
153
153
  return this.raw.ownerAddress ?? null;
154
154
  }
155
+ /** TON address of the gift NFT */
156
+ get giftAddress() {
157
+ return this.raw.giftAddress ?? null;
158
+ }
155
159
  }
156
160
  const StarGiftUnique$1 = /* @__PURE__ */ inspectable.makeInspectable(StarGiftUnique);
157
161
  const StarGiftUnique$2 = /* @__PURE__ */ memoize.memoizeGetters(StarGiftUnique$1, ["model", "pattern", "backdrop", "originalDetails"]);
@@ -73,4 +73,6 @@ export declare class StarGiftUnique {
73
73
  get originalDetails(): StarGiftUniqueOriginalDetails | null;
74
74
  /** TON address of the owner of the unique star gift */
75
75
  get ownerAddress(): string | null;
76
+ /** TON address of the gift NFT */
77
+ get giftAddress(): string | null;
76
78
  }
@@ -73,4 +73,6 @@ export declare class StarGiftUnique {
73
73
  get originalDetails(): StarGiftUniqueOriginalDetails | null;
74
74
  /** TON address of the owner of the unique star gift */
75
75
  get ownerAddress(): string | null;
76
+ /** TON address of the gift NFT */
77
+ get giftAddress(): string | null;
76
78
  }
@@ -145,6 +145,10 @@ class StarGiftUnique {
145
145
  get ownerAddress() {
146
146
  return this.raw.ownerAddress ?? null;
147
147
  }
148
+ /** TON address of the gift NFT */
149
+ get giftAddress() {
150
+ return this.raw.giftAddress ?? null;
151
+ }
148
152
  }
149
153
  const StarGiftUnique$1 = /* @__PURE__ */ makeInspectable(StarGiftUnique);
150
154
  const StarGiftUnique$2 = /* @__PURE__ */ memoizeGetters(StarGiftUnique$1, ["model", "pattern", "backdrop", "originalDetails"]);
@@ -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":