@mtcute/core 0.30.0 → 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.
- package/client.cjs +8 -0
- package/client.js +8 -0
- package/highlevel/client.d.cts +63 -1
- package/highlevel/client.d.ts +63 -1
- package/highlevel/methods/files/normalize-input-media.cjs +8 -0
- package/highlevel/methods/files/normalize-input-media.js +9 -1
- package/highlevel/methods/messages/create-rich-streaming-draft.cjs +39 -0
- package/highlevel/methods/messages/create-rich-streaming-draft.d.cts +42 -0
- package/highlevel/methods/messages/create-rich-streaming-draft.d.ts +42 -0
- package/highlevel/methods/messages/create-rich-streaming-draft.js +34 -0
- package/highlevel/methods/messages/normalize-rich-message.cjs +157 -0
- package/highlevel/methods/messages/normalize-rich-message.d.cts +10 -0
- package/highlevel/methods/messages/normalize-rich-message.d.ts +10 -0
- package/highlevel/methods/messages/normalize-rich-message.js +152 -0
- package/highlevel/methods/messages/send-rich-message.cjs +49 -0
- package/highlevel/methods/messages/send-rich-message.d.cts +38 -0
- package/highlevel/methods/messages/send-rich-message.d.ts +38 -0
- package/highlevel/methods/messages/send-rich-message.js +44 -0
- package/highlevel/methods.d.cts +3 -0
- package/highlevel/methods.d.ts +3 -0
- package/highlevel/types/bots/inline-message/factories.cjs +14 -0
- package/highlevel/types/bots/inline-message/factories.d.cts +9 -1
- package/highlevel/types/bots/inline-message/factories.d.ts +9 -1
- package/highlevel/types/bots/inline-message/factories.js +14 -0
- package/highlevel/types/bots/inline-message/types.d.cts +17 -1
- package/highlevel/types/bots/inline-message/types.d.ts +17 -1
- package/highlevel/types/media/input-media/types.d.cts +1 -1
- package/highlevel/types/media/input-media/types.d.ts +1 -1
- package/highlevel/types/messages/index.d.cts +1 -1
- package/highlevel/types/messages/index.d.ts +1 -1
- package/highlevel/types/messages/message.cjs +1 -1
- package/highlevel/types/messages/message.d.cts +1 -1
- package/highlevel/types/messages/message.d.ts +1 -1
- package/highlevel/types/messages/message.js +1 -1
- package/highlevel/types/messages/rich/index.d.cts +4 -0
- package/highlevel/types/messages/rich/index.d.ts +4 -0
- package/highlevel/types/messages/rich/inner.cjs +219 -0
- package/highlevel/types/messages/rich/inner.d.cts +127 -0
- package/highlevel/types/messages/rich/inner.d.ts +127 -0
- package/highlevel/types/messages/rich/inner.js +214 -0
- package/highlevel/types/messages/{rich-message.cjs → rich/rich-message.cjs} +6 -6
- package/highlevel/types/messages/{rich-message.d.cts → rich/rich-message.d.cts} +5 -5
- package/highlevel/types/messages/{rich-message.d.ts → rich/rich-message.d.ts} +5 -5
- package/highlevel/types/messages/{rich-message.js → rich/rich-message.js} +6 -6
- package/highlevel/types/messages/rich/types.d.cts +76 -0
- package/highlevel/types/messages/rich/types.d.ts +76 -0
- package/highlevel/updates/manager.cjs +4 -0
- package/highlevel/updates/manager.js +4 -0
- package/highlevel/utils/entities.cjs +176 -0
- package/highlevel/utils/entities.d.cts +18 -0
- package/highlevel/utils/entities.d.ts +18 -0
- package/highlevel/utils/entities.js +177 -1
- package/index.cjs +3 -1
- package/index.js +3 -1
- package/methods.cjs +4 -0
- package/methods.js +4 -0
- package/network/mtproxy/_fake-tls.cjs +169 -107
- package/network/mtproxy/_fake-tls.js +169 -107
- package/network/mtproxy/_fake-tls.test.d.cts +1 -0
- package/network/mtproxy/_fake-tls.test.d.ts +1 -0
- package/network/network-manager.cjs +1 -1
- package/network/network-manager.js +1 -1
- package/package.json +1 -1
- package/tl/api-schema.json +1 -1
- package/tl/binary/reader.cjs +115 -109
- package/tl/binary/reader.js +115 -109
- package/tl/binary/writer.cjs +243 -245
- package/tl/binary/writer.js +243 -245
- package/tl/index.d.cts +227 -216
- package/tl/index.d.ts +227 -216
- package/tl/inner-tl.cjs +3 -1
- package/tl/inner-tl.js +3 -1
- package/types/utils.d.cts +4 -0
- package/types/utils.d.ts +4 -0
- package/utils.cjs +2 -0
- package/utils.js +3 -1
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
|
};
|
package/highlevel/client.d.cts
CHANGED
|
@@ -12,6 +12,7 @@ import { GetForumTopicsOffset, getForumTopics } from './methods/forums/get-forum
|
|
|
12
12
|
import { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/gifts/get-resale-star-gifts.js';
|
|
13
13
|
import { StarGiftUpgradeOptions } from './methods/gifts/get-star-gift-upgrade-options.js';
|
|
14
14
|
import { GetInviteLinksOffset, getInviteLinks } from './methods/invite-links/get-invite-links.js';
|
|
15
|
+
import { RichStreamingDraft } from './methods/messages/create-rich-streaming-draft.js';
|
|
15
16
|
import { StreamingDraft } from './methods/messages/create-streaming-draft.js';
|
|
16
17
|
import { DeleteMessagesParams } from './methods/messages/delete-messages.js';
|
|
17
18
|
import { ForwardMessageOptions } from './methods/messages/forward-messages.js';
|
|
@@ -29,7 +30,7 @@ import { InputStarsAmount } from './methods/premium/_normalize-stars-amount.js';
|
|
|
29
30
|
import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
|
|
30
31
|
import { CanSendStoryResult } from './methods/stories/can-send-story.js';
|
|
31
32
|
import { ITelegramStorageProvider } from './storage/provider.js';
|
|
32
|
-
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';
|
|
33
34
|
import { ParsedUpdateHandlerParams } from './updates/parsed.js';
|
|
34
35
|
import { RawUpdateInfo } from './updates/types.js';
|
|
35
36
|
import { InputStringSessionData } from './utils/string-session.js';
|
|
@@ -3092,6 +3093,34 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
3092
3093
|
*/
|
|
3093
3094
|
shouldDispatch?: true;
|
|
3094
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>;
|
|
3095
3124
|
/**
|
|
3096
3125
|
* Create a streaming text message draft
|
|
3097
3126
|
*
|
|
@@ -4093,6 +4122,39 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4093
4122
|
replyMedia(message: Message, ...params: ParametersSkip2<typeof sendMedia>): ReturnType<typeof sendMedia>;
|
|
4094
4123
|
/** Send a media group in reply to a given message */
|
|
4095
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>;
|
|
4096
4158
|
/**
|
|
4097
4159
|
* Send previously scheduled message(s)
|
|
4098
4160
|
*
|
package/highlevel/client.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { GetForumTopicsOffset, getForumTopics } from './methods/forums/get-forum
|
|
|
12
12
|
import { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/gifts/get-resale-star-gifts.js';
|
|
13
13
|
import { StarGiftUpgradeOptions } from './methods/gifts/get-star-gift-upgrade-options.js';
|
|
14
14
|
import { GetInviteLinksOffset, getInviteLinks } from './methods/invite-links/get-invite-links.js';
|
|
15
|
+
import { RichStreamingDraft } from './methods/messages/create-rich-streaming-draft.js';
|
|
15
16
|
import { StreamingDraft } from './methods/messages/create-streaming-draft.js';
|
|
16
17
|
import { DeleteMessagesParams } from './methods/messages/delete-messages.js';
|
|
17
18
|
import { ForwardMessageOptions } from './methods/messages/forward-messages.js';
|
|
@@ -29,7 +30,7 @@ import { InputStarsAmount } from './methods/premium/_normalize-stars-amount.js';
|
|
|
29
30
|
import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
|
|
30
31
|
import { CanSendStoryResult } from './methods/stories/can-send-story.js';
|
|
31
32
|
import { ITelegramStorageProvider } from './storage/provider.js';
|
|
32
|
-
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';
|
|
33
34
|
import { ParsedUpdateHandlerParams } from './updates/parsed.js';
|
|
34
35
|
import { RawUpdateInfo } from './updates/types.js';
|
|
35
36
|
import { InputStringSessionData } from './utils/string-session.js';
|
|
@@ -3092,6 +3093,34 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
3092
3093
|
*/
|
|
3093
3094
|
shouldDispatch?: true;
|
|
3094
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>;
|
|
3095
3124
|
/**
|
|
3096
3125
|
* Create a streaming text message draft
|
|
3097
3126
|
*
|
|
@@ -4093,6 +4122,39 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4093
4122
|
replyMedia(message: Message, ...params: ParametersSkip2<typeof sendMedia>): ReturnType<typeof sendMedia>;
|
|
4094
4123
|
/** Send a media group in reply to a given message */
|
|
4095
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>;
|
|
4096
4158
|
/**
|
|
4097
4159
|
* Send previously scheduled message(s)
|
|
4098
4160
|
*
|
|
@@ -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;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { default as Long } from 'long';
|
|
2
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
3
|
+
import { InputPeerLike } from '../../types/index.js';
|
|
4
|
+
import { InputRichMessage, RichMediaUploadCache } from '../../types/messages/rich/types.js';
|
|
5
|
+
export interface RichStreamingDraft {
|
|
6
|
+
/** Random ID of the draft */
|
|
7
|
+
readonly randomId: Long;
|
|
8
|
+
/** Replace the draft with the given rich message */
|
|
9
|
+
send(content: InputRichMessage): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Cache of media uploaded while streaming the draft (unless disabled).
|
|
12
|
+
*
|
|
13
|
+
* Pass it to the final {@link sendRichMessage} call to avoid re-uploading the media.
|
|
14
|
+
*/
|
|
15
|
+
readonly uploadCache?: RichMediaUploadCache;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Create a streaming rich message draft
|
|
19
|
+
*
|
|
20
|
+
* @param chatId Chat ID
|
|
21
|
+
* @param params
|
|
22
|
+
*/
|
|
23
|
+
export declare function createRichStreamingDraft(client: ITelegramClient, chatId: InputPeerLike, params?: {
|
|
24
|
+
/**
|
|
25
|
+
* Unique identifier of the business connection on behalf of which the action will be sent
|
|
26
|
+
*/
|
|
27
|
+
businessConnectionId?: string;
|
|
28
|
+
/** Whether to disable upload cache (exists to prevent uploading the same media multiple times) */
|
|
29
|
+
disableUploadCache?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* For comment threads, ID of the thread (i.e. top message)
|
|
32
|
+
*/
|
|
33
|
+
threadId?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Function that will be called after some part of the media has been uploaded.
|
|
36
|
+
*
|
|
37
|
+
* @param id ID of the file being uploaded
|
|
38
|
+
* @param uploaded Number of bytes already uploaded
|
|
39
|
+
* @param total Total file size
|
|
40
|
+
*/
|
|
41
|
+
progressCallback?: (id: string, uploaded: number, total: number) => void;
|
|
42
|
+
}): Promise<RichStreamingDraft>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { default as Long } from 'long';
|
|
2
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
3
|
+
import { InputPeerLike } from '../../types/index.js';
|
|
4
|
+
import { InputRichMessage, RichMediaUploadCache } from '../../types/messages/rich/types.js';
|
|
5
|
+
export interface RichStreamingDraft {
|
|
6
|
+
/** Random ID of the draft */
|
|
7
|
+
readonly randomId: Long;
|
|
8
|
+
/** Replace the draft with the given rich message */
|
|
9
|
+
send(content: InputRichMessage): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Cache of media uploaded while streaming the draft (unless disabled).
|
|
12
|
+
*
|
|
13
|
+
* Pass it to the final {@link sendRichMessage} call to avoid re-uploading the media.
|
|
14
|
+
*/
|
|
15
|
+
readonly uploadCache?: RichMediaUploadCache;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Create a streaming rich message draft
|
|
19
|
+
*
|
|
20
|
+
* @param chatId Chat ID
|
|
21
|
+
* @param params
|
|
22
|
+
*/
|
|
23
|
+
export declare function createRichStreamingDraft(client: ITelegramClient, chatId: InputPeerLike, params?: {
|
|
24
|
+
/**
|
|
25
|
+
* Unique identifier of the business connection on behalf of which the action will be sent
|
|
26
|
+
*/
|
|
27
|
+
businessConnectionId?: string;
|
|
28
|
+
/** Whether to disable upload cache (exists to prevent uploading the same media multiple times) */
|
|
29
|
+
disableUploadCache?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* For comment threads, ID of the thread (i.e. top message)
|
|
32
|
+
*/
|
|
33
|
+
threadId?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Function that will be called after some part of the media has been uploaded.
|
|
36
|
+
*
|
|
37
|
+
* @param id ID of the file being uploaded
|
|
38
|
+
* @param uploaded Number of bytes already uploaded
|
|
39
|
+
* @param total Total file size
|
|
40
|
+
*/
|
|
41
|
+
progressCallback?: (id: string, uploaded: number, total: number) => void;
|
|
42
|
+
}): Promise<RichStreamingDraft>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { randomLong } from "../../../utils/long-utils.js";
|
|
2
|
+
import { assertTrue } from "../../../utils/type-assertions.js";
|
|
3
|
+
import { resolvePeer } from "../users/resolve-peer.js";
|
|
4
|
+
import { _normalizeInputRichMessage } from "./normalize-rich-message.js";
|
|
5
|
+
async function createRichStreamingDraft(client, chatId, params) {
|
|
6
|
+
const { threadId, businessConnectionId, progressCallback } = params ?? {};
|
|
7
|
+
const randomId = randomLong();
|
|
8
|
+
const peer = await resolvePeer(client, chatId);
|
|
9
|
+
const uploadCache = params?.disableUploadCache ? void 0 : /* @__PURE__ */ new Map();
|
|
10
|
+
const sendDraft = async (content) => {
|
|
11
|
+
const richMessage = await _normalizeInputRichMessage(client, peer, content, { progressCallback, uploadCache });
|
|
12
|
+
const r = await client.call({
|
|
13
|
+
_: "messages.setTyping",
|
|
14
|
+
peer,
|
|
15
|
+
action: {
|
|
16
|
+
_: "inputSendMessageRichMessageDraftAction",
|
|
17
|
+
randomId,
|
|
18
|
+
richMessage
|
|
19
|
+
},
|
|
20
|
+
topMsgId: threadId
|
|
21
|
+
}, {
|
|
22
|
+
businessConnectionId
|
|
23
|
+
});
|
|
24
|
+
assertTrue("messages.setTyping", r);
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
randomId,
|
|
28
|
+
send: sendDraft,
|
|
29
|
+
uploadCache
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
createRichStreamingDraft
|
|
34
|
+
};
|
|
@@ -0,0 +1,157 @@
|
|
|
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 utils = require("@fuman/utils");
|
|
9
|
+
const errors = require("../../../types/errors.cjs");
|
|
10
|
+
const typeAssertions = require("../../../utils/type-assertions.cjs");
|
|
11
|
+
const normalizeInputMedia = require("../files/normalize-input-media.cjs");
|
|
12
|
+
function _richMediaCacheKey(media) {
|
|
13
|
+
if (typeof media === "string") return `auto:${media}`;
|
|
14
|
+
if ("_" in media) return void 0;
|
|
15
|
+
if (typeof media.file === "string") return `${media.type}:${media.file}`;
|
|
16
|
+
return media;
|
|
17
|
+
}
|
|
18
|
+
async function _uploadRichMedia(client, peer, id, media, params) {
|
|
19
|
+
const cacheKey = params.uploadCache != null ? _richMediaCacheKey(media) : void 0;
|
|
20
|
+
if (cacheKey !== void 0) {
|
|
21
|
+
const cached = params.uploadCache.get(cacheKey);
|
|
22
|
+
if (cached != null) return cached;
|
|
23
|
+
}
|
|
24
|
+
const input = typeof media === "string" ? { type: "auto", file: media } : media;
|
|
25
|
+
const normalized = await normalizeInputMedia._normalizeInputMedia(client, input, {
|
|
26
|
+
uploadPeer: peer,
|
|
27
|
+
abortSignal: params.abortSignal,
|
|
28
|
+
progressCallback: params.progressCallback?.bind(null, id)
|
|
29
|
+
}, true);
|
|
30
|
+
if (normalized._ !== "inputMediaPhoto" && normalized._ !== "inputMediaDocument") {
|
|
31
|
+
throw new errors.MtTypeAssertionError("sendRichMessage (upload)", "inputMediaDocument | inputMediaPhoto", normalized._);
|
|
32
|
+
}
|
|
33
|
+
if (cacheKey !== void 0) params.uploadCache.set(cacheKey, normalized);
|
|
34
|
+
return normalized;
|
|
35
|
+
}
|
|
36
|
+
async function _normalizeInputRichMessage(client, peer, input, params) {
|
|
37
|
+
if ("_" in input) return input;
|
|
38
|
+
if (input.type !== "blocks") {
|
|
39
|
+
let richFiles;
|
|
40
|
+
if (input.attachments) {
|
|
41
|
+
const medias = [...Object.entries(input.attachments)];
|
|
42
|
+
const normalized = await utils.parallelMap(
|
|
43
|
+
medias,
|
|
44
|
+
async ([id, media]) => [id, await _uploadRichMedia(client, peer, id, media, params)],
|
|
45
|
+
{ limit: 4, signal: params.abortSignal }
|
|
46
|
+
);
|
|
47
|
+
richFiles = normalized.map(
|
|
48
|
+
([id, media]) => media._ === "inputMediaDocument" ? { _: "inputRichFileDocument", id, document: media.id } : { _: "inputRichFilePhoto", id, photo: media.id }
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
return input.type === "markdown" ? {
|
|
52
|
+
_: "inputRichMessageMarkdown",
|
|
53
|
+
rtl: input.rtl,
|
|
54
|
+
noautolink: input.skipEntityDetection,
|
|
55
|
+
files: richFiles,
|
|
56
|
+
markdown: input.content
|
|
57
|
+
} : {
|
|
58
|
+
_: "inputRichMessageHTML",
|
|
59
|
+
rtl: input.rtl,
|
|
60
|
+
noautolink: input.skipEntityDetection,
|
|
61
|
+
files: richFiles,
|
|
62
|
+
html: input.content
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const photos = [];
|
|
66
|
+
const documents = [];
|
|
67
|
+
const fileBlocks = [];
|
|
68
|
+
function processBlock(node) {
|
|
69
|
+
if ("file" in node) {
|
|
70
|
+
const block = processBlock(node.block);
|
|
71
|
+
fileBlocks.push({ block, media: node.file });
|
|
72
|
+
return block;
|
|
73
|
+
}
|
|
74
|
+
switch (node._) {
|
|
75
|
+
case "pageBlockCover":
|
|
76
|
+
return { ...node, cover: processBlock(node.cover) };
|
|
77
|
+
case "pageBlockCollage":
|
|
78
|
+
case "pageBlockSlideshow":
|
|
79
|
+
return { ...node, items: node.items.map(processBlock) };
|
|
80
|
+
case "pageBlockDetails":
|
|
81
|
+
case "pageBlockEmbedPost":
|
|
82
|
+
case "pageBlockBlockquoteBlocks":
|
|
83
|
+
return { ...node, blocks: node.blocks.map(processBlock) };
|
|
84
|
+
case "pageBlockList":
|
|
85
|
+
return {
|
|
86
|
+
...node,
|
|
87
|
+
items: node.items.map(
|
|
88
|
+
(item) => item._ === "pageListItemBlocks" ? {
|
|
89
|
+
...item,
|
|
90
|
+
blocks: item.blocks.map(processBlock)
|
|
91
|
+
} : item
|
|
92
|
+
)
|
|
93
|
+
};
|
|
94
|
+
case "pageBlockOrderedList":
|
|
95
|
+
return {
|
|
96
|
+
...node,
|
|
97
|
+
items: node.items.map(
|
|
98
|
+
(item) => item._ === "pageListOrderedItemBlocks" ? { ...item, blocks: item.blocks.map(processBlock) } : item
|
|
99
|
+
)
|
|
100
|
+
};
|
|
101
|
+
default:
|
|
102
|
+
return node;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const blocks = input.blocks.map(processBlock);
|
|
106
|
+
const uploaded = await utils.parallelMap(
|
|
107
|
+
fileBlocks,
|
|
108
|
+
async ({ block, media }, idx) => {
|
|
109
|
+
const uploaded2 = await _uploadRichMedia(client, peer, `block-${idx}`, media, params);
|
|
110
|
+
return { block, media: uploaded2 };
|
|
111
|
+
},
|
|
112
|
+
{ limit: 4, signal: params.abortSignal }
|
|
113
|
+
);
|
|
114
|
+
for (const { block, media } of uploaded) {
|
|
115
|
+
if (media._ === "inputMediaPhoto") {
|
|
116
|
+
const photo = media.id;
|
|
117
|
+
typeAssertions.assertTypeIs("sendRichMessage (upload)", photo, "inputPhoto");
|
|
118
|
+
photos.push(photo);
|
|
119
|
+
switch (block._) {
|
|
120
|
+
case "pageBlockPhoto":
|
|
121
|
+
block.photoId = photo.id;
|
|
122
|
+
break;
|
|
123
|
+
case "pageBlockEmbed":
|
|
124
|
+
block.posterPhotoId = photo.id;
|
|
125
|
+
break;
|
|
126
|
+
case "pageBlockEmbedPost":
|
|
127
|
+
block.authorPhotoId = photo.id;
|
|
128
|
+
break;
|
|
129
|
+
default:
|
|
130
|
+
throw new errors.MtArgumentError(`sendRichMessage: expected photo ${photo.id} to be used in a photo block, but got ${block._}`);
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
const document = media.id;
|
|
134
|
+
typeAssertions.assertTypeIs("sendRichMessage (upload)", document, "inputDocument");
|
|
135
|
+
documents.push(document);
|
|
136
|
+
switch (block._) {
|
|
137
|
+
case "pageBlockVideo":
|
|
138
|
+
block.videoId = document.id;
|
|
139
|
+
break;
|
|
140
|
+
case "pageBlockAudio":
|
|
141
|
+
block.audioId = document.id;
|
|
142
|
+
break;
|
|
143
|
+
default:
|
|
144
|
+
throw new errors.MtArgumentError(`sendRichMessage: expected document ${document.id} to be used in a document block, but got ${block._}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
_: "inputRichMessage",
|
|
150
|
+
rtl: input.rtl,
|
|
151
|
+
noautolink: input.skipEntityDetection,
|
|
152
|
+
blocks,
|
|
153
|
+
photos: photos.length ? photos : void 0,
|
|
154
|
+
documents: documents.length ? documents : void 0
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
exports._normalizeInputRichMessage = _normalizeInputRichMessage;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { tl } from '../../../tl/index.js';
|
|
2
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
3
|
+
import { InputRichMessage, RichMediaUploadCache } from '../../types/messages/rich/types.js';
|
|
4
|
+
interface NormalizeRichMessageParams {
|
|
5
|
+
abortSignal?: AbortSignal;
|
|
6
|
+
progressCallback?: (id: string, uploaded: number, total: number) => void;
|
|
7
|
+
uploadCache?: RichMediaUploadCache;
|
|
8
|
+
}
|
|
9
|
+
export declare function _normalizeInputRichMessage(client: ITelegramClient, peer: tl.TypeInputPeer, input: InputRichMessage, params: NormalizeRichMessageParams): Promise<tl.TypeInputRichMessage>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { tl } from '../../../tl/index.js';
|
|
2
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
3
|
+
import { InputRichMessage, RichMediaUploadCache } from '../../types/messages/rich/types.js';
|
|
4
|
+
interface NormalizeRichMessageParams {
|
|
5
|
+
abortSignal?: AbortSignal;
|
|
6
|
+
progressCallback?: (id: string, uploaded: number, total: number) => void;
|
|
7
|
+
uploadCache?: RichMediaUploadCache;
|
|
8
|
+
}
|
|
9
|
+
export declare function _normalizeInputRichMessage(client: ITelegramClient, peer: tl.TypeInputPeer, input: InputRichMessage, params: NormalizeRichMessageParams): Promise<tl.TypeInputRichMessage>;
|
|
10
|
+
export {};
|