@mtcute/core 0.31.0 → 0.32.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 (148) hide show
  1. package/client.cjs +12 -0
  2. package/client.js +12 -0
  3. package/highlevel/client.d.cts +74 -9
  4. package/highlevel/client.d.ts +74 -9
  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/forward-messages.cjs +1 -0
  48. package/highlevel/methods/messages/forward-messages.d.cts +2 -0
  49. package/highlevel/methods/messages/forward-messages.d.ts +2 -0
  50. package/highlevel/methods/messages/forward-messages.js +1 -0
  51. package/highlevel/methods/messages/normalize-rich-message.cjs +3 -0
  52. package/highlevel/methods/messages/normalize-rich-message.js +3 -0
  53. package/highlevel/methods/messages/send-text.cjs +2 -33
  54. package/highlevel/methods/messages/send-text.js +2 -33
  55. package/highlevel/methods/messages/send-typing.d.cts +3 -3
  56. package/highlevel/methods/messages/send-typing.d.ts +3 -3
  57. package/highlevel/methods/messages/set-typing.cjs +1 -1
  58. package/highlevel/methods/messages/set-typing.d.cts +2 -2
  59. package/highlevel/methods/messages/set-typing.d.ts +2 -2
  60. package/highlevel/methods/messages/set-typing.js +1 -1
  61. package/highlevel/methods.d.cts +3 -0
  62. package/highlevel/methods.d.ts +3 -0
  63. package/highlevel/types/bots/keyboards/builder.cjs +5 -5
  64. package/highlevel/types/bots/keyboards/builder.d.cts +8 -9
  65. package/highlevel/types/bots/keyboards/builder.d.ts +8 -9
  66. package/highlevel/types/bots/keyboards/builder.js +5 -5
  67. package/highlevel/types/bots/keyboards/factories.cjs +51 -103
  68. package/highlevel/types/bots/keyboards/factories.d.cts +58 -89
  69. package/highlevel/types/bots/keyboards/factories.d.ts +58 -89
  70. package/highlevel/types/bots/keyboards/factories.js +51 -103
  71. package/highlevel/types/bots/keyboards/index.d.cts +3 -3
  72. package/highlevel/types/bots/keyboards/index.d.ts +3 -3
  73. package/highlevel/types/bots/keyboards/normalize.cjs +131 -0
  74. package/highlevel/types/bots/keyboards/normalize.d.cts +10 -0
  75. package/highlevel/types/bots/keyboards/normalize.d.ts +10 -0
  76. package/highlevel/types/bots/keyboards/normalize.js +126 -0
  77. package/highlevel/types/bots/keyboards/types.d.cts +160 -4
  78. package/highlevel/types/bots/keyboards/types.d.ts +160 -4
  79. package/highlevel/types/messages/dialog.cjs +8 -1
  80. package/highlevel/types/messages/dialog.d.cts +3 -0
  81. package/highlevel/types/messages/dialog.d.ts +3 -0
  82. package/highlevel/types/messages/dialog.js +8 -1
  83. package/highlevel/types/messages/dialog.test.d.cts +1 -0
  84. package/highlevel/types/messages/dialog.test.d.ts +1 -0
  85. package/highlevel/types/messages/ephemeral-message.cjs +35 -3
  86. package/highlevel/types/messages/ephemeral-message.d.cts +22 -2
  87. package/highlevel/types/messages/ephemeral-message.d.ts +22 -2
  88. package/highlevel/types/messages/ephemeral-message.js +35 -3
  89. package/highlevel/types/messages/message-action.cjs +8 -1
  90. package/highlevel/types/messages/message-action.d.cts +11 -1
  91. package/highlevel/types/messages/message-action.d.ts +11 -1
  92. package/highlevel/types/messages/message-action.js +8 -1
  93. package/highlevel/types/messages/message.cjs +7 -2
  94. package/highlevel/types/messages/message.d.cts +2 -2
  95. package/highlevel/types/messages/message.d.ts +2 -2
  96. package/highlevel/types/messages/message.js +8 -3
  97. package/highlevel/types/messages/rich/inner.cjs +37 -0
  98. package/highlevel/types/messages/rich/inner.d.cts +19 -0
  99. package/highlevel/types/messages/rich/inner.d.ts +19 -0
  100. package/highlevel/types/messages/rich/inner.js +37 -0
  101. package/highlevel/types/peers/full-chat.cjs +4 -0
  102. package/highlevel/types/peers/full-chat.d.cts +2 -0
  103. package/highlevel/types/peers/full-chat.d.ts +2 -0
  104. package/highlevel/types/peers/full-chat.js +4 -0
  105. package/highlevel/types/peers/typing-status.d.cts +4 -1
  106. package/highlevel/types/peers/typing-status.d.ts +4 -1
  107. package/highlevel/types/updates/ephemeral-callback-query.cjs +10 -2
  108. package/highlevel/types/updates/ephemeral-callback-query.d.cts +8 -2
  109. package/highlevel/types/updates/ephemeral-callback-query.d.ts +8 -2
  110. package/highlevel/types/updates/ephemeral-callback-query.js +10 -2
  111. package/highlevel/types/updates/user-typing-update.cjs +18 -0
  112. package/highlevel/types/updates/user-typing-update.d.cts +9 -0
  113. package/highlevel/types/updates/user-typing-update.d.ts +9 -0
  114. package/highlevel/types/updates/user-typing-update.js +18 -0
  115. package/highlevel/updates/manager.cjs +40 -28
  116. package/highlevel/updates/manager.js +40 -28
  117. package/highlevel/utils/walk-page-blocks.cjs +5 -0
  118. package/highlevel/utils/walk-page-blocks.js +5 -0
  119. package/methods.cjs +6 -0
  120. package/methods.js +6 -0
  121. package/network/mtproto-session.cjs +9 -2
  122. package/network/mtproto-session.d.cts +3 -1
  123. package/network/mtproto-session.d.ts +3 -1
  124. package/network/mtproto-session.js +9 -2
  125. package/network/network-manager.cjs +1 -1
  126. package/network/network-manager.js +1 -1
  127. package/network/session-connection.cjs +12 -6
  128. package/network/session-connection.js +12 -6
  129. package/network/session-connection.test.d.cts +1 -0
  130. package/network/session-connection.test.d.ts +1 -0
  131. package/package.json +3 -3
  132. package/tl/api-schema.json +1 -1
  133. package/tl/binary/reader.cjs +136 -93
  134. package/tl/binary/reader.js +136 -93
  135. package/tl/binary/writer.cjs +318 -207
  136. package/tl/binary/writer.js +318 -207
  137. package/tl/compat/reader.cjs +82 -0
  138. package/tl/compat/reader.js +82 -0
  139. package/tl/index.d.cts +377 -718
  140. package/tl/index.d.ts +377 -718
  141. package/tl/inner-tl.cjs +23 -7
  142. package/tl/inner-tl.js +23 -7
  143. package/tl/rpc-error.test.d.cts +1 -0
  144. package/tl/rpc-error.test.d.ts +1 -0
  145. package/utils/binary/compat.cjs +175 -29
  146. package/utils/binary/compat.js +175 -29
  147. package/utils/links/bots.cjs +9 -4
  148. package/utils/links/bots.js +9 -4
@@ -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",
@@ -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
  }
@@ -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
  }
@@ -59,11 +59,11 @@ class BotKeyboardBuilder {
59
59
  /**
60
60
  * Return contents of this builder as an inline keyboard
61
61
  */
62
- asInline() {
63
- return {
64
- type: "inline",
65
- buttons: this._buttons
66
- };
62
+ asInline(params = {}) {
63
+ const ret = params;
64
+ ret.type = "inline";
65
+ ret.buttons = this._buttons;
66
+ return ret;
67
67
  }
68
68
  /**
69
69
  * Return contents of this builder as a reply keyboard