@mtcute/core 0.29.7 → 0.30.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 (134) hide show
  1. package/client.cjs +8 -0
  2. package/client.js +8 -0
  3. package/highlevel/client.d.cts +67 -7
  4. package/highlevel/client.d.ts +67 -7
  5. package/highlevel/methods/chats/join-chat.cjs +38 -16
  6. package/highlevel/methods/chats/join-chat.d.cts +20 -6
  7. package/highlevel/methods/chats/join-chat.d.ts +20 -6
  8. package/highlevel/methods/chats/join-chat.js +38 -16
  9. package/highlevel/methods/chats/save-draft.d.cts +4 -1
  10. package/highlevel/methods/chats/save-draft.d.ts +4 -1
  11. package/highlevel/methods/files/normalize-input-media.cjs +8 -0
  12. package/highlevel/methods/files/normalize-input-media.js +9 -1
  13. package/highlevel/methods/messages/create-rich-streaming-draft.cjs +39 -0
  14. package/highlevel/methods/messages/create-rich-streaming-draft.d.cts +42 -0
  15. package/highlevel/methods/messages/create-rich-streaming-draft.d.ts +42 -0
  16. package/highlevel/methods/messages/create-rich-streaming-draft.js +34 -0
  17. package/highlevel/methods/messages/normalize-rich-message.cjs +157 -0
  18. package/highlevel/methods/messages/normalize-rich-message.d.cts +10 -0
  19. package/highlevel/methods/messages/normalize-rich-message.d.ts +10 -0
  20. package/highlevel/methods/messages/normalize-rich-message.js +152 -0
  21. package/highlevel/methods/messages/send-rich-message.cjs +49 -0
  22. package/highlevel/methods/messages/send-rich-message.d.cts +38 -0
  23. package/highlevel/methods/messages/send-rich-message.d.ts +38 -0
  24. package/highlevel/methods/messages/send-rich-message.js +44 -0
  25. package/highlevel/methods.d.cts +5 -0
  26. package/highlevel/methods.d.ts +5 -0
  27. package/highlevel/storage/service/peers.cjs +1 -0
  28. package/highlevel/storage/service/peers.js +1 -0
  29. package/highlevel/types/bots/inline-message/factories.cjs +14 -0
  30. package/highlevel/types/bots/inline-message/factories.d.cts +9 -1
  31. package/highlevel/types/bots/inline-message/factories.d.ts +9 -1
  32. package/highlevel/types/bots/inline-message/factories.js +14 -0
  33. package/highlevel/types/bots/inline-message/types.d.cts +17 -1
  34. package/highlevel/types/bots/inline-message/types.d.ts +17 -1
  35. package/highlevel/types/files/utils.d.cts +1 -1
  36. package/highlevel/types/files/utils.d.ts +1 -1
  37. package/highlevel/types/media/input-media/types.d.cts +1 -1
  38. package/highlevel/types/media/input-media/types.d.ts +1 -1
  39. package/highlevel/types/messages/index.d.cts +1 -0
  40. package/highlevel/types/messages/index.d.ts +1 -0
  41. package/highlevel/types/messages/message.cjs +5 -0
  42. package/highlevel/types/messages/message.d.cts +3 -0
  43. package/highlevel/types/messages/message.d.ts +3 -0
  44. package/highlevel/types/messages/message.js +5 -0
  45. package/highlevel/types/messages/rich/index.d.cts +4 -0
  46. package/highlevel/types/messages/rich/index.d.ts +4 -0
  47. package/highlevel/types/messages/rich/inner.cjs +219 -0
  48. package/highlevel/types/messages/rich/inner.d.cts +127 -0
  49. package/highlevel/types/messages/rich/inner.d.ts +127 -0
  50. package/highlevel/types/messages/rich/inner.js +214 -0
  51. package/highlevel/types/messages/rich/rich-message.cjs +50 -0
  52. package/highlevel/types/messages/rich/rich-message.d.cts +18 -0
  53. package/highlevel/types/messages/rich/rich-message.d.ts +18 -0
  54. package/highlevel/types/messages/rich/rich-message.js +45 -0
  55. package/highlevel/types/messages/rich/types.d.cts +76 -0
  56. package/highlevel/types/messages/rich/types.d.ts +76 -0
  57. package/highlevel/types/peers/full-chat.cjs +6 -0
  58. package/highlevel/types/peers/full-chat.d.cts +2 -0
  59. package/highlevel/types/peers/full-chat.d.ts +2 -0
  60. package/highlevel/types/peers/full-chat.js +6 -0
  61. package/highlevel/types/peers/user.cjs +4 -0
  62. package/highlevel/types/peers/user.d.cts +2 -0
  63. package/highlevel/types/peers/user.d.ts +2 -0
  64. package/highlevel/types/peers/user.js +4 -0
  65. package/highlevel/types/updates/user-typing-update.cjs +2 -0
  66. package/highlevel/types/updates/user-typing-update.js +2 -0
  67. package/highlevel/updates/manager.cjs +195 -0
  68. package/highlevel/updates/manager.js +195 -0
  69. package/highlevel/utils/entities.cjs +176 -0
  70. package/highlevel/utils/entities.d.cts +18 -0
  71. package/highlevel/utils/entities.d.ts +18 -0
  72. package/highlevel/utils/entities.js +177 -1
  73. package/highlevel/utils/inspectable.cjs +1 -0
  74. package/highlevel/utils/inspectable.d.cts +1 -0
  75. package/highlevel/utils/inspectable.d.ts +1 -0
  76. package/highlevel/utils/inspectable.js +1 -0
  77. package/index.cjs +4 -0
  78. package/index.js +4 -0
  79. package/methods.cjs +4 -0
  80. package/methods.js +4 -0
  81. package/network/flood-control.cjs +149 -0
  82. package/network/flood-control.d.cts +79 -0
  83. package/network/flood-control.d.ts +79 -0
  84. package/network/flood-control.js +144 -0
  85. package/network/flood-control.test.d.cts +1 -0
  86. package/network/flood-control.test.d.ts +1 -0
  87. package/network/mtproto-session.cjs +1 -21
  88. package/network/mtproto-session.d.cts +1 -5
  89. package/network/mtproto-session.d.ts +1 -5
  90. package/network/mtproto-session.js +2 -22
  91. package/network/mtproxy/_fake-tls.cjs +169 -107
  92. package/network/mtproxy/_fake-tls.js +169 -107
  93. package/network/mtproxy/_fake-tls.test.d.cts +1 -0
  94. package/network/mtproxy/_fake-tls.test.d.ts +1 -0
  95. package/network/multi-session-connection.cjs +26 -16
  96. package/network/multi-session-connection.d.cts +1 -1
  97. package/network/multi-session-connection.d.ts +1 -1
  98. package/network/multi-session-connection.js +26 -16
  99. package/network/multi-session-connection.test.d.cts +1 -0
  100. package/network/multi-session-connection.test.d.ts +1 -0
  101. package/network/network-manager.cjs +3 -2
  102. package/network/network-manager.d.cts +12 -0
  103. package/network/network-manager.d.ts +12 -0
  104. package/network/network-manager.js +3 -2
  105. package/network/persistent-connection.cjs +25 -1
  106. package/network/persistent-connection.d.cts +5 -0
  107. package/network/persistent-connection.d.ts +5 -0
  108. package/network/persistent-connection.js +25 -1
  109. package/network/session-connection.cjs +5 -10
  110. package/network/session-connection.d.cts +0 -2
  111. package/network/session-connection.d.ts +0 -2
  112. package/network/session-connection.js +5 -10
  113. package/package.json +1 -1
  114. package/tl/api-schema.json +1 -1
  115. package/tl/binary/reader.cjs +182 -26
  116. package/tl/binary/reader.js +182 -26
  117. package/tl/binary/writer.cjs +437 -20
  118. package/tl/binary/writer.js +437 -20
  119. package/tl/compat/reader.cjs +23 -0
  120. package/tl/compat/reader.js +23 -0
  121. package/tl/index.d.cts +425 -14
  122. package/tl/index.d.ts +425 -14
  123. package/tl/inner-tl.cjs +22 -8
  124. package/tl/inner-tl.js +22 -8
  125. package/types/utils.d.cts +4 -0
  126. package/types/utils.d.ts +4 -0
  127. package/utils/binary/compat.cjs +79 -0
  128. package/utils/binary/compat.js +79 -0
  129. package/utils/index.d.cts +1 -0
  130. package/utils/index.d.ts +1 -0
  131. package/utils/long-utils.cjs +10 -0
  132. package/utils/long-utils.js +10 -0
  133. package/utils.cjs +9 -0
  134. package/utils.js +11 -2
@@ -64,6 +64,7 @@ export { getUser } from './methods/chats/get-user.js';
64
64
  export { iterChatEventLog } from './methods/chats/iter-chat-event-log.js';
65
65
  export { iterChatMembers } from './methods/chats/iter-chat-members.js';
66
66
  export { joinChat } from './methods/chats/join-chat.js';
67
+ export type { JoinChatResult } from './methods/chats/join-chat.js';
67
68
  export { kickChatMember } from './methods/chats/kick-chat-member.js';
68
69
  export { leaveChat } from './methods/chats/leave-chat.js';
69
70
  export { markChatUnread } from './methods/chats/mark-chat-unread.js';
@@ -72,6 +73,7 @@ export { closeChat } from './methods/chats/open-chat.js';
72
73
  export { reorderUsernames } from './methods/chats/reorder-usernames.js';
73
74
  export { restrictChatMember } from './methods/chats/restrict-chat-member.js';
74
75
  export { saveDraft } from './methods/chats/save-draft.js';
76
+ export type { DraftMessageInput } from './methods/chats/save-draft.js';
75
77
  export { setChatColor } from './methods/chats/set-chat-color.js';
76
78
  export { setChatDefaultPermissions } from './methods/chats/set-chat-default-permissions.js';
77
79
  export { setChatDescription } from './methods/chats/set-chat-description.js';
@@ -161,6 +163,8 @@ export { iterInviteLinks } from './methods/invite-links/iter-invite-links.js';
161
163
  export { revokeInviteLink } from './methods/invite-links/revoke-invite-link.js';
162
164
  export { appendTodoList } from './methods/messages/append-todo-list.js';
163
165
  export { closePoll } from './methods/messages/close-poll.js';
166
+ export { createRichStreamingDraft } from './methods/messages/create-rich-streaming-draft.js';
167
+ export type { RichStreamingDraft } from './methods/messages/create-rich-streaming-draft.js';
164
168
  export { createStreamingDraft } from './methods/messages/create-streaming-draft.js';
165
169
  export type { StreamingDraft } from './methods/messages/create-streaming-draft.js';
166
170
  export { deleteMessagesById } from './methods/messages/delete-messages.js';
@@ -228,6 +232,7 @@ export { sendReaction } from './methods/messages/send-reaction.js';
228
232
  export { replyText } from './methods/messages/send-reply.js';
229
233
  export { replyMedia } from './methods/messages/send-reply.js';
230
234
  export { replyMediaGroup } from './methods/messages/send-reply.js';
235
+ export { sendRichMessage } from './methods/messages/send-rich-message.js';
231
236
  export { sendScheduled } from './methods/messages/send-scheduled.js';
232
237
  export { sendText } from './methods/messages/send-text.js';
233
238
  export { sendTyping } from './methods/messages/send-typing.js';
@@ -181,6 +181,7 @@ class PeersService extends base.BaseService {
181
181
  storiesUnavailable: peer.storiesUnavailable,
182
182
  contactRequirePremium: peer.contactRequirePremium,
183
183
  botBusiness: peer.botBusiness,
184
+ botGuard: peer.botGuard,
184
185
  botHasMainApp: peer.botHasMainApp,
185
186
  botCanManageBots: peer.botCanManageBots,
186
187
  botGuestchat: peer.botGuestchat,
@@ -174,6 +174,7 @@ class PeersService extends BaseService {
174
174
  storiesUnavailable: peer.storiesUnavailable,
175
175
  contactRequirePremium: peer.contactRequirePremium,
176
176
  botBusiness: peer.botBusiness,
177
+ botGuard: peer.botGuard,
177
178
  botHasMainApp: peer.botHasMainApp,
178
179
  botCanManageBots: peer.botCanManageBots,
179
180
  botGuestchat: peer.botGuestchat,
@@ -6,6 +6,7 @@ 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 utils = require("../../../../types/utils.cjs");
9
+ const normalizeRichMessage = require("../../../methods/messages/normalize-rich-message.cjs");
9
10
  const normalizeText = require("../../../methods/misc/normalize-text.cjs");
10
11
  const factories = require("../keyboards/factories.cjs");
11
12
  function text(text2, params = {}) {
@@ -14,6 +15,12 @@ function text(text2, params = {}) {
14
15
  ret.text = text2;
15
16
  return ret;
16
17
  }
18
+ function rich(rich2, params = {}) {
19
+ const ret = params;
20
+ ret.type = "rich";
21
+ ret.content = rich2;
22
+ return ret;
23
+ }
17
24
  function media(params = {}) {
18
25
  const ret = params;
19
26
  ret.type = "media";
@@ -61,6 +68,12 @@ async function _convertToTl(client, obj) {
61
68
  invertMedia: obj.invertMedia
62
69
  };
63
70
  }
71
+ case "rich":
72
+ return {
73
+ _: "inputBotInlineMessageRichMessage",
74
+ replyMarkup: factories._convertToTl(obj.replyMarkup),
75
+ richMessage: "_" in obj.content ? obj.content : await normalizeRichMessage._normalizeInputRichMessage(client, { _: "inputPeerEmpty" }, obj.content, {})
76
+ };
64
77
  case "media": {
65
78
  const [message, entities] = await normalizeText._normalizeInputText(client, obj.text);
66
79
  return {
@@ -139,6 +152,7 @@ exports.game = game;
139
152
  exports.geo = geo;
140
153
  exports.geoLive = geoLive;
141
154
  exports.media = media;
155
+ exports.rich = rich;
142
156
  exports.text = text;
143
157
  exports.venue = venue;
144
158
  exports.webpage = webpage;
@@ -1,7 +1,8 @@
1
1
  import { tl } from '../../../../tl/index.js';
2
2
  import { ITelegramClient } from '../../../client.types.js';
3
3
  import { InputText } from '../../../types/misc/entities.js';
4
- import { InputInlineMessage, InputInlineMessageContact, InputInlineMessageGame, InputInlineMessageGeo, InputInlineMessageGeoLive, InputInlineMessageMedia, InputInlineMessageText, InputInlineMessageVenue, InputInlineMessageWebpage } from './types.js';
4
+ import { InputRichMessage } from '../../messages/rich/types.js';
5
+ import { InputInlineMessage, InputInlineMessageContact, InputInlineMessageGame, InputInlineMessageGeo, InputInlineMessageGeoLive, InputInlineMessageMedia, InputInlineMessageRich, InputInlineMessageText, InputInlineMessageVenue, InputInlineMessageWebpage } from './types.js';
5
6
  /**
6
7
  * Create a text inline message
7
8
  *
@@ -9,6 +10,13 @@ import { InputInlineMessage, InputInlineMessageContact, InputInlineMessageGame,
9
10
  * @param params
10
11
  */
11
12
  export declare function text(text: InputText, params?: Omit<InputInlineMessageText, 'type' | 'text'>): InputInlineMessageText;
13
+ /**
14
+ * Create a rich inline message
15
+ *
16
+ * @param rich Input rich message
17
+ * @param params
18
+ */
19
+ export declare function rich(rich: tl.TypeInputRichMessage | InputRichMessage, params?: Omit<InputInlineMessageRich, 'type' | 'content'>): InputInlineMessageRich;
12
20
  /**
13
21
  * Create an inline message containing
14
22
  * media from the result
@@ -1,7 +1,8 @@
1
1
  import { tl } from '../../../../tl/index.js';
2
2
  import { ITelegramClient } from '../../../client.types.js';
3
3
  import { InputText } from '../../../types/misc/entities.js';
4
- import { InputInlineMessage, InputInlineMessageContact, InputInlineMessageGame, InputInlineMessageGeo, InputInlineMessageGeoLive, InputInlineMessageMedia, InputInlineMessageText, InputInlineMessageVenue, InputInlineMessageWebpage } from './types.js';
4
+ import { InputRichMessage } from '../../messages/rich/types.js';
5
+ import { InputInlineMessage, InputInlineMessageContact, InputInlineMessageGame, InputInlineMessageGeo, InputInlineMessageGeoLive, InputInlineMessageMedia, InputInlineMessageRich, InputInlineMessageText, InputInlineMessageVenue, InputInlineMessageWebpage } from './types.js';
5
6
  /**
6
7
  * Create a text inline message
7
8
  *
@@ -9,6 +10,13 @@ import { InputInlineMessage, InputInlineMessageContact, InputInlineMessageGame,
9
10
  * @param params
10
11
  */
11
12
  export declare function text(text: InputText, params?: Omit<InputInlineMessageText, 'type' | 'text'>): InputInlineMessageText;
13
+ /**
14
+ * Create a rich inline message
15
+ *
16
+ * @param rich Input rich message
17
+ * @param params
18
+ */
19
+ export declare function rich(rich: tl.TypeInputRichMessage | InputRichMessage, params?: Omit<InputInlineMessageRich, 'type' | 'content'>): InputInlineMessageRich;
12
20
  /**
13
21
  * Create an inline message containing
14
22
  * media from the result
@@ -1,4 +1,5 @@
1
1
  import { assertNever } from "../../../../types/utils.js";
2
+ import { _normalizeInputRichMessage } from "../../../methods/messages/normalize-rich-message.js";
2
3
  import { _normalizeInputText } from "../../../methods/misc/normalize-text.js";
3
4
  import { _convertToTl as _convertToTl$1 } from "../keyboards/factories.js";
4
5
  function text(text2, params = {}) {
@@ -7,6 +8,12 @@ function text(text2, params = {}) {
7
8
  ret.text = text2;
8
9
  return ret;
9
10
  }
11
+ function rich(rich2, params = {}) {
12
+ const ret = params;
13
+ ret.type = "rich";
14
+ ret.content = rich2;
15
+ return ret;
16
+ }
10
17
  function media(params = {}) {
11
18
  const ret = params;
12
19
  ret.type = "media";
@@ -54,6 +61,12 @@ async function _convertToTl(client, obj) {
54
61
  invertMedia: obj.invertMedia
55
62
  };
56
63
  }
64
+ case "rich":
65
+ return {
66
+ _: "inputBotInlineMessageRichMessage",
67
+ replyMarkup: _convertToTl$1(obj.replyMarkup),
68
+ richMessage: "_" in obj.content ? obj.content : await _normalizeInputRichMessage(client, { _: "inputPeerEmpty" }, obj.content, {})
69
+ };
57
70
  case "media": {
58
71
  const [message, entities] = await _normalizeInputText(client, obj.text);
59
72
  return {
@@ -133,6 +146,7 @@ export {
133
146
  geo,
134
147
  geoLive,
135
148
  media,
149
+ rich,
136
150
  text,
137
151
  venue,
138
152
  webpage
@@ -1,4 +1,6 @@
1
+ import { tl } from '../../../../tl/index.js';
1
2
  import { InputMediaContact, InputMediaGeo, InputMediaGeoLive, InputMediaVenue, InputMediaWebpage } from '../../media/index.js';
3
+ import { InputRichMessage } from '../../messages/rich/index.js';
2
4
  import { InputText } from '../../misc/entities.js';
3
5
  import { ReplyMarkup } from '../index.js';
4
6
  /**
@@ -26,6 +28,20 @@ export interface InputInlineMessageText {
26
28
  */
27
29
  invertMedia?: boolean;
28
30
  }
31
+ /**
32
+ * Inline message containing a rich message
33
+ */
34
+ export interface InputInlineMessageRich {
35
+ type: 'rich';
36
+ /**
37
+ * Contents of the message
38
+ */
39
+ content: tl.TypeInputRichMessage | InputRichMessage;
40
+ /**
41
+ * Message reply markup
42
+ */
43
+ replyMarkup?: ReplyMarkup;
44
+ }
29
45
  /**
30
46
  * Inline message containing media, which is automatically
31
47
  * inferred from the result itself.
@@ -111,4 +127,4 @@ export interface InputInlineMessageWebpage extends InputMediaWebpage {
111
127
  */
112
128
  invertMedia?: boolean;
113
129
  }
114
- export type InputInlineMessage = InputInlineMessageText | InputInlineMessageMedia | InputInlineMessageGeo | InputInlineMessageGeoLive | InputInlineMessageVenue | InputInlineMessageGame | InputInlineMessageContact | InputInlineMessageWebpage;
130
+ export type InputInlineMessage = InputInlineMessageText | InputInlineMessageMedia | InputInlineMessageGeo | InputInlineMessageGeoLive | InputInlineMessageVenue | InputInlineMessageGame | InputInlineMessageContact | InputInlineMessageWebpage | InputInlineMessageRich;
@@ -1,4 +1,6 @@
1
+ import { tl } from '../../../../tl/index.js';
1
2
  import { InputMediaContact, InputMediaGeo, InputMediaGeoLive, InputMediaVenue, InputMediaWebpage } from '../../media/index.js';
3
+ import { InputRichMessage } from '../../messages/rich/index.js';
2
4
  import { InputText } from '../../misc/entities.js';
3
5
  import { ReplyMarkup } from '../index.js';
4
6
  /**
@@ -26,6 +28,20 @@ export interface InputInlineMessageText {
26
28
  */
27
29
  invertMedia?: boolean;
28
30
  }
31
+ /**
32
+ * Inline message containing a rich message
33
+ */
34
+ export interface InputInlineMessageRich {
35
+ type: 'rich';
36
+ /**
37
+ * Contents of the message
38
+ */
39
+ content: tl.TypeInputRichMessage | InputRichMessage;
40
+ /**
41
+ * Message reply markup
42
+ */
43
+ replyMarkup?: ReplyMarkup;
44
+ }
29
45
  /**
30
46
  * Inline message containing media, which is automatically
31
47
  * inferred from the result itself.
@@ -111,4 +127,4 @@ export interface InputInlineMessageWebpage extends InputMediaWebpage {
111
127
  */
112
128
  invertMedia?: boolean;
113
129
  }
114
- export type InputInlineMessage = InputInlineMessageText | InputInlineMessageMedia | InputInlineMessageGeo | InputInlineMessageGeoLive | InputInlineMessageVenue | InputInlineMessageGame | InputInlineMessageContact | InputInlineMessageWebpage;
130
+ export type InputInlineMessage = InputInlineMessageText | InputInlineMessageMedia | InputInlineMessageGeo | InputInlineMessageGeoLive | InputInlineMessageVenue | InputInlineMessageGame | InputInlineMessageContact | InputInlineMessageWebpage | InputInlineMessageRich;
@@ -18,7 +18,7 @@ import { UploadedFile } from './uploaded-file.js';
18
18
  * - `Readable` (Node.js/Bun readable stream)
19
19
  * - `Response` (from `window.fetch`)
20
20
  */
21
- export type UploadFileLike = URL | Uint8Array | File | Blob | string | IReadable | AnyToNever<import('node:fs').ReadStream> | AnyToNever<ReadableStream<Uint8Array>> | AnyToNever<NodeJS.ReadableStream> | AnyToNever<Response>;
21
+ export type UploadFileLike = URL | Uint8Array | File | Blob | string | IReadable | AnyToNever<import('node:fs').ReadStream> | AnyToNever<ReadableStream<Uint8Array>> | AnyToNever<NodeJS.ReadableStream> | AnyToNever<Response> | AnyToNever<Deno.FsFile>;
22
22
  /**
23
23
  * Describes types that can be used as an input
24
24
  * to any methods that send media (like {@link TelegramClient.sendPhoto})
@@ -18,7 +18,7 @@ import { UploadedFile } from './uploaded-file.js';
18
18
  * - `Readable` (Node.js/Bun readable stream)
19
19
  * - `Response` (from `window.fetch`)
20
20
  */
21
- export type UploadFileLike = URL | Uint8Array | File | Blob | string | IReadable | AnyToNever<import('node:fs').ReadStream> | AnyToNever<ReadableStream<Uint8Array>> | AnyToNever<NodeJS.ReadableStream> | AnyToNever<Response>;
21
+ export type UploadFileLike = URL | Uint8Array | File | Blob | string | IReadable | AnyToNever<import('node:fs').ReadStream> | AnyToNever<ReadableStream<Uint8Array>> | AnyToNever<NodeJS.ReadableStream> | AnyToNever<Response> | AnyToNever<Deno.FsFile>;
22
22
  /**
23
23
  * Describes types that can be used as an input
24
24
  * to any methods that send media (like {@link TelegramClient.sendPhoto})
@@ -543,4 +543,4 @@ export interface InputMediaTodoList {
543
543
  *
544
544
  * @link InputMedia
545
545
  */
546
- export type InputMediaLike = InputMediaAudio | InputMediaVoice | InputMediaDocument | InputMediaPhoto | InputMediaVideo | InputMediaAuto | InputMediaSticker | InputMediaVenue | InputMediaGeo | InputMediaGeoLive | InputMediaDice | InputMediaContact | InputMediaGame | InputMediaInvoice | InputMediaPoll | InputMediaQuiz | InputMediaStory | InputMediaWebpage | InputMediaPaidMedia | InputMediaTodoList | tl.TypeInputMedia;
546
+ export type InputMediaLike = InputMediaAudio | InputMediaVoice | InputMediaDocument | InputMediaPhoto | InputMediaVideo | InputMediaAuto | InputMediaSticker | InputMediaVenue | InputMediaGeo | InputMediaGeoLive | InputMediaDice | InputMediaContact | InputMediaGame | InputMediaInvoice | InputMediaPoll | InputMediaQuiz | InputMediaStory | InputMediaWebpage | InputMediaPaidMedia | InputMediaTodoList | tl.TypeInputMedia | tl.TypeInputPhoto | tl.TypeInputDocument;
@@ -543,4 +543,4 @@ export interface InputMediaTodoList {
543
543
  *
544
544
  * @link InputMedia
545
545
  */
546
- export type InputMediaLike = InputMediaAudio | InputMediaVoice | InputMediaDocument | InputMediaPhoto | InputMediaVideo | InputMediaAuto | InputMediaSticker | InputMediaVenue | InputMediaGeo | InputMediaGeoLive | InputMediaDice | InputMediaContact | InputMediaGame | InputMediaInvoice | InputMediaPoll | InputMediaQuiz | InputMediaStory | InputMediaWebpage | InputMediaPaidMedia | InputMediaTodoList | tl.TypeInputMedia;
546
+ export type InputMediaLike = InputMediaAudio | InputMediaVoice | InputMediaDocument | InputMediaPhoto | InputMediaVideo | InputMediaAuto | InputMediaSticker | InputMediaVenue | InputMediaGeo | InputMediaGeoLive | InputMediaDice | InputMediaContact | InputMediaGame | InputMediaInvoice | InputMediaPoll | InputMediaQuiz | InputMediaStory | InputMediaWebpage | InputMediaPaidMedia | InputMediaTodoList | tl.TypeInputMedia | tl.TypeInputPhoto | tl.TypeInputDocument;
@@ -11,5 +11,6 @@ export * from './message-reactions.js';
11
11
  export * from './message-replies.js';
12
12
  export * from './message.js';
13
13
  export * from './replied-message.js';
14
+ export * from './rich/index.js';
14
15
  export * from './search-filters.js';
15
16
  export * from './suggested-post.js';
@@ -11,5 +11,6 @@ export * from './message-reactions.js';
11
11
  export * from './message-replies.js';
12
12
  export * from './message.js';
13
13
  export * from './replied-message.js';
14
+ export * from './rich/index.js';
14
15
  export * from './search-filters.js';
15
16
  export * from './suggested-post.js';
@@ -20,6 +20,7 @@ const messageMedia = require("./message-media.cjs");
20
20
  const messageReactions = require("./message-reactions.cjs");
21
21
  const messageReplies = require("./message-replies.cjs");
22
22
  const repliedMessage = require("./replied-message.cjs");
23
+ const richMessage = require("./rich/rich-message.cjs");
23
24
  const suggestedPost = require("./suggested-post.cjs");
24
25
  const inspectable = require("../../utils/inspectable.cjs");
25
26
  const factories = require("../bots/keyboards/factories.cjs");
@@ -342,6 +343,10 @@ class Message {
342
343
  }
343
344
  return messageMedia._messageMediaFromTl(this._peers, this.raw.media);
344
345
  }
346
+ /** If this message is a rich message, its contents. Mutually exclusive with {@link media} and {@link text} */
347
+ get richMessage() {
348
+ return this.raw._ === "message" && this.raw.richMessage !== void 0 ? new richMessage.RichMessage(this.raw.richMessage) : null;
349
+ }
345
350
  /**
346
351
  * Whether this is a premium media
347
352
  * (e.g. >2gb file or fullscreen sticker)
@@ -12,6 +12,7 @@ import { MessageForwardInfo } from './message-forward.js';
12
12
  import { MessageReactions } from './message-reactions.js';
13
13
  import { MessageRepliesInfo } from './message-replies.js';
14
14
  import { RepliedMessageInfo } from './replied-message.js';
15
+ import { RichMessage } from './rich/rich-message.js';
15
16
  import { SuggestedPostInfo } from './suggested-post.js';
16
17
  /**
17
18
  * A Telegram message.
@@ -216,6 +217,8 @@ export declare class Message {
216
217
  * For unsupported media types, use `.raw.media` directly.
217
218
  */
218
219
  get media(): MessageMedia;
220
+ /** If this message is a rich message, its contents. Mutually exclusive with {@link media} and {@link text} */
221
+ get richMessage(): RichMessage | null;
219
222
  /**
220
223
  * Whether this is a premium media
221
224
  * (e.g. >2gb file or fullscreen sticker)
@@ -12,6 +12,7 @@ import { MessageForwardInfo } from './message-forward.js';
12
12
  import { MessageReactions } from './message-reactions.js';
13
13
  import { MessageRepliesInfo } from './message-replies.js';
14
14
  import { RepliedMessageInfo } from './replied-message.js';
15
+ import { RichMessage } from './rich/rich-message.js';
15
16
  import { SuggestedPostInfo } from './suggested-post.js';
16
17
  /**
17
18
  * A Telegram message.
@@ -216,6 +217,8 @@ export declare class Message {
216
217
  * For unsupported media types, use `.raw.media` directly.
217
218
  */
218
219
  get media(): MessageMedia;
220
+ /** If this message is a rich message, its contents. Mutually exclusive with {@link media} and {@link text} */
221
+ get richMessage(): RichMessage | null;
219
222
  /**
220
223
  * Whether this is a premium media
221
224
  * (e.g. >2gb file or fullscreen sticker)
@@ -13,6 +13,7 @@ import { _messageMediaFromTl } from "./message-media.js";
13
13
  import { MessageReactions as MessageReactions$2 } from "./message-reactions.js";
14
14
  import { MessageRepliesInfo as MessageRepliesInfo$2 } from "./message-replies.js";
15
15
  import { RepliedMessageInfo as RepliedMessageInfo$2 } from "./replied-message.js";
16
+ import { RichMessage as RichMessage$2 } from "./rich/rich-message.js";
16
17
  import { SuggestedPostInfo as SuggestedPostInfo$1 } from "./suggested-post.js";
17
18
  import { makeInspectable } from "../../utils/inspectable.js";
18
19
  import { _rowsTo2d } from "../bots/keyboards/factories.js";
@@ -335,6 +336,10 @@ class Message {
335
336
  }
336
337
  return _messageMediaFromTl(this._peers, this.raw.media);
337
338
  }
339
+ /** If this message is a rich message, its contents. Mutually exclusive with {@link media} and {@link text} */
340
+ get richMessage() {
341
+ return this.raw._ === "message" && this.raw.richMessage !== void 0 ? new RichMessage$2(this.raw.richMessage) : null;
342
+ }
338
343
  /**
339
344
  * Whether this is a premium media
340
345
  * (e.g. >2gb file or fullscreen sticker)
@@ -0,0 +1,4 @@
1
+ import * as Rich from './inner.js';
2
+ export * from './rich-message.js';
3
+ export * from './types.js';
4
+ export { Rich };
@@ -0,0 +1,4 @@
1
+ import * as Rich from './inner.js';
2
+ export * from './rich-message.js';
3
+ export * from './types.js';
4
+ export { Rich };
@@ -0,0 +1,219 @@
1
+ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
+ globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
+ console.warn("[@mtcute/core] CommonJS bundles are deprecated. They will be removed completely in one of the upcoming releases. No support is provided for CommonJS users. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
+ }
6
+ "use strict";
7
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ const Long = require("long");
9
+ const entities = require("../../../utils/entities.cjs");
10
+ const RICH_EMPTY = { _: "textEmpty" };
11
+ function normalizeRichText(text) {
12
+ if (typeof text === "string") return { _: "textPlain", text };
13
+ if ("_" in text) return text;
14
+ return entities.textWithEntitiesToRichText(text);
15
+ }
16
+ function normalizeCaption(input) {
17
+ if (input == null) return { _: "pageCaption", text: RICH_EMPTY, credit: RICH_EMPTY };
18
+ if (typeof input === "string" || "_" in input || "entities" in input) {
19
+ return { _: "pageCaption", text: normalizeRichText(input), credit: RICH_EMPTY };
20
+ }
21
+ return {
22
+ _: "pageCaption",
23
+ text: input.text != null ? normalizeRichText(input.text) : RICH_EMPTY,
24
+ credit: "credit" in input && input.credit != null ? normalizeRichText(input.credit) : RICH_EMPTY
25
+ };
26
+ }
27
+ function footer(text) {
28
+ return { _: "pageBlockFooter", text: normalizeRichText(text) };
29
+ }
30
+ function paragraph(text) {
31
+ return { _: "pageBlockParagraph", text: normalizeRichText(text) };
32
+ }
33
+ function thinking(text) {
34
+ return { _: "pageBlockThinking", text: normalizeRichText(text) };
35
+ }
36
+ function heading(level, text) {
37
+ return { _: `pageBlockHeading${level}`, text: normalizeRichText(text) };
38
+ }
39
+ function divider() {
40
+ return { _: "pageBlockDivider" };
41
+ }
42
+ function anchor(name) {
43
+ return { _: "pageBlockAnchor", name };
44
+ }
45
+ function math(source) {
46
+ return { _: "pageBlockMath", source };
47
+ }
48
+ function preformatted(text, language = "") {
49
+ return { _: "pageBlockPreformatted", text: normalizeRichText(text), language };
50
+ }
51
+ function blockquote(content, caption) {
52
+ const normalizedCaption = caption != null ? normalizeRichText(caption) : RICH_EMPTY;
53
+ if (Array.isArray(content)) {
54
+ return { _: "pageBlockBlockquoteBlocks", blocks: content, caption: normalizedCaption };
55
+ }
56
+ return { _: "pageBlockBlockquote", text: normalizeRichText(content), caption: normalizedCaption };
57
+ }
58
+ function pullquote(text, caption) {
59
+ return {
60
+ _: "pageBlockPullquote",
61
+ text: normalizeRichText(text),
62
+ caption: caption != null ? normalizeRichText(caption) : RICH_EMPTY
63
+ };
64
+ }
65
+ function map(params) {
66
+ return {
67
+ _: "inputPageBlockMap",
68
+ geo: { _: "inputGeoPoint", lat: params.latitude, long: params.longitude },
69
+ zoom: params.zoom,
70
+ w: params.width,
71
+ h: params.height,
72
+ caption: normalizeCaption(params.caption)
73
+ };
74
+ }
75
+ function listItem(content, params = {}) {
76
+ if (Array.isArray(content)) {
77
+ return {
78
+ _: "pageListItemBlocks",
79
+ blocks: content,
80
+ checkbox: params.checkbox,
81
+ checked: params.checked
82
+ };
83
+ }
84
+ return {
85
+ _: "pageListItemText",
86
+ text: normalizeRichText(content),
87
+ checkbox: params.checkbox,
88
+ checked: params.checked
89
+ };
90
+ }
91
+ function list(items) {
92
+ return { _: "pageBlockList", items };
93
+ }
94
+ function orderedListItem(content, params = {}) {
95
+ if (Array.isArray(content)) {
96
+ return {
97
+ _: "pageListOrderedItemBlocks",
98
+ blocks: content,
99
+ checkbox: params.checkbox,
100
+ checked: params.checked,
101
+ num: params.num,
102
+ value: params.value,
103
+ type: params.type
104
+ };
105
+ }
106
+ return {
107
+ _: "pageListOrderedItemText",
108
+ text: normalizeRichText(content),
109
+ checkbox: params.checkbox,
110
+ checked: params.checked,
111
+ num: params.num,
112
+ value: params.value,
113
+ type: params.type
114
+ };
115
+ }
116
+ function orderedList(items, params = {}) {
117
+ return {
118
+ _: "pageBlockOrderedList",
119
+ items,
120
+ reversed: params.reversed,
121
+ start: params.start,
122
+ type: params.type
123
+ };
124
+ }
125
+ function tableCell(text, params = {}) {
126
+ return {
127
+ _: "pageTableCell",
128
+ text: text != null ? normalizeRichText(text) : void 0,
129
+ header: params.header,
130
+ alignCenter: params.alignCenter,
131
+ alignRight: params.alignRight,
132
+ valignMiddle: params.valignMiddle,
133
+ valignBottom: params.valignBottom,
134
+ colspan: params.colspan,
135
+ rowspan: params.rowspan
136
+ };
137
+ }
138
+ function tableRow(cells) {
139
+ return { _: "pageTableRow", cells };
140
+ }
141
+ function table(rows, params = {}) {
142
+ return {
143
+ _: "pageBlockTable",
144
+ title: params.title != null ? normalizeRichText(params.title) : RICH_EMPTY,
145
+ rows,
146
+ bordered: params.bordered,
147
+ striped: params.striped
148
+ };
149
+ }
150
+ function collage(items, caption) {
151
+ return { _: "pageBlockCollage", items, caption: normalizeCaption(caption) };
152
+ }
153
+ function slideshow(items, caption) {
154
+ return { _: "pageBlockSlideshow", items, caption: normalizeCaption(caption) };
155
+ }
156
+ function details(title, blocks, params = {}) {
157
+ return { _: "pageBlockDetails", blocks, title: normalizeRichText(title), open: params.open };
158
+ }
159
+ function photo(file, params = {}) {
160
+ return {
161
+ // the default `auto` mode would upload it as a document, but we already know it should be a photo
162
+ file: typeof file === "string" ? { type: "photo", file } : file,
163
+ block: {
164
+ _: "pageBlockPhoto",
165
+ photoId: Long.ZERO,
166
+ caption: normalizeCaption(params.caption),
167
+ url: params.url,
168
+ webpageId: params.webpageId,
169
+ spoiler: params.spoiler
170
+ }
171
+ };
172
+ }
173
+ function video(file, params = {}) {
174
+ return {
175
+ file,
176
+ block: {
177
+ _: "pageBlockVideo",
178
+ videoId: Long.ZERO,
179
+ caption: normalizeCaption(params.caption),
180
+ autoplay: params.autoplay,
181
+ loop: params.loop,
182
+ spoiler: params.spoiler
183
+ }
184
+ };
185
+ }
186
+ function audio(file, params = {}) {
187
+ return {
188
+ file,
189
+ block: {
190
+ _: "pageBlockAudio",
191
+ audioId: Long.ZERO,
192
+ caption: normalizeCaption(params.caption)
193
+ }
194
+ };
195
+ }
196
+ exports.anchor = anchor;
197
+ exports.audio = audio;
198
+ exports.blockquote = blockquote;
199
+ exports.collage = collage;
200
+ exports.details = details;
201
+ exports.divider = divider;
202
+ exports.footer = footer;
203
+ exports.heading = heading;
204
+ exports.list = list;
205
+ exports.listItem = listItem;
206
+ exports.map = map;
207
+ exports.math = math;
208
+ exports.orderedList = orderedList;
209
+ exports.orderedListItem = orderedListItem;
210
+ exports.paragraph = paragraph;
211
+ exports.photo = photo;
212
+ exports.preformatted = preformatted;
213
+ exports.pullquote = pullquote;
214
+ exports.slideshow = slideshow;
215
+ exports.table = table;
216
+ exports.tableCell = tableCell;
217
+ exports.tableRow = tableRow;
218
+ exports.thinking = thinking;
219
+ exports.video = video;