@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
package/client.cjs CHANGED
@@ -159,6 +159,7 @@ const iterInviteLinks = require("./highlevel/methods/invite-links/iter-invite-li
159
159
  const revokeInviteLink = require("./highlevel/methods/invite-links/revoke-invite-link.cjs");
160
160
  const appendTodoList = require("./highlevel/methods/messages/append-todo-list.cjs");
161
161
  const closePoll = require("./highlevel/methods/messages/close-poll.cjs");
162
+ const createRichStreamingDraft = require("./highlevel/methods/messages/create-rich-streaming-draft.cjs");
162
163
  const createStreamingDraft = require("./highlevel/methods/messages/create-streaming-draft.cjs");
163
164
  const deleteMessages = require("./highlevel/methods/messages/delete-messages.cjs");
164
165
  const deleteScheduledMessages = require("./highlevel/methods/messages/delete-scheduled-messages.cjs");
@@ -201,6 +202,7 @@ const sendPaidReaction = require("./highlevel/methods/messages/send-paid-reactio
201
202
  const sendQuote = require("./highlevel/methods/messages/send-quote.cjs");
202
203
  const sendReaction = require("./highlevel/methods/messages/send-reaction.cjs");
203
204
  const sendReply = require("./highlevel/methods/messages/send-reply.cjs");
205
+ const sendRichMessage = require("./highlevel/methods/messages/send-rich-message.cjs");
204
206
  const sendScheduled = require("./highlevel/methods/messages/send-scheduled.cjs");
205
207
  const sendText = require("./highlevel/methods/messages/send-text.cjs");
206
208
  const sendTyping = require("./highlevel/methods/messages/send-typing.cjs");
@@ -931,6 +933,9 @@ TelegramClient.prototype.appendTodoList = function(...args) {
931
933
  TelegramClient.prototype.closePoll = function(...args) {
932
934
  return closePoll.closePoll(this._client, ...args);
933
935
  };
936
+ TelegramClient.prototype.createRichStreamingDraft = function(...args) {
937
+ return createRichStreamingDraft.createRichStreamingDraft(this._client, ...args);
938
+ };
934
939
  TelegramClient.prototype.createStreamingDraft = function(...args) {
935
940
  return createStreamingDraft.createStreamingDraft(this._client, ...args);
936
941
  };
@@ -1093,6 +1098,9 @@ TelegramClient.prototype.replyMedia = function(...args) {
1093
1098
  TelegramClient.prototype.replyMediaGroup = function(...args) {
1094
1099
  return sendReply.replyMediaGroup(this._client, ...args);
1095
1100
  };
1101
+ TelegramClient.prototype.sendRichMessage = function(...args) {
1102
+ return sendRichMessage.sendRichMessage(this._client, ...args);
1103
+ };
1096
1104
  TelegramClient.prototype.sendScheduled = function(...args) {
1097
1105
  return sendScheduled.sendScheduled(this._client, ...args);
1098
1106
  };
package/client.js CHANGED
@@ -152,6 +152,7 @@ import { iterInviteLinks } from "./highlevel/methods/invite-links/iter-invite-li
152
152
  import { revokeInviteLink } from "./highlevel/methods/invite-links/revoke-invite-link.js";
153
153
  import { appendTodoList } from "./highlevel/methods/messages/append-todo-list.js";
154
154
  import { closePoll } from "./highlevel/methods/messages/close-poll.js";
155
+ import { createRichStreamingDraft } from "./highlevel/methods/messages/create-rich-streaming-draft.js";
155
156
  import { createStreamingDraft } from "./highlevel/methods/messages/create-streaming-draft.js";
156
157
  import { deleteMessagesById, deleteMessages } from "./highlevel/methods/messages/delete-messages.js";
157
158
  import { deleteScheduledMessages } from "./highlevel/methods/messages/delete-scheduled-messages.js";
@@ -194,6 +195,7 @@ import { sendPaidReaction } from "./highlevel/methods/messages/send-paid-reactio
194
195
  import { quoteWithText, quoteWithMedia, quoteWithMediaGroup } from "./highlevel/methods/messages/send-quote.js";
195
196
  import { sendReaction } from "./highlevel/methods/messages/send-reaction.js";
196
197
  import { replyText, replyMedia, replyMediaGroup } from "./highlevel/methods/messages/send-reply.js";
198
+ import { sendRichMessage } from "./highlevel/methods/messages/send-rich-message.js";
197
199
  import { sendScheduled } from "./highlevel/methods/messages/send-scheduled.js";
198
200
  import { sendText } from "./highlevel/methods/messages/send-text.js";
199
201
  import { sendTyping } from "./highlevel/methods/messages/send-typing.js";
@@ -924,6 +926,9 @@ TelegramClient.prototype.appendTodoList = function(...args) {
924
926
  TelegramClient.prototype.closePoll = function(...args) {
925
927
  return closePoll(this._client, ...args);
926
928
  };
929
+ TelegramClient.prototype.createRichStreamingDraft = function(...args) {
930
+ return createRichStreamingDraft(this._client, ...args);
931
+ };
927
932
  TelegramClient.prototype.createStreamingDraft = function(...args) {
928
933
  return createStreamingDraft(this._client, ...args);
929
934
  };
@@ -1086,6 +1091,9 @@ TelegramClient.prototype.replyMedia = function(...args) {
1086
1091
  TelegramClient.prototype.replyMediaGroup = function(...args) {
1087
1092
  return replyMediaGroup(this._client, ...args);
1088
1093
  };
1094
+ TelegramClient.prototype.sendRichMessage = function(...args) {
1095
+ return sendRichMessage(this._client, ...args);
1096
+ };
1089
1097
  TelegramClient.prototype.sendScheduled = function(...args) {
1090
1098
  return sendScheduled(this._client, ...args);
1091
1099
  };
@@ -6,10 +6,13 @@ import { BaseTelegramClientOptions } from './base.js';
6
6
  import { ITelegramClient } from './client.types.js';
7
7
  import { LogOutResult } from './methods/auth/log-out.js';
8
8
  import { CreateGroupResult } from './methods/chats/create-group.js';
9
+ import { JoinChatResult } from './methods/chats/join-chat.js';
10
+ import { DraftMessageInput } from './methods/chats/save-draft.js';
9
11
  import { GetForumTopicsOffset, getForumTopics } from './methods/forums/get-forum-topics.js';
10
12
  import { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/gifts/get-resale-star-gifts.js';
11
13
  import { StarGiftUpgradeOptions } from './methods/gifts/get-star-gift-upgrade-options.js';
12
14
  import { GetInviteLinksOffset, getInviteLinks } from './methods/invite-links/get-invite-links.js';
15
+ import { RichStreamingDraft } from './methods/messages/create-rich-streaming-draft.js';
13
16
  import { StreamingDraft } from './methods/messages/create-streaming-draft.js';
14
17
  import { DeleteMessagesParams } from './methods/messages/delete-messages.js';
15
18
  import { ForwardMessageOptions } from './methods/messages/forward-messages.js';
@@ -27,7 +30,7 @@ import { InputStarsAmount } from './methods/premium/_normalize-stars-amount.js';
27
30
  import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
28
31
  import { CanSendStoryResult } from './methods/stories/can-send-story.js';
29
32
  import { ITelegramStorageProvider } from './storage/provider.js';
30
- import { AllStories, ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, Audio, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotGuestChatQuery, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputDocumentId, InputFileLike, InputInlineMessage, InputInlineResult, InputMediaAudio, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SavedStarGift, SentCode, StarGift, StarGiftUnique, StarGiftValue, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js';
33
+ import { AllStories, ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, Audio, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotGuestChatQuery, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputDocumentId, InputFileLike, InputInlineMessage, InputInlineResult, InputMediaAudio, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputRichMessage, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, RichMediaUploadCache, SavedStarGift, SentCode, StarGift, StarGiftUnique, StarGiftValue, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js';
31
34
  import { ParsedUpdateHandlerParams } from './updates/parsed.js';
32
35
  import { RawUpdateInfo } from './updates/types.js';
33
36
  import { InputStringSessionData } from './utils/string-session.js';
@@ -1399,17 +1402,13 @@ export interface TelegramClient extends ITelegramClient {
1399
1402
  /**
1400
1403
  * Join a channel or supergroup
1401
1404
  *
1402
- * When using with invite links, this method may throw RPC error
1403
- * `INVITE_REQUEST_SENT`, which means that you need to wait for admin approval.
1404
- * You will get into the chat once they do so.
1405
- *
1406
1405
  * **Available**: 👤 users only
1407
1406
  *
1408
1407
  * @param chatId
1409
1408
  * Chat identifier. Either an invite link (`t.me/joinchat/*`), a username (`@username`)
1410
1409
  * or ID of the linked supergroup or channel.
1411
1410
  */
1412
- joinChat(chatId: InputPeerLike): Promise<Chat>;
1411
+ joinChat(chatId: InputPeerLike): Promise<JoinChatResult>;
1413
1412
  /**
1414
1413
  * Kick a user from a chat.
1415
1414
  *
@@ -1517,7 +1516,7 @@ export interface TelegramClient extends ITelegramClient {
1517
1516
  * @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
1518
1517
  * @param draft Draft message, or `null` to delete.
1519
1518
  */
1520
- saveDraft(chatId: InputPeerLike, draft: null | Omit<tl.RawDraftMessage, '_' | 'date'>): Promise<void>;
1519
+ saveDraft(chatId: InputPeerLike, draft: null | DraftMessageInput): Promise<void>;
1521
1520
  /**
1522
1521
  * Set peer color and optionally background pattern
1523
1522
  * **Available**: 👤 users only
@@ -3094,6 +3093,34 @@ export interface TelegramClient extends ITelegramClient {
3094
3093
  */
3095
3094
  shouldDispatch?: true;
3096
3095
  }): Promise<Poll>;
3096
+ /**
3097
+ * Create a streaming rich message draft
3098
+ *
3099
+ * **Available**: 👤 users only
3100
+ *
3101
+ * @param chatId Chat ID
3102
+ * @param params
3103
+ */
3104
+ createRichStreamingDraft(chatId: InputPeerLike, params?: {
3105
+ /**
3106
+ * Unique identifier of the business connection on behalf of which the action will be sent
3107
+ */
3108
+ businessConnectionId?: string;
3109
+ /** Whether to disable upload cache (exists to prevent uploading the same media multiple times) */
3110
+ disableUploadCache?: boolean;
3111
+ /**
3112
+ * For comment threads, ID of the thread (i.e. top message)
3113
+ */
3114
+ threadId?: number;
3115
+ /**
3116
+ * Function that will be called after some part of the media has been uploaded.
3117
+ *
3118
+ * @param id ID of the file being uploaded
3119
+ * @param uploaded Number of bytes already uploaded
3120
+ * @param total Total file size
3121
+ */
3122
+ progressCallback?: (id: string, uploaded: number, total: number) => void;
3123
+ }): Promise<RichStreamingDraft>;
3097
3124
  /**
3098
3125
  * Create a streaming text message draft
3099
3126
  *
@@ -4095,6 +4122,39 @@ export interface TelegramClient extends ITelegramClient {
4095
4122
  replyMedia(message: Message, ...params: ParametersSkip2<typeof sendMedia>): ReturnType<typeof sendMedia>;
4096
4123
  /** Send a media group in reply to a given message */
4097
4124
  replyMediaGroup(message: Message, ...params: ParametersSkip2<typeof sendMediaGroup>): ReturnType<typeof sendMediaGroup>;
4125
+ /**
4126
+ * Send a rich message
4127
+ *
4128
+ * **Available**: 👤 users only
4129
+ *
4130
+ * @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
4131
+ * @param params Rich message contents and additional sending parameters
4132
+ */
4133
+ sendRichMessage(chatId: InputPeerLike, params: CommonSendParams & {
4134
+ content: InputRichMessage;
4135
+ /** Override the default random ID, for streaming drafts */
4136
+ randomId?: Long;
4137
+ /**
4138
+ * For bots: inline or reply markup or an instruction
4139
+ * to hide a reply keyboard or to force a reply.
4140
+ */
4141
+ replyMarkup?: ReplyMarkup;
4142
+ /**
4143
+ * Function that will be called after some part has been uploaded.
4144
+ *
4145
+ * @param id ID of the file being uploaded
4146
+ * @param uploaded Number of bytes already uploaded
4147
+ * @param total Total file size
4148
+ */
4149
+ progressCallback?: (id: string, uploaded: number, total: number) => void;
4150
+ /**
4151
+ * Cache for uploaded media, used to avoid re-uploading the same media multiple times.
4152
+ *
4153
+ * Pass a (potentially shared) {@link RichMediaUploadCache} to reuse media uploaded
4154
+ * by an earlier call (e.g. a streaming draft) instead of uploading it again.
4155
+ */
4156
+ uploadCache?: RichMediaUploadCache;
4157
+ }): Promise<Message>;
4098
4158
  /**
4099
4159
  * Send previously scheduled message(s)
4100
4160
  *
@@ -6,10 +6,13 @@ import { BaseTelegramClientOptions } from './base.js';
6
6
  import { ITelegramClient } from './client.types.js';
7
7
  import { LogOutResult } from './methods/auth/log-out.js';
8
8
  import { CreateGroupResult } from './methods/chats/create-group.js';
9
+ import { JoinChatResult } from './methods/chats/join-chat.js';
10
+ import { DraftMessageInput } from './methods/chats/save-draft.js';
9
11
  import { GetForumTopicsOffset, getForumTopics } from './methods/forums/get-forum-topics.js';
10
12
  import { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/gifts/get-resale-star-gifts.js';
11
13
  import { StarGiftUpgradeOptions } from './methods/gifts/get-star-gift-upgrade-options.js';
12
14
  import { GetInviteLinksOffset, getInviteLinks } from './methods/invite-links/get-invite-links.js';
15
+ import { RichStreamingDraft } from './methods/messages/create-rich-streaming-draft.js';
13
16
  import { StreamingDraft } from './methods/messages/create-streaming-draft.js';
14
17
  import { DeleteMessagesParams } from './methods/messages/delete-messages.js';
15
18
  import { ForwardMessageOptions } from './methods/messages/forward-messages.js';
@@ -27,7 +30,7 @@ import { InputStarsAmount } from './methods/premium/_normalize-stars-amount.js';
27
30
  import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
28
31
  import { CanSendStoryResult } from './methods/stories/can-send-story.js';
29
32
  import { ITelegramStorageProvider } from './storage/provider.js';
30
- import { AllStories, ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, Audio, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotGuestChatQuery, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputDocumentId, InputFileLike, InputInlineMessage, InputInlineResult, InputMediaAudio, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SavedStarGift, SentCode, StarGift, StarGiftUnique, StarGiftValue, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js';
33
+ import { AllStories, ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, Audio, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotGuestChatQuery, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputDocumentId, InputFileLike, InputInlineMessage, InputInlineResult, InputMediaAudio, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputRichMessage, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, RichMediaUploadCache, SavedStarGift, SentCode, StarGift, StarGiftUnique, StarGiftValue, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js';
31
34
  import { ParsedUpdateHandlerParams } from './updates/parsed.js';
32
35
  import { RawUpdateInfo } from './updates/types.js';
33
36
  import { InputStringSessionData } from './utils/string-session.js';
@@ -1399,17 +1402,13 @@ export interface TelegramClient extends ITelegramClient {
1399
1402
  /**
1400
1403
  * Join a channel or supergroup
1401
1404
  *
1402
- * When using with invite links, this method may throw RPC error
1403
- * `INVITE_REQUEST_SENT`, which means that you need to wait for admin approval.
1404
- * You will get into the chat once they do so.
1405
- *
1406
1405
  * **Available**: 👤 users only
1407
1406
  *
1408
1407
  * @param chatId
1409
1408
  * Chat identifier. Either an invite link (`t.me/joinchat/*`), a username (`@username`)
1410
1409
  * or ID of the linked supergroup or channel.
1411
1410
  */
1412
- joinChat(chatId: InputPeerLike): Promise<Chat>;
1411
+ joinChat(chatId: InputPeerLike): Promise<JoinChatResult>;
1413
1412
  /**
1414
1413
  * Kick a user from a chat.
1415
1414
  *
@@ -1517,7 +1516,7 @@ export interface TelegramClient extends ITelegramClient {
1517
1516
  * @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
1518
1517
  * @param draft Draft message, or `null` to delete.
1519
1518
  */
1520
- saveDraft(chatId: InputPeerLike, draft: null | Omit<tl.RawDraftMessage, '_' | 'date'>): Promise<void>;
1519
+ saveDraft(chatId: InputPeerLike, draft: null | DraftMessageInput): Promise<void>;
1521
1520
  /**
1522
1521
  * Set peer color and optionally background pattern
1523
1522
  * **Available**: 👤 users only
@@ -3094,6 +3093,34 @@ export interface TelegramClient extends ITelegramClient {
3094
3093
  */
3095
3094
  shouldDispatch?: true;
3096
3095
  }): Promise<Poll>;
3096
+ /**
3097
+ * Create a streaming rich message draft
3098
+ *
3099
+ * **Available**: 👤 users only
3100
+ *
3101
+ * @param chatId Chat ID
3102
+ * @param params
3103
+ */
3104
+ createRichStreamingDraft(chatId: InputPeerLike, params?: {
3105
+ /**
3106
+ * Unique identifier of the business connection on behalf of which the action will be sent
3107
+ */
3108
+ businessConnectionId?: string;
3109
+ /** Whether to disable upload cache (exists to prevent uploading the same media multiple times) */
3110
+ disableUploadCache?: boolean;
3111
+ /**
3112
+ * For comment threads, ID of the thread (i.e. top message)
3113
+ */
3114
+ threadId?: number;
3115
+ /**
3116
+ * Function that will be called after some part of the media has been uploaded.
3117
+ *
3118
+ * @param id ID of the file being uploaded
3119
+ * @param uploaded Number of bytes already uploaded
3120
+ * @param total Total file size
3121
+ */
3122
+ progressCallback?: (id: string, uploaded: number, total: number) => void;
3123
+ }): Promise<RichStreamingDraft>;
3097
3124
  /**
3098
3125
  * Create a streaming text message draft
3099
3126
  *
@@ -4095,6 +4122,39 @@ export interface TelegramClient extends ITelegramClient {
4095
4122
  replyMedia(message: Message, ...params: ParametersSkip2<typeof sendMedia>): ReturnType<typeof sendMedia>;
4096
4123
  /** Send a media group in reply to a given message */
4097
4124
  replyMediaGroup(message: Message, ...params: ParametersSkip2<typeof sendMediaGroup>): ReturnType<typeof sendMediaGroup>;
4125
+ /**
4126
+ * Send a rich message
4127
+ *
4128
+ * **Available**: 👤 users only
4129
+ *
4130
+ * @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
4131
+ * @param params Rich message contents and additional sending parameters
4132
+ */
4133
+ sendRichMessage(chatId: InputPeerLike, params: CommonSendParams & {
4134
+ content: InputRichMessage;
4135
+ /** Override the default random ID, for streaming drafts */
4136
+ randomId?: Long;
4137
+ /**
4138
+ * For bots: inline or reply markup or an instruction
4139
+ * to hide a reply keyboard or to force a reply.
4140
+ */
4141
+ replyMarkup?: ReplyMarkup;
4142
+ /**
4143
+ * Function that will be called after some part has been uploaded.
4144
+ *
4145
+ * @param id ID of the file being uploaded
4146
+ * @param uploaded Number of bytes already uploaded
4147
+ * @param total Total file size
4148
+ */
4149
+ progressCallback?: (id: string, uploaded: number, total: number) => void;
4150
+ /**
4151
+ * Cache for uploaded media, used to avoid re-uploading the same media multiple times.
4152
+ *
4153
+ * Pass a (potentially shared) {@link RichMediaUploadCache} to reuse media uploaded
4154
+ * by an earlier call (e.g. a streaming draft) instead of uploading it again.
4155
+ */
4156
+ uploadCache?: RichMediaUploadCache;
4157
+ }): Promise<Message>;
4098
4158
  /**
4099
4159
  * Send previously scheduled message(s)
4100
4160
  *
@@ -8,26 +8,48 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const utils = require("../../updates/utils.cjs");
9
9
  const peerUtils = require("../../utils/peer-utils.cjs");
10
10
  const resolvePeer = require("../users/resolve-peer.cjs");
11
+ const innerTl = require("../../../tl/inner-tl.cjs");
12
+ const peersIndex = require("../../types/peers/peers-index.cjs");
13
+ const user = require("../../types/peers/user.cjs");
11
14
  const chat = require("../../types/peers/chat.cjs");
12
15
  async function joinChat(client, chatId) {
13
- if (typeof chatId === "string") {
14
- const m = chatId.match(peerUtils.INVITE_LINK_REGEX);
15
- if (m) {
16
- const res2 = await client.call({
17
- _: "messages.importChatInvite",
18
- hash: m[1]
16
+ let res;
17
+ try {
18
+ if (typeof chatId === "string") {
19
+ const m = chatId.match(peerUtils.INVITE_LINK_REGEX);
20
+ if (m) {
21
+ res = await client.call({
22
+ _: "messages.importChatInvite",
23
+ hash: m[1]
24
+ });
25
+ }
26
+ }
27
+ if (!res) {
28
+ res = await client.call({
29
+ _: "channels.joinChannel",
30
+ channel: await resolvePeer.resolveChannel(client, chatId)
19
31
  });
20
- utils.assertIsUpdatesGroup("messages.importChatInvite", res2);
21
- client.handleClientUpdate(res2);
22
- return new chat.Chat(res2.chats[0]);
32
+ }
33
+ } catch (e) {
34
+ if (innerTl.RpcError.is(e, "INVITE_REQUEST_SENT")) {
35
+ return { status: "request_sent" };
36
+ } else {
37
+ throw e;
38
+ }
39
+ }
40
+ switch (res._) {
41
+ case "messages.chatInviteJoinResultOk":
42
+ utils.assertIsUpdatesGroup("joinChat", res.updates);
43
+ client.handleClientUpdate(res.updates);
44
+ return { status: "ok", chat: new chat.Chat(res.updates.chats[0]) };
45
+ case "messages.chatInviteJoinResultWebView": {
46
+ const peers = peersIndex.PeersIndex.from(res);
47
+ return {
48
+ status: "webview",
49
+ bot: new user.User(peers.user(res.botId)),
50
+ webview: res.webview
51
+ };
23
52
  }
24
53
  }
25
- const res = await client.call({
26
- _: "channels.joinChannel",
27
- channel: await resolvePeer.resolveChannel(client, chatId)
28
- });
29
- utils.assertIsUpdatesGroup("channels.joinChannel", res);
30
- client.handleClientUpdate(res);
31
- return new chat.Chat(res.chats[0]);
32
54
  }
33
55
  exports.joinChat = joinChat;
@@ -1,14 +1,28 @@
1
1
  import { ITelegramClient } from '../../client.types.js';
2
- import { InputPeerLike, Chat } from '../../types/index.js';
2
+ import { InputPeerLike, Chat, User } from '../../types/index.js';
3
+ import { tl } from '../../../tl/index.js';
3
4
  /**
4
- * Join a channel or supergroup
5
+ * Result of {@link joinChat}
5
6
  *
6
- * When using with invite links, this method may throw RPC error
7
- * `INVITE_REQUEST_SENT`, which means that you need to wait for admin approval.
8
- * You will get into the chat once they do so.
7
+ * - `status: 'ok'` - the chat was joined successfully
8
+ * - `status: 'request_sent'` - a join request was sent and needs to be approved by the chat admin
9
+ * - `status: 'webview'` - a guard bot requested you to open a webview before joining the chat
10
+ */
11
+ export type JoinChatResult = {
12
+ status: 'ok';
13
+ chat: Chat;
14
+ } | {
15
+ status: 'request_sent';
16
+ } | {
17
+ status: 'webview';
18
+ bot: User;
19
+ webview: tl.TypeWebViewResult;
20
+ };
21
+ /**
22
+ * Join a channel or supergroup
9
23
  *
10
24
  * @param chatId
11
25
  * Chat identifier. Either an invite link (`t.me/joinchat/*`), a username (`@username`)
12
26
  * or ID of the linked supergroup or channel.
13
27
  */
14
- export declare function joinChat(client: ITelegramClient, chatId: InputPeerLike): Promise<Chat>;
28
+ export declare function joinChat(client: ITelegramClient, chatId: InputPeerLike): Promise<JoinChatResult>;
@@ -1,14 +1,28 @@
1
1
  import { ITelegramClient } from '../../client.types.js';
2
- import { InputPeerLike, Chat } from '../../types/index.js';
2
+ import { InputPeerLike, Chat, User } from '../../types/index.js';
3
+ import { tl } from '../../../tl/index.js';
3
4
  /**
4
- * Join a channel or supergroup
5
+ * Result of {@link joinChat}
5
6
  *
6
- * When using with invite links, this method may throw RPC error
7
- * `INVITE_REQUEST_SENT`, which means that you need to wait for admin approval.
8
- * You will get into the chat once they do so.
7
+ * - `status: 'ok'` - the chat was joined successfully
8
+ * - `status: 'request_sent'` - a join request was sent and needs to be approved by the chat admin
9
+ * - `status: 'webview'` - a guard bot requested you to open a webview before joining the chat
10
+ */
11
+ export type JoinChatResult = {
12
+ status: 'ok';
13
+ chat: Chat;
14
+ } | {
15
+ status: 'request_sent';
16
+ } | {
17
+ status: 'webview';
18
+ bot: User;
19
+ webview: tl.TypeWebViewResult;
20
+ };
21
+ /**
22
+ * Join a channel or supergroup
9
23
  *
10
24
  * @param chatId
11
25
  * Chat identifier. Either an invite link (`t.me/joinchat/*`), a username (`@username`)
12
26
  * or ID of the linked supergroup or channel.
13
27
  */
14
- export declare function joinChat(client: ITelegramClient, chatId: InputPeerLike): Promise<Chat>;
28
+ export declare function joinChat(client: ITelegramClient, chatId: InputPeerLike): Promise<JoinChatResult>;
@@ -1,27 +1,49 @@
1
1
  import { assertIsUpdatesGroup } from "../../updates/utils.js";
2
2
  import { INVITE_LINK_REGEX } from "../../utils/peer-utils.js";
3
3
  import { resolveChannel } from "../users/resolve-peer.js";
4
+ import { RpcError } from "../../../tl/inner-tl.js";
5
+ import { PeersIndex } from "../../types/peers/peers-index.js";
6
+ import { User as User$2 } from "../../types/peers/user.js";
4
7
  import { Chat as Chat$2 } from "../../types/peers/chat.js";
5
8
  async function joinChat(client, chatId) {
6
- if (typeof chatId === "string") {
7
- const m = chatId.match(INVITE_LINK_REGEX);
8
- if (m) {
9
- const res2 = await client.call({
10
- _: "messages.importChatInvite",
11
- hash: m[1]
9
+ let res;
10
+ try {
11
+ if (typeof chatId === "string") {
12
+ const m = chatId.match(INVITE_LINK_REGEX);
13
+ if (m) {
14
+ res = await client.call({
15
+ _: "messages.importChatInvite",
16
+ hash: m[1]
17
+ });
18
+ }
19
+ }
20
+ if (!res) {
21
+ res = await client.call({
22
+ _: "channels.joinChannel",
23
+ channel: await resolveChannel(client, chatId)
12
24
  });
13
- assertIsUpdatesGroup("messages.importChatInvite", res2);
14
- client.handleClientUpdate(res2);
15
- return new Chat$2(res2.chats[0]);
25
+ }
26
+ } catch (e) {
27
+ if (RpcError.is(e, "INVITE_REQUEST_SENT")) {
28
+ return { status: "request_sent" };
29
+ } else {
30
+ throw e;
31
+ }
32
+ }
33
+ switch (res._) {
34
+ case "messages.chatInviteJoinResultOk":
35
+ assertIsUpdatesGroup("joinChat", res.updates);
36
+ client.handleClientUpdate(res.updates);
37
+ return { status: "ok", chat: new Chat$2(res.updates.chats[0]) };
38
+ case "messages.chatInviteJoinResultWebView": {
39
+ const peers = PeersIndex.from(res);
40
+ return {
41
+ status: "webview",
42
+ bot: new User$2(peers.user(res.botId)),
43
+ webview: res.webview
44
+ };
16
45
  }
17
46
  }
18
- const res = await client.call({
19
- _: "channels.joinChannel",
20
- channel: await resolveChannel(client, chatId)
21
- });
22
- assertIsUpdatesGroup("channels.joinChannel", res);
23
- client.handleClientUpdate(res);
24
- return new Chat$2(res.chats[0]);
25
47
  }
26
48
  export {
27
49
  joinChat
@@ -1,10 +1,13 @@
1
1
  import { tl } from '../../../tl/index.js';
2
2
  import { ITelegramClient } from '../../client.types.js';
3
3
  import { InputPeerLike } from '../../types/index.js';
4
+ export type DraftMessageInput = Omit<tl.RawDraftMessage, '_' | 'date' | 'richMessage'> & {
5
+ richMessage?: tl.TypeInputRichMessage;
6
+ };
4
7
  /**
5
8
  * Save or delete a draft message associated with some chat
6
9
  *
7
10
  * @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
8
11
  * @param draft Draft message, or `null` to delete.
9
12
  */
10
- export declare function saveDraft(client: ITelegramClient, chatId: InputPeerLike, draft: null | Omit<tl.RawDraftMessage, '_' | 'date'>): Promise<void>;
13
+ export declare function saveDraft(client: ITelegramClient, chatId: InputPeerLike, draft: null | DraftMessageInput): Promise<void>;
@@ -1,10 +1,13 @@
1
1
  import { tl } from '../../../tl/index.js';
2
2
  import { ITelegramClient } from '../../client.types.js';
3
3
  import { InputPeerLike } from '../../types/index.js';
4
+ export type DraftMessageInput = Omit<tl.RawDraftMessage, '_' | 'date' | 'richMessage'> & {
5
+ richMessage?: tl.TypeInputRichMessage;
6
+ };
4
7
  /**
5
8
  * Save or delete a draft message associated with some chat
6
9
  *
7
10
  * @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
8
11
  * @param draft Draft message, or `null` to delete.
9
12
  */
10
- export declare function saveDraft(client: ITelegramClient, chatId: InputPeerLike, draft: null | Omit<tl.RawDraftMessage, '_' | 'date'>): Promise<void>;
13
+ export declare function saveDraft(client: ITelegramClient, chatId: InputPeerLike, draft: null | DraftMessageInput): Promise<void>;
@@ -29,6 +29,14 @@ async function _normalizeInputMedia(client, media, params = {}, uploadMedia = fa
29
29
  }
30
30
  return media;
31
31
  }
32
+ if (innerTl.isAnyInputPhoto(media)) {
33
+ typeAssertions.assertTypeIs("normalizeInputMedia (@ photo)", media, "inputPhoto");
34
+ return { _: "inputMediaPhoto", id: media };
35
+ }
36
+ if (innerTl.isAnyInputDocument(media)) {
37
+ typeAssertions.assertTypeIs("normalizeInputMedia (@ document)", media, "inputDocument");
38
+ return { _: "inputMediaDocument", id: media };
39
+ }
32
40
  if (media.type === "venue") {
33
41
  return {
34
42
  _: "inputMediaVenue",
@@ -10,7 +10,7 @@ import { _normalizeInputText } from "../misc/normalize-text.js";
10
10
  import { resolvePeer } from "../users/resolve-peer.js";
11
11
  import { _normalizeInputFile } from "./normalize-input-file.js";
12
12
  import { uploadFile } from "./upload-file.js";
13
- import { isAnyInputMedia, isAnyPollAnswer, isAnyInputFile } from "../../../tl/inner-tl.js";
13
+ import { isAnyInputMedia, isAnyInputPhoto, isAnyInputDocument, isAnyPollAnswer, isAnyInputFile } from "../../../tl/inner-tl.js";
14
14
  async function _normalizeInputMedia(client, media, params = {}, uploadMedia = false) {
15
15
  if (isAnyInputMedia(media)) {
16
16
  switch (media._) {
@@ -22,6 +22,14 @@ async function _normalizeInputMedia(client, media, params = {}, uploadMedia = fa
22
22
  }
23
23
  return media;
24
24
  }
25
+ if (isAnyInputPhoto(media)) {
26
+ assertTypeIs("normalizeInputMedia (@ photo)", media, "inputPhoto");
27
+ return { _: "inputMediaPhoto", id: media };
28
+ }
29
+ if (isAnyInputDocument(media)) {
30
+ assertTypeIs("normalizeInputMedia (@ document)", media, "inputDocument");
31
+ return { _: "inputMediaDocument", id: media };
32
+ }
25
33
  if (media.type === "venue") {
26
34
  return {
27
35
  _: "inputMediaVenue",
@@ -0,0 +1,39 @@
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 longUtils = require("../../../utils/long-utils.cjs");
9
+ const typeAssertions = require("../../../utils/type-assertions.cjs");
10
+ const resolvePeer = require("../users/resolve-peer.cjs");
11
+ const normalizeRichMessage = require("./normalize-rich-message.cjs");
12
+ async function createRichStreamingDraft(client, chatId, params) {
13
+ const { threadId, businessConnectionId, progressCallback } = params ?? {};
14
+ const randomId = longUtils.randomLong();
15
+ const peer = await resolvePeer.resolvePeer(client, chatId);
16
+ const uploadCache = params?.disableUploadCache ? void 0 : /* @__PURE__ */ new Map();
17
+ const sendDraft = async (content) => {
18
+ const richMessage = await normalizeRichMessage._normalizeInputRichMessage(client, peer, content, { progressCallback, uploadCache });
19
+ const r = await client.call({
20
+ _: "messages.setTyping",
21
+ peer,
22
+ action: {
23
+ _: "inputSendMessageRichMessageDraftAction",
24
+ randomId,
25
+ richMessage
26
+ },
27
+ topMsgId: threadId
28
+ }, {
29
+ businessConnectionId
30
+ });
31
+ typeAssertions.assertTrue("messages.setTyping", r);
32
+ };
33
+ return {
34
+ randomId,
35
+ send: sendDraft,
36
+ uploadCache
37
+ };
38
+ }
39
+ exports.createRichStreamingDraft = createRichStreamingDraft;