@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
@@ -207,11 +207,11 @@ class PeersService extends base.BaseService {
207
207
  async getById(id, allowRefs = true) {
208
208
  const cached = this._cache.get(id);
209
209
  if (cached) return cached.peer;
210
- const dto = await this._peers.getById(id, false);
211
- if (dto) {
210
+ const dto = await this._peers.getById(id);
211
+ if (dto && !dto.isMin) {
212
212
  return this._returnCaching(id, dto);
213
213
  }
214
- if (allowRefs) {
214
+ if ((!dto || dto.isMin) && allowRefs) {
215
215
  const ref = await this._refs.getForPeer(id);
216
216
  if (!ref) return null;
217
217
  const [chatId, msgId] = ref;
@@ -234,6 +234,11 @@ class PeersService extends base.BaseService {
234
234
  }
235
235
  return null;
236
236
  }
237
+ async getMinAccessHash(id) {
238
+ const dto = await this._peers.getById(id);
239
+ if (!dto) return null;
240
+ return longUtils.longFromFastString(dto.accessHash);
241
+ }
237
242
  async getByPhone(phone) {
238
243
  const dto = await this._peers.getByPhone(phone);
239
244
  if (!dto) return null;
@@ -250,8 +255,9 @@ class PeersService extends base.BaseService {
250
255
  async getCompleteById(id, allowMin = false) {
251
256
  const cached = this._cache.get(id);
252
257
  if (cached) return cached.complete;
253
- const dto = await this._peers.getById(id, allowMin);
258
+ const dto = await this._peers.getById(id);
254
259
  if (!dto) return null;
260
+ if (!allowMin && dto.isMin) return null;
255
261
  const cacheItem = {
256
262
  peer: getInputPeer(dto),
257
263
  complete: this._deserializeTl(dto.complete)
@@ -17,6 +17,7 @@ export declare class PeersService extends BaseService {
17
17
  store(peer: tl.TypeUser | tl.TypeChat): Promise<void>;
18
18
  private _returnCaching;
19
19
  getById(id: number, allowRefs?: boolean): Promise<tl.TypeInputPeer | null>;
20
+ getMinAccessHash(id: number): Promise<tl.Long | null>;
20
21
  getByPhone(phone: string): Promise<tl.TypeInputPeer | null>;
21
22
  getByUsername(username: string): Promise<tl.TypeInputPeer | null>;
22
23
  getCompleteById(id: number, allowMin?: boolean): Promise<tl.TypeUser | tl.TypeChat | null>;
@@ -17,6 +17,7 @@ export declare class PeersService extends BaseService {
17
17
  store(peer: tl.TypeUser | tl.TypeChat): Promise<void>;
18
18
  private _returnCaching;
19
19
  getById(id: number, allowRefs?: boolean): Promise<tl.TypeInputPeer | null>;
20
+ getMinAccessHash(id: number): Promise<tl.Long | null>;
20
21
  getByPhone(phone: string): Promise<tl.TypeInputPeer | null>;
21
22
  getByUsername(username: string): Promise<tl.TypeInputPeer | null>;
22
23
  getCompleteById(id: number, allowMin?: boolean): Promise<tl.TypeUser | tl.TypeChat | null>;
@@ -200,11 +200,11 @@ class PeersService extends BaseService {
200
200
  async getById(id, allowRefs = true) {
201
201
  const cached = this._cache.get(id);
202
202
  if (cached) return cached.peer;
203
- const dto = await this._peers.getById(id, false);
204
- if (dto) {
203
+ const dto = await this._peers.getById(id);
204
+ if (dto && !dto.isMin) {
205
205
  return this._returnCaching(id, dto);
206
206
  }
207
- if (allowRefs) {
207
+ if ((!dto || dto.isMin) && allowRefs) {
208
208
  const ref = await this._refs.getForPeer(id);
209
209
  if (!ref) return null;
210
210
  const [chatId, msgId] = ref;
@@ -227,6 +227,11 @@ class PeersService extends BaseService {
227
227
  }
228
228
  return null;
229
229
  }
230
+ async getMinAccessHash(id) {
231
+ const dto = await this._peers.getById(id);
232
+ if (!dto) return null;
233
+ return longFromFastString(dto.accessHash);
234
+ }
230
235
  async getByPhone(phone) {
231
236
  const dto = await this._peers.getByPhone(phone);
232
237
  if (!dto) return null;
@@ -243,8 +248,9 @@ class PeersService extends BaseService {
243
248
  async getCompleteById(id, allowMin = false) {
244
249
  const cached = this._cache.get(id);
245
250
  if (cached) return cached.complete;
246
- const dto = await this._peers.getById(id, allowMin);
251
+ const dto = await this._peers.getById(id);
247
252
  if (!dto) return null;
253
+ if (!allowMin && dto.isMin) return null;
248
254
  const cacheItem = {
249
255
  peer: getInputPeer(dto),
250
256
  complete: this._deserializeTl(dto.complete)
@@ -5,9 +5,9 @@ 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 tl = require("@mtcute/tl");
10
- const utils = require("../../../../types/utils.cjs");
10
+ const utils$1 = require("../../../../types/utils.cjs");
11
11
  const peerUtils = require("../../../utils/peer-utils.cjs");
12
12
  const builder$1 = require("./builder.cjs");
13
13
  function builder(maxRowWidth) {
@@ -73,7 +73,7 @@ function callback(text2, data, requiresPassword) {
73
73
  _: "keyboardButtonCallback",
74
74
  text: text2,
75
75
  requiresPassword,
76
- data: typeof data === "string" ? utils$1.utf8.encoder.encode(data) : data
76
+ data: typeof data === "string" ? utils.utf8.encoder.encode(data) : data
77
77
  };
78
78
  }
79
79
  function switchInline(text2, query = "", currentChat) {
@@ -199,7 +199,7 @@ function _convertToTl(obj) {
199
199
  rows: _2dToRows(obj.buttons, true)
200
200
  };
201
201
  default:
202
- utils.assertNever();
202
+ utils$1.assertNever();
203
203
  }
204
204
  }
205
205
  exports._2dToRows = _2dToRows;
@@ -8,8 +8,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const fileId = require("@mtcute/file-id");
9
9
  const memoize = require("../../utils/memoize.cjs");
10
10
  const thumbnail = require("./thumbnail.cjs");
11
- const fileLocation = require("../files/file-location.cjs");
12
11
  const inspectable = require("../../utils/inspectable.cjs");
12
+ const fileLocation = require("../files/file-location.cjs");
13
13
  class RawDocument extends fileLocation.FileLocation {
14
14
  constructor(raw) {
15
15
  super(
@@ -1,8 +1,8 @@
1
1
  import { tdFileId, toFileId, toUniqueFileId } from "@mtcute/file-id";
2
2
  import { memoizeGetters } from "../../utils/memoize.js";
3
3
  import { Thumbnail as Thumbnail$2 } from "./thumbnail.js";
4
- import { FileLocation as FileLocation$1 } from "../files/file-location.js";
5
4
  import { makeInspectable } from "../../utils/inspectable.js";
5
+ import { FileLocation as FileLocation$1 } from "../files/file-location.js";
6
6
  class RawDocument extends FileLocation$1 {
7
7
  constructor(raw) {
8
8
  super(
@@ -5,6 +5,7 @@ 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 = require("@fuman/utils");
8
9
  const errors = require("../../../types/errors.cjs");
9
10
  const memoize = require("../../utils/memoize.cjs");
10
11
  const documentUtils = require("./document-utils.cjs");
@@ -14,7 +15,6 @@ class WebPage {
14
15
  constructor(raw) {
15
16
  this.raw = raw;
16
17
  }
17
- type = "webpage";
18
18
  /**
19
19
  * Unique ID of the preview
20
20
  */
@@ -172,6 +172,42 @@ class WebPage {
172
172
  }
173
173
  return documentUtils.parseDocument(this.raw.document);
174
174
  }
175
+ }
176
+ const WebPage$1 = /* @__PURE__ */ memoize.memoizeGetters(WebPage, ["photo", "document"]);
177
+ const WebPage$2 = /* @__PURE__ */ inspectable.makeInspectable(WebPage$1);
178
+ class WebPageMedia {
179
+ constructor(raw) {
180
+ this.raw = raw;
181
+ }
182
+ type = "webpage";
183
+ /** Web page preview */
184
+ get preview() {
185
+ utils.assert(this.raw.webpage._ === "webPage");
186
+ return new WebPage(this.raw.webpage);
187
+ }
188
+ /**
189
+ * Size in which the client should display whatever contained in the webpage
190
+ *
191
+ * - `small`: small square thumbnail on the right
192
+ * - `large`: large thumbnail below the webpage content
193
+ * - `default`: default behaviour (depending on the og tags)
194
+ */
195
+ get displaySize() {
196
+ if (this.raw.forceLargeMedia) return "large";
197
+ if (this.raw.forceSmallMedia) return "small";
198
+ return "default";
199
+ }
200
+ /**
201
+ * Whether the webpage was manually set, and the link might not be present
202
+ * at all in the actual message
203
+ */
204
+ get manual() {
205
+ return this.raw.manual;
206
+ }
207
+ /** Whether it's safe to open the URL without the user confirmation */
208
+ get safe() {
209
+ return this.raw.safe;
210
+ }
175
211
  /**
176
212
  * Input media TL object generated from this object,
177
213
  * to be used inside {@link InputMediaLike} and
@@ -185,6 +221,7 @@ class WebPage {
185
221
  throw new errors.MtArgumentError("WebPage cannot provide an InputMedia");
186
222
  }
187
223
  }
188
- const WebPage$1 = /* @__PURE__ */ memoize.memoizeGetters(WebPage, ["photo", "document"]);
189
- const WebPage$2 = /* @__PURE__ */ inspectable.makeInspectable(WebPage$1, void 0, ["inputMedia"]);
224
+ const WebPageMedia$1 = /* @__PURE__ */ inspectable.makeInspectable(WebPageMedia, void 0, ["inputMedia"]);
225
+ const WebPageMedia$2 = /* @__PURE__ */ memoize.memoizeGetters(WebPageMedia$1, ["preview"]);
190
226
  exports.WebPage = WebPage$2;
227
+ exports.WebPageMedia = WebPageMedia$2;
@@ -13,7 +13,6 @@ import { Photo } from './photo.js';
13
13
  */
14
14
  export declare class WebPage {
15
15
  readonly raw: tl.RawWebPage;
16
- readonly type: "webpage";
17
16
  constructor(raw: tl.RawWebPage);
18
17
  /**
19
18
  * Unique ID of the preview
@@ -138,6 +137,29 @@ export declare class WebPage {
138
137
  * {@link Audio}, {@link Document}.
139
138
  */
140
139
  get document(): RawDocument | null;
140
+ }
141
+ /** Information about a web page preview in a message */
142
+ export declare class WebPageMedia {
143
+ readonly raw: tl.RawMessageMediaWebPage;
144
+ readonly type: "webpage";
145
+ constructor(raw: tl.RawMessageMediaWebPage);
146
+ /** Web page preview */
147
+ get preview(): WebPage;
148
+ /**
149
+ * Size in which the client should display whatever contained in the webpage
150
+ *
151
+ * - `small`: small square thumbnail on the right
152
+ * - `large`: large thumbnail below the webpage content
153
+ * - `default`: default behaviour (depending on the og tags)
154
+ */
155
+ get displaySize(): 'small' | 'large' | 'default';
156
+ /**
157
+ * Whether the webpage was manually set, and the link might not be present
158
+ * at all in the actual message
159
+ */
160
+ get manual(): boolean;
161
+ /** Whether it's safe to open the URL without the user confirmation */
162
+ get safe(): boolean;
141
163
  /**
142
164
  * Input media TL object generated from this object,
143
165
  * to be used inside {@link InputMediaLike} and
@@ -13,7 +13,6 @@ import { Photo } from './photo.js';
13
13
  */
14
14
  export declare class WebPage {
15
15
  readonly raw: tl.RawWebPage;
16
- readonly type: "webpage";
17
16
  constructor(raw: tl.RawWebPage);
18
17
  /**
19
18
  * Unique ID of the preview
@@ -138,6 +137,29 @@ export declare class WebPage {
138
137
  * {@link Audio}, {@link Document}.
139
138
  */
140
139
  get document(): RawDocument | null;
140
+ }
141
+ /** Information about a web page preview in a message */
142
+ export declare class WebPageMedia {
143
+ readonly raw: tl.RawMessageMediaWebPage;
144
+ readonly type: "webpage";
145
+ constructor(raw: tl.RawMessageMediaWebPage);
146
+ /** Web page preview */
147
+ get preview(): WebPage;
148
+ /**
149
+ * Size in which the client should display whatever contained in the webpage
150
+ *
151
+ * - `small`: small square thumbnail on the right
152
+ * - `large`: large thumbnail below the webpage content
153
+ * - `default`: default behaviour (depending on the og tags)
154
+ */
155
+ get displaySize(): 'small' | 'large' | 'default';
156
+ /**
157
+ * Whether the webpage was manually set, and the link might not be present
158
+ * at all in the actual message
159
+ */
160
+ get manual(): boolean;
161
+ /** Whether it's safe to open the URL without the user confirmation */
162
+ get safe(): boolean;
141
163
  /**
142
164
  * Input media TL object generated from this object,
143
165
  * to be used inside {@link InputMediaLike} and
@@ -1,3 +1,4 @@
1
+ import { assert } from "@fuman/utils";
1
2
  import { MtArgumentError } from "../../../types/errors.js";
2
3
  import { memoizeGetters } from "../../utils/memoize.js";
3
4
  import { parseDocument } from "./document-utils.js";
@@ -7,7 +8,6 @@ class WebPage {
7
8
  constructor(raw) {
8
9
  this.raw = raw;
9
10
  }
10
- type = "webpage";
11
11
  /**
12
12
  * Unique ID of the preview
13
13
  */
@@ -165,6 +165,42 @@ class WebPage {
165
165
  }
166
166
  return parseDocument(this.raw.document);
167
167
  }
168
+ }
169
+ const WebPage$1 = /* @__PURE__ */ memoizeGetters(WebPage, ["photo", "document"]);
170
+ const WebPage$2 = /* @__PURE__ */ makeInspectable(WebPage$1);
171
+ class WebPageMedia {
172
+ constructor(raw) {
173
+ this.raw = raw;
174
+ }
175
+ type = "webpage";
176
+ /** Web page preview */
177
+ get preview() {
178
+ assert(this.raw.webpage._ === "webPage");
179
+ return new WebPage(this.raw.webpage);
180
+ }
181
+ /**
182
+ * Size in which the client should display whatever contained in the webpage
183
+ *
184
+ * - `small`: small square thumbnail on the right
185
+ * - `large`: large thumbnail below the webpage content
186
+ * - `default`: default behaviour (depending on the og tags)
187
+ */
188
+ get displaySize() {
189
+ if (this.raw.forceLargeMedia) return "large";
190
+ if (this.raw.forceSmallMedia) return "small";
191
+ return "default";
192
+ }
193
+ /**
194
+ * Whether the webpage was manually set, and the link might not be present
195
+ * at all in the actual message
196
+ */
197
+ get manual() {
198
+ return this.raw.manual;
199
+ }
200
+ /** Whether it's safe to open the URL without the user confirmation */
201
+ get safe() {
202
+ return this.raw.safe;
203
+ }
168
204
  /**
169
205
  * Input media TL object generated from this object,
170
206
  * to be used inside {@link InputMediaLike} and
@@ -178,8 +214,9 @@ class WebPage {
178
214
  throw new MtArgumentError("WebPage cannot provide an InputMedia");
179
215
  }
180
216
  }
181
- const WebPage$1 = /* @__PURE__ */ memoizeGetters(WebPage, ["photo", "document"]);
182
- const WebPage$2 = /* @__PURE__ */ makeInspectable(WebPage$1, void 0, ["inputMedia"]);
217
+ const WebPageMedia$1 = /* @__PURE__ */ makeInspectable(WebPageMedia, void 0, ["inputMedia"]);
218
+ const WebPageMedia$2 = /* @__PURE__ */ memoizeGetters(WebPageMedia$1, ["preview"]);
183
219
  export {
184
- WebPage$2 as WebPage
220
+ WebPage$2 as WebPage,
221
+ WebPageMedia$2 as WebPageMedia
185
222
  };
@@ -40,7 +40,7 @@ function _messageMediaFromTl(peers, m) {
40
40
  return new game.Game(m.game);
41
41
  case "messageMediaWebPage":
42
42
  if (!(m.webpage._ === "webPage")) return null;
43
- return new webPage.WebPage(m.webpage);
43
+ return new webPage.WebPageMedia(m);
44
44
  case "messageMediaVenue":
45
45
  return new venue.Venue(m);
46
46
  case "messageMediaPoll":
@@ -15,9 +15,9 @@ import { Photo } from '../media/photo.js';
15
15
  import { Poll } from '../media/poll.js';
16
16
  import { MediaStory } from '../media/story.js';
17
17
  import { Venue } from '../media/venue.js';
18
- import { WebPage } from '../media/web-page.js';
18
+ import { WebPageMedia } from '../media/web-page.js';
19
19
  /** A media inside of a {@link Message} */
20
- export type MessageMedia = Photo | Dice | Contact | Audio | Voice | Sticker | Document | Video | Location | LiveLocation | Game | WebPage | Venue | Poll | Invoice | MediaStory | PaidMedia | null;
20
+ export type MessageMedia = Photo | Dice | Contact | Audio | Voice | Sticker | Document | Video | Location | LiveLocation | Game | WebPageMedia | Venue | Poll | Invoice | MediaStory | PaidMedia | null;
21
21
  export type MessageMediaType = Exclude<MessageMedia, null>['type'];
22
22
  /** @internal */
23
23
  export declare function _messageMediaFromTl(peers: PeersIndex | null, m: tl.TypeMessageMedia): MessageMedia;
@@ -15,9 +15,9 @@ import { Photo } from '../media/photo.js';
15
15
  import { Poll } from '../media/poll.js';
16
16
  import { MediaStory } from '../media/story.js';
17
17
  import { Venue } from '../media/venue.js';
18
- import { WebPage } from '../media/web-page.js';
18
+ import { WebPageMedia } from '../media/web-page.js';
19
19
  /** A media inside of a {@link Message} */
20
- export type MessageMedia = Photo | Dice | Contact | Audio | Voice | Sticker | Document | Video | Location | LiveLocation | Game | WebPage | Venue | Poll | Invoice | MediaStory | PaidMedia | null;
20
+ export type MessageMedia = Photo | Dice | Contact | Audio | Voice | Sticker | Document | Video | Location | LiveLocation | Game | WebPageMedia | Venue | Poll | Invoice | MediaStory | PaidMedia | null;
21
21
  export type MessageMediaType = Exclude<MessageMedia, null>['type'];
22
22
  /** @internal */
23
23
  export declare function _messageMediaFromTl(peers: PeersIndex | null, m: tl.TypeMessageMedia): MessageMedia;
@@ -10,7 +10,7 @@ import { Photo as Photo$2 } from "../media/photo.js";
10
10
  import { Poll as Poll$2 } from "../media/poll.js";
11
11
  import { MediaStory as MediaStory$1 } from "../media/story.js";
12
12
  import { Venue as Venue$2 } from "../media/venue.js";
13
- import { WebPage as WebPage$2 } from "../media/web-page.js";
13
+ import { WebPageMedia as WebPageMedia$2 } from "../media/web-page.js";
14
14
  function _messageMediaFromTl(peers, m) {
15
15
  switch (m._) {
16
16
  case "messageMediaPhoto":
@@ -33,7 +33,7 @@ function _messageMediaFromTl(peers, m) {
33
33
  return new Game$2(m.game);
34
34
  case "messageMediaWebPage":
35
35
  if (!(m.webpage._ === "webPage")) return null;
36
- return new WebPage$2(m.webpage);
36
+ return new WebPageMedia$2(m);
37
37
  case "messageMediaVenue":
38
38
  return new Venue$2(m);
39
39
  case "messageMediaPoll":
@@ -422,6 +422,10 @@ class Message {
422
422
  get videoProcessingPending() {
423
423
  return this.raw._ === "message" && this.raw.videoProcessingPending;
424
424
  }
425
+ /** If this message was paid, the number of stars spent sending it */
426
+ get sendPrice() {
427
+ return this.raw._ === "message" ? this.raw.paidMessageStars ?? null : null;
428
+ }
425
429
  /**
426
430
  * Generated permalink to this message, only for groups and channels
427
431
  *
@@ -247,6 +247,8 @@ export declare class Message {
247
247
  get effectId(): tl.Long | null;
248
248
  /** Whether this message has a video that is still being processed */
249
249
  get videoProcessingPending(): boolean;
250
+ /** If this message was paid, the number of stars spent sending it */
251
+ get sendPrice(): tl.Long | null;
250
252
  /**
251
253
  * Generated permalink to this message, only for groups and channels
252
254
  *
@@ -247,6 +247,8 @@ export declare class Message {
247
247
  get effectId(): tl.Long | null;
248
248
  /** Whether this message has a video that is still being processed */
249
249
  get videoProcessingPending(): boolean;
250
+ /** If this message was paid, the number of stars spent sending it */
251
+ get sendPrice(): tl.Long | null;
250
252
  /**
251
253
  * Generated permalink to this message, only for groups and channels
252
254
  *
@@ -415,6 +415,10 @@ class Message {
415
415
  get videoProcessingPending() {
416
416
  return this.raw._ === "message" && this.raw.videoProcessingPending;
417
417
  }
418
+ /** If this message was paid, the number of stars spent sending it */
419
+ get sendPrice() {
420
+ return this.raw._ === "message" ? this.raw.paidMessageStars ?? null : null;
421
+ }
418
422
  /**
419
423
  * Generated permalink to this message, only for groups and channels
420
424
  *
@@ -189,6 +189,9 @@ function _actionFromTl(e, peers) {
189
189
  link: new chatInviteLink.ChatInviteLink(e.invite, peers),
190
190
  approvedBy: new user.User(peers.user(e.approvedBy))
191
191
  };
192
+ // channelAdminLogEventActionCreateTopic#58707d28 topic:ForumTopic = ChannelAdminLogEventAction;
193
+ // channelAdminLogEventActionEditTopic#f06fe208 prev_topic:ForumTopic new_topic:ForumTopic
194
+ // channelAdminLogEventActionDeleteTopic#ae168909 topic:ForumTopic = ChannelAdminLogEventAction;
192
195
  case "channelAdminLogEventActionToggleForum":
193
196
  return {
194
197
  type: "forum_toggled",
@@ -219,6 +222,8 @@ function _actionFromTl(e, peers) {
219
222
  type: "no_forwards_toggled",
220
223
  enabled: e.newValue
221
224
  };
225
+ // case 'channelAdminLogEventActionPinTopic'
226
+ // ^ looks like it is not used, and pinned topics are not at all presented in the event log
222
227
  case "channelAdminLogEventActionToggleSignatureProfiles":
223
228
  return {
224
229
  type: "signature_profiles_toggled",
@@ -182,6 +182,9 @@ function _actionFromTl(e, peers) {
182
182
  link: new ChatInviteLink$2(e.invite, peers),
183
183
  approvedBy: new User$2(peers.user(e.approvedBy))
184
184
  };
185
+ // channelAdminLogEventActionCreateTopic#58707d28 topic:ForumTopic = ChannelAdminLogEventAction;
186
+ // channelAdminLogEventActionEditTopic#f06fe208 prev_topic:ForumTopic new_topic:ForumTopic
187
+ // channelAdminLogEventActionDeleteTopic#ae168909 topic:ForumTopic = ChannelAdminLogEventAction;
185
188
  case "channelAdminLogEventActionToggleForum":
186
189
  return {
187
190
  type: "forum_toggled",
@@ -212,6 +215,8 @@ function _actionFromTl(e, peers) {
212
215
  type: "no_forwards_toggled",
213
216
  enabled: e.newValue
214
217
  };
218
+ // case 'channelAdminLogEventActionPinTopic'
219
+ // ^ looks like it is not used, and pinned topics are not at all presented in the event log
215
220
  case "channelAdminLogEventActionToggleSignatureProfiles":
216
221
  return {
217
222
  type: "signature_profiles_toggled",
@@ -400,6 +400,10 @@ class Chat {
400
400
  if (!this.raw.migratedTo) return null;
401
401
  return peerUtils.getMarkedPeerId(this.raw.migratedTo);
402
402
  }
403
+ /** If this chat has paid messages enabled, price of one message in stars */
404
+ get paidMessagePrice() {
405
+ return this.raw._ === "channel" ? this.raw.sendPaidMessagesStars ?? null : null;
406
+ }
403
407
  /**
404
408
  * Create a mention for the chat.
405
409
  *
@@ -227,6 +227,8 @@ export declare class Chat {
227
227
  * this field will contain the marked ID of that supergroup.
228
228
  */
229
229
  get migratedToId(): number | null;
230
+ /** If this chat has paid messages enabled, price of one message in stars */
231
+ get paidMessagePrice(): tl.Long | null;
230
232
  /**
231
233
  * Create a mention for the chat.
232
234
  *
@@ -227,6 +227,8 @@ export declare class Chat {
227
227
  * this field will contain the marked ID of that supergroup.
228
228
  */
229
229
  get migratedToId(): number | null;
230
+ /** If this chat has paid messages enabled, price of one message in stars */
231
+ get paidMessagePrice(): tl.Long | null;
230
232
  /**
231
233
  * Create a mention for the chat.
232
234
  *
@@ -393,6 +393,10 @@ class Chat {
393
393
  if (!this.raw.migratedTo) return null;
394
394
  return getMarkedPeerId(this.raw.migratedTo);
395
395
  }
396
+ /** If this chat has paid messages enabled, price of one message in stars */
397
+ get paidMessagePrice() {
398
+ return this.raw._ === "channel" ? this.raw.sendPaidMessagesStars ?? null : null;
399
+ }
396
400
  /**
397
401
  * Create a mention for the chat.
398
402
  *
@@ -306,6 +306,10 @@ class FullChat extends chat.Chat {
306
306
  get starGiftsCount() {
307
307
  return this.full._ === "channelFull" ? this.full.stargiftsCount ?? 0 : 0;
308
308
  }
309
+ /** Whether you can enable paid messages in this chat */
310
+ get paidMessagesAvailable() {
311
+ return this.full._ === "channelFull" && this.full.paidMessagesAvailable;
312
+ }
309
313
  }
310
314
  const FullChat$1 = /* @__PURE__ */ memoize.memoizeGetters(FullChat, [
311
315
  "fullPhoto",
@@ -165,4 +165,6 @@ export declare class FullChat extends Chat {
165
165
  get starGiftsAvailable(): boolean;
166
166
  /** Number of star gifts available in this chat */
167
167
  get starGiftsCount(): number;
168
+ /** Whether you can enable paid messages in this chat */
169
+ get paidMessagesAvailable(): boolean;
168
170
  }
@@ -165,4 +165,6 @@ export declare class FullChat extends Chat {
165
165
  get starGiftsAvailable(): boolean;
166
166
  /** Number of star gifts available in this chat */
167
167
  get starGiftsCount(): number;
168
+ /** Whether you can enable paid messages in this chat */
169
+ get paidMessagesAvailable(): boolean;
168
170
  }
@@ -299,6 +299,10 @@ class FullChat extends Chat$2 {
299
299
  get starGiftsCount() {
300
300
  return this.full._ === "channelFull" ? this.full.stargiftsCount ?? 0 : 0;
301
301
  }
302
+ /** Whether you can enable paid messages in this chat */
303
+ get paidMessagesAvailable() {
304
+ return this.full._ === "channelFull" && this.full.paidMessagesAvailable;
305
+ }
302
306
  }
303
307
  const FullChat$1 = /* @__PURE__ */ memoizeGetters(FullChat, [
304
308
  "fullPhoto",
@@ -14,6 +14,7 @@ export * from './chatlist-preview.js';
14
14
  export * from './forum-topic.js';
15
15
  export * from './full-chat.js';
16
16
  export * from './full-user.js';
17
+ export * from './peer-settings.js';
17
18
  export * from './peer.js';
18
19
  export * from './peers-index.js';
19
20
  export * from './typing-status.js';
@@ -14,6 +14,7 @@ export * from './chatlist-preview.js';
14
14
  export * from './forum-topic.js';
15
15
  export * from './full-chat.js';
16
16
  export * from './full-user.js';
17
+ export * from './peer-settings.js';
17
18
  export * from './peer.js';
18
19
  export * from './peers-index.js';
19
20
  export * from './typing-status.js';