@mtcute/core 0.31.0 → 0.32.1

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 (154) hide show
  1. package/client.cjs +12 -0
  2. package/client.js +12 -0
  3. package/highlevel/client.d.cts +79 -10
  4. package/highlevel/client.d.ts +79 -10
  5. package/highlevel/methods/chats/build-peers-index.cjs +45 -0
  6. package/highlevel/methods/chats/build-peers-index.d.cts +13 -0
  7. package/highlevel/methods/chats/build-peers-index.d.ts +13 -0
  8. package/highlevel/methods/chats/build-peers-index.js +40 -0
  9. package/highlevel/methods/ephemeral/delete-all-welcome-messages.cjs +17 -0
  10. package/highlevel/methods/ephemeral/delete-all-welcome-messages.d.cts +8 -0
  11. package/highlevel/methods/ephemeral/delete-all-welcome-messages.d.ts +8 -0
  12. package/highlevel/methods/ephemeral/delete-all-welcome-messages.js +12 -0
  13. package/highlevel/methods/ephemeral/delete-ephemeral-message.cjs +1 -1
  14. package/highlevel/methods/ephemeral/delete-ephemeral-message.d.cts +2 -2
  15. package/highlevel/methods/ephemeral/delete-ephemeral-message.d.ts +2 -2
  16. package/highlevel/methods/ephemeral/delete-ephemeral-message.js +1 -1
  17. package/highlevel/methods/ephemeral/delete-welcome-message.cjs +18 -0
  18. package/highlevel/methods/ephemeral/delete-welcome-message.d.cts +9 -0
  19. package/highlevel/methods/ephemeral/delete-welcome-message.d.ts +9 -0
  20. package/highlevel/methods/ephemeral/delete-welcome-message.js +13 -0
  21. package/highlevel/methods/ephemeral/edit-ephemeral-message.cjs +11 -3
  22. package/highlevel/methods/ephemeral/edit-ephemeral-message.d.cts +16 -2
  23. package/highlevel/methods/ephemeral/edit-ephemeral-message.d.ts +16 -2
  24. package/highlevel/methods/ephemeral/edit-ephemeral-message.js +11 -3
  25. package/highlevel/methods/ephemeral/get-welcome-messages.cjs +29 -0
  26. package/highlevel/methods/ephemeral/get-welcome-messages.d.cts +8 -0
  27. package/highlevel/methods/ephemeral/get-welcome-messages.d.ts +8 -0
  28. package/highlevel/methods/ephemeral/get-welcome-messages.js +24 -0
  29. package/highlevel/methods/ephemeral/send-ephemeral-message.cjs +13 -3
  30. package/highlevel/methods/ephemeral/send-ephemeral-message.d.cts +20 -2
  31. package/highlevel/methods/ephemeral/send-ephemeral-message.d.ts +20 -2
  32. package/highlevel/methods/ephemeral/send-ephemeral-message.js +13 -3
  33. package/highlevel/methods/files/download-iterable.cjs +3 -0
  34. package/highlevel/methods/files/download-iterable.js +3 -0
  35. package/highlevel/methods/files/normalize-input-media.cjs +25 -4
  36. package/highlevel/methods/files/normalize-input-media.js +25 -4
  37. package/highlevel/methods/forums/edit-forum-topic.cjs +1 -1
  38. package/highlevel/methods/forums/edit-forum-topic.js +1 -1
  39. package/highlevel/methods/forums/toggle-forum-topic-closed.cjs +1 -1
  40. package/highlevel/methods/forums/toggle-forum-topic-closed.js +1 -1
  41. package/highlevel/methods/forums/toggle-general-topic-hidden.cjs +1 -1
  42. package/highlevel/methods/forums/toggle-general-topic-hidden.js +1 -1
  43. package/highlevel/methods/gifts/buy-resale-gift.cjs +5 -2
  44. package/highlevel/methods/gifts/buy-resale-gift.d.cts +11 -1
  45. package/highlevel/methods/gifts/buy-resale-gift.d.ts +11 -1
  46. package/highlevel/methods/gifts/buy-resale-gift.js +5 -2
  47. package/highlevel/methods/messages/edit-message.cjs +7 -1
  48. package/highlevel/methods/messages/edit-message.d.cts +6 -2
  49. package/highlevel/methods/messages/edit-message.d.ts +6 -2
  50. package/highlevel/methods/messages/edit-message.js +7 -1
  51. package/highlevel/methods/messages/edit-message.test.d.cts +1 -0
  52. package/highlevel/methods/messages/edit-message.test.d.ts +1 -0
  53. package/highlevel/methods/messages/forward-messages.cjs +1 -0
  54. package/highlevel/methods/messages/forward-messages.d.cts +2 -0
  55. package/highlevel/methods/messages/forward-messages.d.ts +2 -0
  56. package/highlevel/methods/messages/forward-messages.js +1 -0
  57. package/highlevel/methods/messages/normalize-rich-message.cjs +3 -0
  58. package/highlevel/methods/messages/normalize-rich-message.js +3 -0
  59. package/highlevel/methods/messages/send-text.cjs +2 -33
  60. package/highlevel/methods/messages/send-text.js +2 -33
  61. package/highlevel/methods/messages/send-typing.d.cts +3 -3
  62. package/highlevel/methods/messages/send-typing.d.ts +3 -3
  63. package/highlevel/methods/messages/set-typing.cjs +1 -1
  64. package/highlevel/methods/messages/set-typing.d.cts +2 -2
  65. package/highlevel/methods/messages/set-typing.d.ts +2 -2
  66. package/highlevel/methods/messages/set-typing.js +1 -1
  67. package/highlevel/methods.d.cts +3 -0
  68. package/highlevel/methods.d.ts +3 -0
  69. package/highlevel/types/bots/keyboards/builder.cjs +5 -5
  70. package/highlevel/types/bots/keyboards/builder.d.cts +8 -9
  71. package/highlevel/types/bots/keyboards/builder.d.ts +8 -9
  72. package/highlevel/types/bots/keyboards/builder.js +5 -5
  73. package/highlevel/types/bots/keyboards/factories.cjs +51 -103
  74. package/highlevel/types/bots/keyboards/factories.d.cts +58 -89
  75. package/highlevel/types/bots/keyboards/factories.d.ts +58 -89
  76. package/highlevel/types/bots/keyboards/factories.js +51 -103
  77. package/highlevel/types/bots/keyboards/index.d.cts +3 -3
  78. package/highlevel/types/bots/keyboards/index.d.ts +3 -3
  79. package/highlevel/types/bots/keyboards/normalize.cjs +131 -0
  80. package/highlevel/types/bots/keyboards/normalize.d.cts +10 -0
  81. package/highlevel/types/bots/keyboards/normalize.d.ts +10 -0
  82. package/highlevel/types/bots/keyboards/normalize.js +126 -0
  83. package/highlevel/types/bots/keyboards/types.d.cts +160 -4
  84. package/highlevel/types/bots/keyboards/types.d.ts +160 -4
  85. package/highlevel/types/messages/dialog.cjs +8 -1
  86. package/highlevel/types/messages/dialog.d.cts +3 -0
  87. package/highlevel/types/messages/dialog.d.ts +3 -0
  88. package/highlevel/types/messages/dialog.js +8 -1
  89. package/highlevel/types/messages/dialog.test.d.cts +1 -0
  90. package/highlevel/types/messages/dialog.test.d.ts +1 -0
  91. package/highlevel/types/messages/ephemeral-message.cjs +35 -3
  92. package/highlevel/types/messages/ephemeral-message.d.cts +22 -2
  93. package/highlevel/types/messages/ephemeral-message.d.ts +22 -2
  94. package/highlevel/types/messages/ephemeral-message.js +35 -3
  95. package/highlevel/types/messages/message-action.cjs +8 -1
  96. package/highlevel/types/messages/message-action.d.cts +11 -1
  97. package/highlevel/types/messages/message-action.d.ts +11 -1
  98. package/highlevel/types/messages/message-action.js +8 -1
  99. package/highlevel/types/messages/message.cjs +7 -2
  100. package/highlevel/types/messages/message.d.cts +2 -2
  101. package/highlevel/types/messages/message.d.ts +2 -2
  102. package/highlevel/types/messages/message.js +8 -3
  103. package/highlevel/types/messages/rich/inner.cjs +37 -0
  104. package/highlevel/types/messages/rich/inner.d.cts +19 -0
  105. package/highlevel/types/messages/rich/inner.d.ts +19 -0
  106. package/highlevel/types/messages/rich/inner.js +37 -0
  107. package/highlevel/types/peers/full-chat.cjs +4 -0
  108. package/highlevel/types/peers/full-chat.d.cts +2 -0
  109. package/highlevel/types/peers/full-chat.d.ts +2 -0
  110. package/highlevel/types/peers/full-chat.js +4 -0
  111. package/highlevel/types/peers/typing-status.d.cts +4 -1
  112. package/highlevel/types/peers/typing-status.d.ts +4 -1
  113. package/highlevel/types/updates/ephemeral-callback-query.cjs +10 -2
  114. package/highlevel/types/updates/ephemeral-callback-query.d.cts +8 -2
  115. package/highlevel/types/updates/ephemeral-callback-query.d.ts +8 -2
  116. package/highlevel/types/updates/ephemeral-callback-query.js +10 -2
  117. package/highlevel/types/updates/user-typing-update.cjs +18 -0
  118. package/highlevel/types/updates/user-typing-update.d.cts +9 -0
  119. package/highlevel/types/updates/user-typing-update.d.ts +9 -0
  120. package/highlevel/types/updates/user-typing-update.js +18 -0
  121. package/highlevel/updates/manager.cjs +40 -28
  122. package/highlevel/updates/manager.js +40 -28
  123. package/highlevel/utils/walk-page-blocks.cjs +5 -0
  124. package/highlevel/utils/walk-page-blocks.js +5 -0
  125. package/methods.cjs +6 -0
  126. package/methods.js +6 -0
  127. package/network/mtproto-session.cjs +9 -2
  128. package/network/mtproto-session.d.cts +3 -1
  129. package/network/mtproto-session.d.ts +3 -1
  130. package/network/mtproto-session.js +9 -2
  131. package/network/network-manager.cjs +1 -1
  132. package/network/network-manager.js +1 -1
  133. package/network/session-connection.cjs +12 -6
  134. package/network/session-connection.js +12 -6
  135. package/network/session-connection.test.d.cts +1 -0
  136. package/network/session-connection.test.d.ts +1 -0
  137. package/package.json +3 -3
  138. package/tl/api-schema.json +1 -1
  139. package/tl/binary/reader.cjs +136 -93
  140. package/tl/binary/reader.js +136 -93
  141. package/tl/binary/writer.cjs +318 -207
  142. package/tl/binary/writer.js +318 -207
  143. package/tl/compat/reader.cjs +82 -0
  144. package/tl/compat/reader.js +82 -0
  145. package/tl/index.d.cts +377 -718
  146. package/tl/index.d.ts +377 -718
  147. package/tl/inner-tl.cjs +23 -7
  148. package/tl/inner-tl.js +23 -7
  149. package/tl/rpc-error.test.d.cts +1 -0
  150. package/tl/rpc-error.test.d.ts +1 -0
  151. package/utils/binary/compat.cjs +175 -29
  152. package/utils/binary/compat.js +175 -29
  153. package/utils/links/bots.cjs +9 -4
  154. package/utils/links/bots.js +9 -4
@@ -8,7 +8,7 @@ async function toggleForumTopicClosed(client, parmas) {
8
8
  topicId: typeof topicId === "number" ? topicId : topicId.id,
9
9
  closed
10
10
  });
11
- return _findMessageInUpdate(client, res, false, shouldDispatch);
11
+ return _findMessageInUpdate(client, res, false, !shouldDispatch);
12
12
  }
13
13
  export {
14
14
  toggleForumTopicClosed
@@ -15,6 +15,6 @@ async function toggleGeneralTopicHidden(client, params) {
15
15
  topicId: 1,
16
16
  hidden
17
17
  });
18
- return findInUpdate._findMessageInUpdate(client, res, false, shouldDispatch);
18
+ return findInUpdate._findMessageInUpdate(client, res, false, !shouldDispatch);
19
19
  }
20
20
  exports.toggleGeneralTopicHidden = toggleGeneralTopicHidden;
@@ -8,7 +8,7 @@ async function toggleGeneralTopicHidden(client, params) {
8
8
  topicId: 1,
9
9
  hidden
10
10
  });
11
- return _findMessageInUpdate(client, res, false, shouldDispatch);
11
+ return _findMessageInUpdate(client, res, false, !shouldDispatch);
12
12
  }
13
13
  export {
14
14
  toggleGeneralTopicHidden
@@ -6,15 +6,18 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const typeAssertions = require("../../../utils/type-assertions.cjs");
9
+ const entities = require("../../types/misc/entities.cjs");
9
10
  const findInUpdate = require("../messages/find-in-update.cjs");
10
11
  const resolvePeer = require("../users/resolve-peer.cjs");
11
12
  async function buyResaleGift(client, params) {
12
- const { slug, recipient, shouldDispatch, ton } = params;
13
+ const { slug, recipient, shouldDispatch, ton, anonymous, message } = params;
13
14
  const invoice = {
14
15
  _: "inputInvoiceStarGiftResale",
15
16
  slug,
16
17
  toId: await resolvePeer.resolvePeer(client, recipient),
17
- ton
18
+ ton,
19
+ showName: anonymous === false,
20
+ message: message ? entities.inputTextToTl(message) : void 0
18
21
  };
19
22
  const form = await client.call({
20
23
  _: "payments.getPaymentForm",
@@ -1,5 +1,5 @@
1
1
  import { ITelegramClient } from '../../client.types.js';
2
- import { InputPeerLike, Message } from '../../types/index.js';
2
+ import { InputPeerLike, InputText, Message } from '../../types/index.js';
3
3
  export declare function buyResaleGift(client: ITelegramClient, params: {
4
4
  /** Slug of the star gift to buy */
5
5
  slug: string;
@@ -12,4 +12,14 @@ export declare function buyResaleGift(client: ITelegramClient, params: {
12
12
  shouldDispatch?: true;
13
13
  /** Whether to use TON currency for payment */
14
14
  ton?: boolean;
15
+ /**
16
+ * Whether to buy the gift anonymously
17
+ * (i.e. if the recipient chooses to display the gift
18
+ * on their profile, your name won't be visible)
19
+ *
20
+ * @default `true`
21
+ */
22
+ anonymous?: boolean;
23
+ /** Message to send along with the gift */
24
+ message?: InputText;
15
25
  }): Promise<Message | null>;
@@ -1,5 +1,5 @@
1
1
  import { ITelegramClient } from '../../client.types.js';
2
- import { InputPeerLike, Message } from '../../types/index.js';
2
+ import { InputPeerLike, InputText, Message } from '../../types/index.js';
3
3
  export declare function buyResaleGift(client: ITelegramClient, params: {
4
4
  /** Slug of the star gift to buy */
5
5
  slug: string;
@@ -12,4 +12,14 @@ export declare function buyResaleGift(client: ITelegramClient, params: {
12
12
  shouldDispatch?: true;
13
13
  /** Whether to use TON currency for payment */
14
14
  ton?: boolean;
15
+ /**
16
+ * Whether to buy the gift anonymously
17
+ * (i.e. if the recipient chooses to display the gift
18
+ * on their profile, your name won't be visible)
19
+ *
20
+ * @default `true`
21
+ */
22
+ anonymous?: boolean;
23
+ /** Message to send along with the gift */
24
+ message?: InputText;
15
25
  }): Promise<Message | null>;
@@ -1,13 +1,16 @@
1
1
  import { assertTypeIs } from "../../../utils/type-assertions.js";
2
+ import { inputTextToTl } from "../../types/misc/entities.js";
2
3
  import { _findMessageInUpdate } from "../messages/find-in-update.js";
3
4
  import { resolvePeer } from "../users/resolve-peer.js";
4
5
  async function buyResaleGift(client, params) {
5
- const { slug, recipient, shouldDispatch, ton } = params;
6
+ const { slug, recipient, shouldDispatch, ton, anonymous, message } = params;
6
7
  const invoice = {
7
8
  _: "inputInvoiceStarGiftResale",
8
9
  slug,
9
10
  toId: await resolvePeer(client, recipient),
10
- ton
11
+ ton,
12
+ showName: anonymous === false,
13
+ message: message ? inputTextToTl(message) : void 0
11
14
  };
12
15
  const form = await client.call({
13
16
  _: "payments.getPaymentForm",
@@ -9,6 +9,7 @@ const normalizeInputMedia = require("../files/normalize-input-media.cjs");
9
9
  const normalizeText = require("../misc/normalize-text.cjs");
10
10
  const resolvePeer = require("../users/resolve-peer.cjs");
11
11
  const findInUpdate = require("./find-in-update.cjs");
12
+ const normalizeRichMessage = require("./normalize-rich-message.cjs");
12
13
  const inputMessageId = require("../../types/messages/input-message-id.cjs");
13
14
  const factories = require("../../types/bots/keyboards/factories.cjs");
14
15
  async function editMessage(client, params) {
@@ -16,6 +17,7 @@ async function editMessage(client, params) {
16
17
  let content;
17
18
  let entities;
18
19
  let media;
20
+ const peer = await resolvePeer.resolvePeer(client, chatId);
19
21
  if (params.media) {
20
22
  media = await normalizeInputMedia._normalizeInputMedia(client, params.media, params);
21
23
  if ("caption" in params.media && params.media.caption !== void 0) {
@@ -28,12 +30,16 @@ async function editMessage(client, params) {
28
30
  const res = await client.call({
29
31
  _: "messages.editMessage",
30
32
  id: message,
31
- peer: await resolvePeer.resolvePeer(client, chatId),
33
+ peer,
32
34
  noWebpage: params.disableWebPreview,
33
35
  replyMarkup: factories._convertToTl(params.replyMarkup),
34
36
  message: content,
35
37
  entities,
36
38
  media,
39
+ richMessage: params.richMessage ? await normalizeRichMessage._normalizeInputRichMessage(client, peer, params.richMessage, {
40
+ progressCallback: params.progressCallback ? (_id, uploaded, total) => params.progressCallback?.(uploaded, total) : void 0,
41
+ uploadCache: params.uploadCache
42
+ }) : void 0,
37
43
  invertMedia: params.invertMedia
38
44
  }, {
39
45
  businessConnectionId: params.businessConnectionId
@@ -1,5 +1,5 @@
1
1
  import { ITelegramClient } from '../../client.types.js';
2
- import { InputMediaLike, InputMessageId, InputText, Message, ReplyMarkup } from '../../types/index.js';
2
+ import { InputMediaLike, InputMessageId, InputRichMessage, InputText, Message, ReplyMarkup, RichMediaUploadCache } from '../../types/index.js';
3
3
  /**
4
4
  * Edit message text, media, reply markup and schedule date.
5
5
  *
@@ -18,6 +18,8 @@ export declare function editMessage(client: ITelegramClient, params: InputMessag
18
18
  * New message media
19
19
  */
20
20
  media?: InputMediaLike;
21
+ /** New rich message content */
22
+ richMessage?: InputRichMessage;
21
23
  /**
22
24
  * Whether to disable links preview in this message
23
25
  */
@@ -33,12 +35,14 @@ export declare function editMessage(client: ITelegramClient, params: InputMessag
33
35
  */
34
36
  scheduleDate?: Date | number;
35
37
  /**
36
- * For media, upload progress callback.
38
+ * For media and rich message attachments, upload progress callback.
37
39
  *
38
40
  * @param uploaded Number of bytes uploaded
39
41
  * @param total Total file size in bytes
40
42
  */
41
43
  progressCallback?: (uploaded: number, total: number) => void;
44
+ /** Cache for uploaded rich message media, see {@link createRichStreamingDraft} */
45
+ uploadCache?: RichMediaUploadCache;
42
46
  /**
43
47
  * Whether to dispatch the edit message event
44
48
  * to the client's update handler.
@@ -1,5 +1,5 @@
1
1
  import { ITelegramClient } from '../../client.types.js';
2
- import { InputMediaLike, InputMessageId, InputText, Message, ReplyMarkup } from '../../types/index.js';
2
+ import { InputMediaLike, InputMessageId, InputRichMessage, InputText, Message, ReplyMarkup, RichMediaUploadCache } from '../../types/index.js';
3
3
  /**
4
4
  * Edit message text, media, reply markup and schedule date.
5
5
  *
@@ -18,6 +18,8 @@ export declare function editMessage(client: ITelegramClient, params: InputMessag
18
18
  * New message media
19
19
  */
20
20
  media?: InputMediaLike;
21
+ /** New rich message content */
22
+ richMessage?: InputRichMessage;
21
23
  /**
22
24
  * Whether to disable links preview in this message
23
25
  */
@@ -33,12 +35,14 @@ export declare function editMessage(client: ITelegramClient, params: InputMessag
33
35
  */
34
36
  scheduleDate?: Date | number;
35
37
  /**
36
- * For media, upload progress callback.
38
+ * For media and rich message attachments, upload progress callback.
37
39
  *
38
40
  * @param uploaded Number of bytes uploaded
39
41
  * @param total Total file size in bytes
40
42
  */
41
43
  progressCallback?: (uploaded: number, total: number) => void;
44
+ /** Cache for uploaded rich message media, see {@link createRichStreamingDraft} */
45
+ uploadCache?: RichMediaUploadCache;
42
46
  /**
43
47
  * Whether to dispatch the edit message event
44
48
  * to the client's update handler.
@@ -2,6 +2,7 @@ import { _normalizeInputMedia } from "../files/normalize-input-media.js";
2
2
  import { _normalizeInputText } from "../misc/normalize-text.js";
3
3
  import { resolvePeer } from "../users/resolve-peer.js";
4
4
  import { _findMessageInUpdate } from "./find-in-update.js";
5
+ import { _normalizeInputRichMessage } from "./normalize-rich-message.js";
5
6
  import { normalizeInputMessageId } from "../../types/messages/input-message-id.js";
6
7
  import { _convertToTl } from "../../types/bots/keyboards/factories.js";
7
8
  async function editMessage(client, params) {
@@ -9,6 +10,7 @@ async function editMessage(client, params) {
9
10
  let content;
10
11
  let entities;
11
12
  let media;
13
+ const peer = await resolvePeer(client, chatId);
12
14
  if (params.media) {
13
15
  media = await _normalizeInputMedia(client, params.media, params);
14
16
  if ("caption" in params.media && params.media.caption !== void 0) {
@@ -21,12 +23,16 @@ async function editMessage(client, params) {
21
23
  const res = await client.call({
22
24
  _: "messages.editMessage",
23
25
  id: message,
24
- peer: await resolvePeer(client, chatId),
26
+ peer,
25
27
  noWebpage: params.disableWebPreview,
26
28
  replyMarkup: _convertToTl(params.replyMarkup),
27
29
  message: content,
28
30
  entities,
29
31
  media,
32
+ richMessage: params.richMessage ? await _normalizeInputRichMessage(client, peer, params.richMessage, {
33
+ progressCallback: params.progressCallback ? (_id, uploaded, total) => params.progressCallback?.(uploaded, total) : void 0,
34
+ uploadCache: params.uploadCache
35
+ }) : void 0,
30
36
  invertMedia: params.invertMedia
31
37
  }, {
32
38
  businessConnectionId: params.businessConnectionId
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -51,6 +51,7 @@ async function forwardMessagesById(client, params) {
51
51
  allowPaidFloodskip,
52
52
  videoTimestamp,
53
53
  allowPaidStars: params.allowPaidMessages,
54
+ fromEphemeral: params.fromEphemeral,
54
55
  topMsgId: toThreadId,
55
56
  replyTo: toMonoforumPeer ? {
56
57
  _: "inputReplyToMonoForum",
@@ -72,6 +72,8 @@ export interface ForwardMessageOptions {
72
72
  allowPaidMessages?: tl.Long;
73
73
  /** Video timestamp to use for the forwarded video */
74
74
  videoTimestamp?: number;
75
+ /** Whether the messages being forwarded are ephemeral messages */
76
+ fromEphemeral?: boolean;
75
77
  }
76
78
  /**
77
79
  * Forward one or more messages by their IDs.
@@ -72,6 +72,8 @@ export interface ForwardMessageOptions {
72
72
  allowPaidMessages?: tl.Long;
73
73
  /** Video timestamp to use for the forwarded video */
74
74
  videoTimestamp?: number;
75
+ /** Whether the messages being forwarded are ephemeral messages */
76
+ fromEphemeral?: boolean;
75
77
  }
76
78
  /**
77
79
  * Forward one or more messages by their IDs.
@@ -44,6 +44,7 @@ async function forwardMessagesById(client, params) {
44
44
  allowPaidFloodskip,
45
45
  videoTimestamp,
46
46
  allowPaidStars: params.allowPaidMessages,
47
+ fromEphemeral: params.fromEphemeral,
47
48
  topMsgId: toThreadId,
48
49
  replyTo: toMonoforumPeer ? {
49
50
  _: "inputReplyToMonoForum",
@@ -150,6 +150,9 @@ async function _normalizeInputRichMessage(client, peer, input, params) {
150
150
  case "pageBlockAudio":
151
151
  block.audioId = document.id;
152
152
  break;
153
+ case "pageBlockDocument":
154
+ block.documentId = document.id;
155
+ break;
153
156
  default:
154
157
  throw new errors.MtArgumentError(`sendRichMessage: expected document ${document.id} to be used in a document block, but got ${block._}`);
155
158
  }
@@ -143,6 +143,9 @@ async function _normalizeInputRichMessage(client, peer, input, params) {
143
143
  case "pageBlockAudio":
144
144
  block.audioId = document.id;
145
145
  break;
146
+ case "pageBlockDocument":
147
+ block.documentId = document.id;
148
+ break;
146
149
  default:
147
150
  throw new MtArgumentError(`sendRichMessage: expected document ${document.id} to be used in a document block, but got ${block._}`);
148
151
  }
@@ -5,19 +5,17 @@ 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 errors = require("../../../types/errors.cjs");
9
8
  const longUtils = require("../../../utils/long-utils.cjs");
10
9
  const peerUtils$1 = require("../../../utils/peer-utils.cjs");
11
10
  const message = require("../../types/messages/message.cjs");
12
11
  const utils = require("../../updates/utils.cjs");
13
12
  const peerUtils = require("../../utils/peer-utils.cjs");
14
- const batchedQueries = require("../chats/batched-queries.cjs");
13
+ const buildPeersIndex = require("../chats/build-peers-index.cjs");
15
14
  const normalizeText = require("../misc/normalize-text.cjs");
16
15
  const resolvePeer = require("../users/resolve-peer.cjs");
17
16
  const findInUpdate = require("./find-in-update.cjs");
18
17
  const sendCommon = require("./send-common.cjs");
19
18
  const factories = require("../../types/bots/keyboards/factories.cjs");
20
- const peersIndex = require("../../types/peers/peers-index.cjs");
21
19
  function _inputReplyToToHeader(replyTo, peer) {
22
20
  if (!replyTo) return [void 0, void 0];
23
21
  switch (replyTo._) {
@@ -123,35 +121,6 @@ async function sendText(client, chatId, text, params) {
123
121
  if (!params.shouldDispatch) {
124
122
  client.handleClientUpdate(utils.createDummyUpdate(res.pts, res.ptsCount));
125
123
  }
126
- const peers = new peersIndex.PeersIndex();
127
- const fetchPeer = async (peer2) => {
128
- const id = peerUtils$1.getMarkedPeerId(peer2);
129
- let cached = await client.storage.peers.getCompleteById(id);
130
- if (!cached) {
131
- cached = await batchedQueries._getRawPeerBatched(client, await resolvePeer.resolvePeer(client, peer2));
132
- }
133
- if (!cached) {
134
- throw new errors.MtTypeAssertionError("sendText (@ getFullPeerById)", "user | chat", "null");
135
- }
136
- switch (cached._) {
137
- case "user":
138
- peers.users.set(cached.id, cached);
139
- break;
140
- case "chat":
141
- case "chatForbidden":
142
- case "channel":
143
- case "channelForbidden":
144
- peers.chats.set(cached.id, cached);
145
- break;
146
- default:
147
- throw new errors.MtTypeAssertionError(
148
- "sendText (@ users.getUsers)",
149
- "user | chat | channel",
150
- // not very accurate, but good enough
151
- cached._
152
- );
153
- }
154
- };
155
124
  const peersToFetch = [peer, msg2.fromId];
156
125
  if (savedPeerId) peersToFetch.push(savedPeerId);
157
126
  if (replyToHeader?._ === "messageReplyHeader" && replyToHeader.replyToPeerId) {
@@ -159,7 +128,7 @@ async function sendText(client, chatId, text, params) {
159
128
  } else if (replyToHeader?._ === "messageReplyStoryHeader") {
160
129
  peersToFetch.push(replyToHeader.peer);
161
130
  }
162
- await Promise.all(peersToFetch.map(fetchPeer));
131
+ const peers = await buildPeersIndex._buildPeersIndex(client, "sendText", peersToFetch);
163
132
  if (replyToHeader?._ === "messageReplyHeader" && replyToHeader.replyToTopId && replyToHeader.replyToTopId !== 1 && msg2.peerId._ === "peerChannel") {
164
133
  const chat = peers.chats.get(msg2.peerId.channelId);
165
134
  if (chat?._ === "channel" && chat.forum) {
@@ -1,16 +1,14 @@
1
- import { MtTypeAssertionError } from "../../../types/errors.js";
2
1
  import { randomLong } from "../../../utils/long-utils.js";
3
2
  import { getMarkedPeerId } from "../../../utils/peer-utils.js";
4
3
  import { Message as Message$2 } from "../../types/messages/message.js";
5
4
  import { createDummyUpdate } from "../../updates/utils.js";
6
5
  import { inputPeerToPeer } from "../../utils/peer-utils.js";
7
- import { _getRawPeerBatched } from "../chats/batched-queries.js";
6
+ import { _buildPeersIndex } from "../chats/build-peers-index.js";
8
7
  import { _normalizeInputText } from "../misc/normalize-text.js";
9
8
  import { resolvePeer } from "../users/resolve-peer.js";
10
9
  import { _findMessageInUpdate } from "./find-in-update.js";
11
10
  import { _processCommonSendParameters } from "./send-common.js";
12
11
  import { _convertToTl } from "../../types/bots/keyboards/factories.js";
13
- import { PeersIndex } from "../../types/peers/peers-index.js";
14
12
  function _inputReplyToToHeader(replyTo, peer) {
15
13
  if (!replyTo) return [void 0, void 0];
16
14
  switch (replyTo._) {
@@ -116,35 +114,6 @@ async function sendText(client, chatId, text, params) {
116
114
  if (!params.shouldDispatch) {
117
115
  client.handleClientUpdate(createDummyUpdate(res.pts, res.ptsCount));
118
116
  }
119
- const peers = new PeersIndex();
120
- const fetchPeer = async (peer2) => {
121
- const id = getMarkedPeerId(peer2);
122
- let cached = await client.storage.peers.getCompleteById(id);
123
- if (!cached) {
124
- cached = await _getRawPeerBatched(client, await resolvePeer(client, peer2));
125
- }
126
- if (!cached) {
127
- throw new MtTypeAssertionError("sendText (@ getFullPeerById)", "user | chat", "null");
128
- }
129
- switch (cached._) {
130
- case "user":
131
- peers.users.set(cached.id, cached);
132
- break;
133
- case "chat":
134
- case "chatForbidden":
135
- case "channel":
136
- case "channelForbidden":
137
- peers.chats.set(cached.id, cached);
138
- break;
139
- default:
140
- throw new MtTypeAssertionError(
141
- "sendText (@ users.getUsers)",
142
- "user | chat | channel",
143
- // not very accurate, but good enough
144
- cached._
145
- );
146
- }
147
- };
148
117
  const peersToFetch = [peer, msg2.fromId];
149
118
  if (savedPeerId) peersToFetch.push(savedPeerId);
150
119
  if (replyToHeader?._ === "messageReplyHeader" && replyToHeader.replyToPeerId) {
@@ -152,7 +121,7 @@ async function sendText(client, chatId, text, params) {
152
121
  } else if (replyToHeader?._ === "messageReplyStoryHeader") {
153
122
  peersToFetch.push(replyToHeader.peer);
154
123
  }
155
- await Promise.all(peersToFetch.map(fetchPeer));
124
+ const peers = await _buildPeersIndex(client, "sendText", peersToFetch);
156
125
  if (replyToHeader?._ === "messageReplyHeader" && replyToHeader.replyToTopId && replyToHeader.replyToTopId !== 1 && msg2.peerId._ === "peerChannel") {
157
126
  const chat = peers.chats.get(msg2.peerId.channelId);
158
127
  if (chat?._ === "channel" && chat.forum) {
@@ -1,7 +1,7 @@
1
1
  import { tl } from '../../../tl/index.js';
2
2
  import { ITelegramClient } from '../../client.types.js';
3
- import { InputPeerLike, TypingStatus } from '../../types/index.js';
4
- export declare function _mapTypingStatus(status: Exclude<TypingStatus, 'interaction' | 'interaction_seen'>, progress?: number): tl.TypeSendMessageAction;
3
+ import { InputPeerLike, SendableTypingStatus } from '../../types/index.js';
4
+ export declare function _mapTypingStatus(status: SendableTypingStatus, progress?: number): tl.TypeSendMessageAction;
5
5
  /**
6
6
  * Sends a current user/bot typing event
7
7
  * to a conversation partner or group.
@@ -16,7 +16,7 @@ export declare function _mapTypingStatus(status: Exclude<TypingStatus, 'interact
16
16
  * @param status Typing status
17
17
  * @param params
18
18
  */
19
- export declare function sendTyping(client: ITelegramClient, chatId: InputPeerLike, status?: Exclude<TypingStatus, 'interaction' | 'interaction_seen'> | tl.TypeSendMessageAction, params?: {
19
+ export declare function sendTyping(client: ITelegramClient, chatId: InputPeerLike, status?: SendableTypingStatus | tl.TypeSendMessageAction, params?: {
20
20
  /**
21
21
  * For `upload_*` and history import actions, progress of the upload
22
22
  */
@@ -1,7 +1,7 @@
1
1
  import { tl } from '../../../tl/index.js';
2
2
  import { ITelegramClient } from '../../client.types.js';
3
- import { InputPeerLike, TypingStatus } from '../../types/index.js';
4
- export declare function _mapTypingStatus(status: Exclude<TypingStatus, 'interaction' | 'interaction_seen'>, progress?: number): tl.TypeSendMessageAction;
3
+ import { InputPeerLike, SendableTypingStatus } from '../../types/index.js';
4
+ export declare function _mapTypingStatus(status: SendableTypingStatus, progress?: number): tl.TypeSendMessageAction;
5
5
  /**
6
6
  * Sends a current user/bot typing event
7
7
  * to a conversation partner or group.
@@ -16,7 +16,7 @@ export declare function _mapTypingStatus(status: Exclude<TypingStatus, 'interact
16
16
  * @param status Typing status
17
17
  * @param params
18
18
  */
19
- export declare function sendTyping(client: ITelegramClient, chatId: InputPeerLike, status?: Exclude<TypingStatus, 'interaction' | 'interaction_seen'> | tl.TypeSendMessageAction, params?: {
19
+ export declare function sendTyping(client: ITelegramClient, chatId: InputPeerLike, status?: SendableTypingStatus | tl.TypeSendMessageAction, params?: {
20
20
  /**
21
21
  * For `upload_*` and history import actions, progress of the upload
22
22
  */
@@ -21,7 +21,7 @@ async function setTyping(client, params) {
21
21
  threadId
22
22
  } = params;
23
23
  let status = params.status ?? "typing";
24
- if (typeof status === "string") status = sendTyping._mapTypingStatus(status);
24
+ if (typeof status === "string") status = sendTyping._mapTypingStatus(status, params.progress ?? 0);
25
25
  const peer = await resolvePeer.resolvePeer(client, peerId);
26
26
  const timerId = _getTypingTimerId(peer, businessConnectionId);
27
27
  await client.timers.cancel(timerId);
@@ -1,7 +1,7 @@
1
1
  import { tl } from '../../../tl/index.js';
2
2
  import { ITelegramClient } from '../../client.types.js';
3
3
  import { InputPeerLike } from '../../types/peers/peer.js';
4
- import { TypingStatus } from '../../types/peers/typing-status.js';
4
+ import { SendableTypingStatus } from '../../types/peers/typing-status.js';
5
5
  export declare function _getTypingTimerId(peer: tl.TypeInputPeer, businessId?: string): string;
6
6
  /**
7
7
  * Sets whether a user is typing in a specific chat
@@ -17,7 +17,7 @@ export declare function setTyping(client: ITelegramClient, params: {
17
17
  *
18
18
  * @default `typing`
19
19
  */
20
- status?: Exclude<TypingStatus, 'interaction' | 'interaction_seen'> | tl.TypeSendMessageAction;
20
+ status?: SendableTypingStatus | tl.TypeSendMessageAction;
21
21
  /**
22
22
  * For `upload_*` and history import actions, progress of the upload
23
23
  */
@@ -1,7 +1,7 @@
1
1
  import { tl } from '../../../tl/index.js';
2
2
  import { ITelegramClient } from '../../client.types.js';
3
3
  import { InputPeerLike } from '../../types/peers/peer.js';
4
- import { TypingStatus } from '../../types/peers/typing-status.js';
4
+ import { SendableTypingStatus } from '../../types/peers/typing-status.js';
5
5
  export declare function _getTypingTimerId(peer: tl.TypeInputPeer, businessId?: string): string;
6
6
  /**
7
7
  * Sets whether a user is typing in a specific chat
@@ -17,7 +17,7 @@ export declare function setTyping(client: ITelegramClient, params: {
17
17
  *
18
18
  * @default `typing`
19
19
  */
20
- status?: Exclude<TypingStatus, 'interaction' | 'interaction_seen'> | tl.TypeSendMessageAction;
20
+ status?: SendableTypingStatus | tl.TypeSendMessageAction;
21
21
  /**
22
22
  * For `upload_*` and history import actions, progress of the upload
23
23
  */
@@ -14,7 +14,7 @@ async function setTyping(client, params) {
14
14
  threadId
15
15
  } = params;
16
16
  let status = params.status ?? "typing";
17
- if (typeof status === "string") status = _mapTypingStatus(status);
17
+ if (typeof status === "string") status = _mapTypingStatus(status, params.progress ?? 0);
18
18
  const peer = await resolvePeer(client, peerId);
19
19
  const timerId = _getTypingTimerId(peer, businessConnectionId);
20
20
  await client.timers.cancel(timerId);
@@ -117,9 +117,12 @@ export { getPeerDialogs } from './methods/dialogs/get-peer-dialogs.js';
117
117
  export { iterDialogs } from './methods/dialogs/iter-dialogs.js';
118
118
  export { joinChatlist } from './methods/dialogs/join-chatlist.js';
119
119
  export { setFoldersOrder } from './methods/dialogs/set-folders-order.js';
120
+ export { deleteAllWelcomeMessages } from './methods/ephemeral/delete-all-welcome-messages.js';
120
121
  export { deleteEphemeralMessage } from './methods/ephemeral/delete-ephemeral-message.js';
122
+ export { deleteWelcomeMessage } from './methods/ephemeral/delete-welcome-message.js';
121
123
  export { editEphemeralMessage } from './methods/ephemeral/edit-ephemeral-message.js';
122
124
  export { getEphemeralCallbackAnswer } from './methods/ephemeral/get-ephemeral-callback-answer.js';
125
+ export { getWelcomeMessages } from './methods/ephemeral/get-welcome-messages.js';
123
126
  export { sendEphemeralMessage } from './methods/ephemeral/send-ephemeral-message.js';
124
127
  export { downloadAsBuffer } from './methods/files/download-buffer.js';
125
128
  export { downloadChunk } from './methods/files/download-chunk.js';
@@ -117,9 +117,12 @@ export { getPeerDialogs } from './methods/dialogs/get-peer-dialogs.js';
117
117
  export { iterDialogs } from './methods/dialogs/iter-dialogs.js';
118
118
  export { joinChatlist } from './methods/dialogs/join-chatlist.js';
119
119
  export { setFoldersOrder } from './methods/dialogs/set-folders-order.js';
120
+ export { deleteAllWelcomeMessages } from './methods/ephemeral/delete-all-welcome-messages.js';
120
121
  export { deleteEphemeralMessage } from './methods/ephemeral/delete-ephemeral-message.js';
122
+ export { deleteWelcomeMessage } from './methods/ephemeral/delete-welcome-message.js';
121
123
  export { editEphemeralMessage } from './methods/ephemeral/edit-ephemeral-message.js';
122
124
  export { getEphemeralCallbackAnswer } from './methods/ephemeral/get-ephemeral-callback-answer.js';
125
+ export { getWelcomeMessages } from './methods/ephemeral/get-welcome-messages.js';
123
126
  export { sendEphemeralMessage } from './methods/ephemeral/send-ephemeral-message.js';
124
127
  export { downloadAsBuffer } from './methods/files/download-buffer.js';
125
128
  export { downloadChunk } from './methods/files/download-chunk.js';
@@ -66,11 +66,11 @@ class BotKeyboardBuilder {
66
66
  /**
67
67
  * Return contents of this builder as an inline keyboard
68
68
  */
69
- asInline() {
70
- return {
71
- type: "inline",
72
- buttons: this._buttons
73
- };
69
+ asInline(params = {}) {
70
+ const ret = params;
71
+ ret.type = "inline";
72
+ ret.buttons = this._buttons;
73
+ return ret;
74
74
  }
75
75
  /**
76
76
  * Return contents of this builder as a reply keyboard
@@ -1,10 +1,9 @@
1
- import { tl } from '../../../../tl/index.js';
2
- import { InlineKeyboardMarkup, ReplyKeyboardMarkup } from './types.js';
3
- export type ButtonLike = tl.TypeKeyboardButton | false | null | undefined | void;
1
+ import { InlineKeyboardMarkup, InputBotKeyboardButton, InputInlineKeyboardButton, InputReplyKeyboardButton, ReplyKeyboardMarkup } from './types.js';
2
+ export type ButtonLike<Button extends InputBotKeyboardButton = InputBotKeyboardButton> = Button | false | null | undefined | void;
4
3
  /**
5
4
  * Builder for bot keyboards
6
5
  */
7
- export declare class BotKeyboardBuilder {
6
+ export declare class BotKeyboardBuilder<Button extends InputBotKeyboardButton = InputInlineKeyboardButton> {
8
7
  readonly maxRowWidth: number | null;
9
8
  private _buttons;
10
9
  constructor(maxRowWidth?: number | null);
@@ -13,26 +12,26 @@ export declare class BotKeyboardBuilder {
13
12
  *
14
13
  * @param buttons Buttons to add
15
14
  */
16
- push(...buttons: (ButtonLike | (() => ButtonLike))[]): this;
15
+ push(...buttons: (ButtonLike<Button> | (() => ButtonLike<Button>))[]): this;
17
16
  /**
18
17
  * Add a row of buttons. Will not be wrapped.
19
18
  *
20
19
  * @param row Row or a function that will populate it
21
20
  */
22
- row(row: ButtonLike[] | ((arr: ButtonLike[]) => void)): this;
21
+ row(row: ButtonLike<Button>[] | ((arr: ButtonLike<Button>[]) => void)): this;
23
22
  /**
24
23
  * Append a button to the last row, wrapping if needed.
25
24
  *
26
25
  * @param btn Button to add
27
26
  * @param force Whether to forcefully add the button (i.e. do not wrap)
28
27
  */
29
- append(btn: ButtonLike | (() => ButtonLike), force?: boolean): this;
28
+ append(btn: ButtonLike<Button> | (() => ButtonLike<Button>), force?: boolean): this;
30
29
  /**
31
30
  * Return contents of this builder as an inline keyboard
32
31
  */
33
- asInline(): InlineKeyboardMarkup;
32
+ asInline(this: BotKeyboardBuilder<InputInlineKeyboardButton>, params?: Omit<InlineKeyboardMarkup, 'type' | 'buttons'>): InlineKeyboardMarkup;
34
33
  /**
35
34
  * Return contents of this builder as a reply keyboard
36
35
  */
37
- asReply(params?: Omit<ReplyKeyboardMarkup, 'type' | 'buttons'>): ReplyKeyboardMarkup;
36
+ asReply(this: BotKeyboardBuilder<InputReplyKeyboardButton>, params?: Omit<ReplyKeyboardMarkup, 'type' | 'buttons'>): ReplyKeyboardMarkup;
38
37
  }