@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.
- package/client.cjs +8 -0
- package/client.js +8 -0
- package/highlevel/client.d.cts +67 -7
- package/highlevel/client.d.ts +67 -7
- package/highlevel/methods/chats/join-chat.cjs +38 -16
- package/highlevel/methods/chats/join-chat.d.cts +20 -6
- package/highlevel/methods/chats/join-chat.d.ts +20 -6
- package/highlevel/methods/chats/join-chat.js +38 -16
- package/highlevel/methods/chats/save-draft.d.cts +4 -1
- package/highlevel/methods/chats/save-draft.d.ts +4 -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 +5 -0
- package/highlevel/methods.d.ts +5 -0
- package/highlevel/storage/service/peers.cjs +1 -0
- package/highlevel/storage/service/peers.js +1 -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/files/utils.d.cts +1 -1
- package/highlevel/types/files/utils.d.ts +1 -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 -0
- package/highlevel/types/messages/index.d.ts +1 -0
- package/highlevel/types/messages/message.cjs +5 -0
- package/highlevel/types/messages/message.d.cts +3 -0
- package/highlevel/types/messages/message.d.ts +3 -0
- package/highlevel/types/messages/message.js +5 -0
- 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/rich-message.cjs +50 -0
- package/highlevel/types/messages/rich/rich-message.d.cts +18 -0
- package/highlevel/types/messages/rich/rich-message.d.ts +18 -0
- package/highlevel/types/messages/rich/rich-message.js +45 -0
- package/highlevel/types/messages/rich/types.d.cts +76 -0
- package/highlevel/types/messages/rich/types.d.ts +76 -0
- package/highlevel/types/peers/full-chat.cjs +6 -0
- package/highlevel/types/peers/full-chat.d.cts +2 -0
- package/highlevel/types/peers/full-chat.d.ts +2 -0
- package/highlevel/types/peers/full-chat.js +6 -0
- package/highlevel/types/peers/user.cjs +4 -0
- package/highlevel/types/peers/user.d.cts +2 -0
- package/highlevel/types/peers/user.d.ts +2 -0
- package/highlevel/types/peers/user.js +4 -0
- package/highlevel/types/updates/user-typing-update.cjs +2 -0
- package/highlevel/types/updates/user-typing-update.js +2 -0
- package/highlevel/updates/manager.cjs +195 -0
- package/highlevel/updates/manager.js +195 -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/highlevel/utils/inspectable.cjs +1 -0
- package/highlevel/utils/inspectable.d.cts +1 -0
- package/highlevel/utils/inspectable.d.ts +1 -0
- package/highlevel/utils/inspectable.js +1 -0
- package/index.cjs +4 -0
- package/index.js +4 -0
- package/methods.cjs +4 -0
- package/methods.js +4 -0
- package/network/flood-control.cjs +149 -0
- package/network/flood-control.d.cts +79 -0
- package/network/flood-control.d.ts +79 -0
- package/network/flood-control.js +144 -0
- package/network/flood-control.test.d.cts +1 -0
- package/network/flood-control.test.d.ts +1 -0
- package/network/mtproto-session.cjs +1 -21
- package/network/mtproto-session.d.cts +1 -5
- package/network/mtproto-session.d.ts +1 -5
- package/network/mtproto-session.js +2 -22
- 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/multi-session-connection.cjs +26 -16
- package/network/multi-session-connection.d.cts +1 -1
- package/network/multi-session-connection.d.ts +1 -1
- package/network/multi-session-connection.js +26 -16
- package/network/multi-session-connection.test.d.cts +1 -0
- package/network/multi-session-connection.test.d.ts +1 -0
- package/network/network-manager.cjs +3 -2
- package/network/network-manager.d.cts +12 -0
- package/network/network-manager.d.ts +12 -0
- package/network/network-manager.js +3 -2
- package/network/persistent-connection.cjs +25 -1
- package/network/persistent-connection.d.cts +5 -0
- package/network/persistent-connection.d.ts +5 -0
- package/network/persistent-connection.js +25 -1
- package/network/session-connection.cjs +5 -10
- package/network/session-connection.d.cts +0 -2
- package/network/session-connection.d.ts +0 -2
- package/network/session-connection.js +5 -10
- package/package.json +1 -1
- package/tl/api-schema.json +1 -1
- package/tl/binary/reader.cjs +182 -26
- package/tl/binary/reader.js +182 -26
- package/tl/binary/writer.cjs +437 -20
- package/tl/binary/writer.js +437 -20
- package/tl/compat/reader.cjs +23 -0
- package/tl/compat/reader.js +23 -0
- package/tl/index.d.cts +425 -14
- package/tl/index.d.ts +425 -14
- package/tl/inner-tl.cjs +22 -8
- package/tl/inner-tl.js +22 -8
- package/types/utils.d.cts +4 -0
- package/types/utils.d.ts +4 -0
- package/utils/binary/compat.cjs +79 -0
- package/utils/binary/compat.js +79 -0
- package/utils/index.d.cts +1 -0
- package/utils/index.d.ts +1 -0
- package/utils/long-utils.cjs +10 -0
- package/utils/long-utils.js +10 -0
- package/utils.cjs +9 -0
- package/utils.js +11 -2
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { tl } from '../../../../tl/index.js';
|
|
2
|
+
import { ReplaceDeep } from '../../../../types/utils.js';
|
|
3
|
+
import { InputMediaAudio, InputMediaPhoto, InputMediaVideo } from '../../media/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Input rich message media, can be one of:
|
|
6
|
+
* - Bot API-compatible file ID
|
|
7
|
+
* - {@link InputMediaPhoto} (e.g. `InputMedia.photo(...)`)
|
|
8
|
+
* - {@link InputMediaVideo} (e.g. `InputMedia.video(...)`)
|
|
9
|
+
* - {@link InputMediaAudio} (e.g. `InputMedia.audio(...)`)
|
|
10
|
+
* - a raw TL object
|
|
11
|
+
*/
|
|
12
|
+
export type InputRichMessageMedia = string | tl.TypeInputPhoto | tl.TypeInputDocument | InputMediaPhoto | InputMediaVideo | InputMediaAudio;
|
|
13
|
+
/** In-memory cache mapping an {@link InputRichMessageMedia} to its uploaded media, used by streaming drafts */
|
|
14
|
+
export type RichMediaUploadCache = Map<unknown, tl.RawInputMediaPhoto | tl.RawInputMediaDocument>;
|
|
15
|
+
interface InputRichMessageBase {
|
|
16
|
+
/** Whether this message should be rendered RTL */
|
|
17
|
+
rtl?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Whether to skip automatic entities detection (e.g., URLs, email addresses,
|
|
20
|
+
* username mentions, hashtags, cashtags, bot commands, or phone numbers)
|
|
21
|
+
*/
|
|
22
|
+
skipEntityDetection?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Input rich message that is parsed by the server in the specified format
|
|
26
|
+
*/
|
|
27
|
+
export interface InputServerParsedRichMessage extends InputRichMessageBase {
|
|
28
|
+
type: 'html' | 'markdown';
|
|
29
|
+
/**
|
|
30
|
+
* HTML or Markdown content
|
|
31
|
+
*
|
|
32
|
+
* Format reference is available in the Bot API:
|
|
33
|
+
* - [Markdown](https://core.telegram.org/bots/api#rich-markdown-style),
|
|
34
|
+
* - [HTML](https://core.telegram.org/bots/api#rich-html-style)
|
|
35
|
+
*
|
|
36
|
+
* In addition to the above, you can use the following links to reference non-HTTP/s media:
|
|
37
|
+
* - photos: `tg://photo?id=XXX`
|
|
38
|
+
* - videos/gifs: `tg://video?id=XXX`
|
|
39
|
+
* - audio: `tg://audio?id=XXX`
|
|
40
|
+
*
|
|
41
|
+
* where XXX is a unique identifier of the media in the {@link attachments} map.
|
|
42
|
+
*/
|
|
43
|
+
content: string;
|
|
44
|
+
/**
|
|
45
|
+
* Attachments to the rich message.
|
|
46
|
+
*/
|
|
47
|
+
attachments?: Record<string, InputRichMessageMedia>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A convenience wrapper for the raw page blocks containing a file
|
|
51
|
+
* (photo, video, document, etc.)
|
|
52
|
+
*
|
|
53
|
+
* You can simply pass `Long.ZERO` as the ID inside the block, and pass the
|
|
54
|
+
* actual file in the `file` property, and mtcute will take care of the rest.
|
|
55
|
+
*/
|
|
56
|
+
export interface InputPageBlockWithFile {
|
|
57
|
+
block: InputPageBlock;
|
|
58
|
+
file: InputRichMessageMedia;
|
|
59
|
+
}
|
|
60
|
+
export type InputPageBlock = ReplaceDeep<tl.TypePageBlock, tl.TypePageBlock, InputPageBlockWithFile>;
|
|
61
|
+
/**
|
|
62
|
+
* A page block as accepted in a *nested* position (inside another block's
|
|
63
|
+
* children, list items, etc.) — either a raw {@link tl.TypePageBlock} or
|
|
64
|
+
* an {@link InputPageBlockWithFile} wrapper.
|
|
65
|
+
*/
|
|
66
|
+
export type InputPageBlockOrFile = tl.TypePageBlock | InputPageBlockWithFile;
|
|
67
|
+
/** Input rich message that is built block-by-block */
|
|
68
|
+
export interface InputBlocksRichMessage extends InputRichMessageBase {
|
|
69
|
+
type: 'blocks';
|
|
70
|
+
/**
|
|
71
|
+
* Blocks of the rich message
|
|
72
|
+
*/
|
|
73
|
+
blocks: (InputPageBlock | InputPageBlockWithFile)[];
|
|
74
|
+
}
|
|
75
|
+
export type InputRichMessage = tl.TypeInputRichMessage | InputBlocksRichMessage | InputServerParsedRichMessage;
|
|
76
|
+
export {};
|
|
@@ -217,6 +217,11 @@ class FullChat extends chat.Chat {
|
|
|
217
217
|
get botInfo() {
|
|
218
218
|
return this.full._ === "channelFull" ? this.full.botInfo.map((it) => new botInfo.BotInfo(it)) : [];
|
|
219
219
|
}
|
|
220
|
+
/** Bot that approves join requests in this chat, if any */
|
|
221
|
+
get guardBot() {
|
|
222
|
+
if (this.full._ !== "channelFull" || !this.full.guardBotId) return null;
|
|
223
|
+
return new user.User(this.peers.user(this.full.guardBotId));
|
|
224
|
+
}
|
|
220
225
|
/**
|
|
221
226
|
* For supergroups, ID of the basic group from which this supergroup was upgraded,
|
|
222
227
|
* and the identifier of the last message from the original group.
|
|
@@ -321,6 +326,7 @@ const FullChat$1 = /* @__PURE__ */ memoize.memoizeGetters(FullChat, [
|
|
|
321
326
|
"stickerSet",
|
|
322
327
|
"emojiSet",
|
|
323
328
|
"botInfo",
|
|
329
|
+
"guardBot",
|
|
324
330
|
"linkedChat",
|
|
325
331
|
"recentRequesters",
|
|
326
332
|
"stories",
|
|
@@ -117,6 +117,8 @@ export declare class FullChat extends Chat {
|
|
|
117
117
|
get notificationsSettings(): tl.TypePeerNotifySettings | null;
|
|
118
118
|
/** Information about bots in this chat */
|
|
119
119
|
get botInfo(): BotInfo[];
|
|
120
|
+
/** Bot that approves join requests in this chat, if any */
|
|
121
|
+
get guardBot(): User | null;
|
|
120
122
|
/**
|
|
121
123
|
* For supergroups, ID of the basic group from which this supergroup was upgraded,
|
|
122
124
|
* and the identifier of the last message from the original group.
|
|
@@ -117,6 +117,8 @@ export declare class FullChat extends Chat {
|
|
|
117
117
|
get notificationsSettings(): tl.TypePeerNotifySettings | null;
|
|
118
118
|
/** Information about bots in this chat */
|
|
119
119
|
get botInfo(): BotInfo[];
|
|
120
|
+
/** Bot that approves join requests in this chat, if any */
|
|
121
|
+
get guardBot(): User | null;
|
|
120
122
|
/**
|
|
121
123
|
* For supergroups, ID of the basic group from which this supergroup was upgraded,
|
|
122
124
|
* and the identifier of the last message from the original group.
|
|
@@ -210,6 +210,11 @@ class FullChat extends Chat$2 {
|
|
|
210
210
|
get botInfo() {
|
|
211
211
|
return this.full._ === "channelFull" ? this.full.botInfo.map((it) => new BotInfo$2(it)) : [];
|
|
212
212
|
}
|
|
213
|
+
/** Bot that approves join requests in this chat, if any */
|
|
214
|
+
get guardBot() {
|
|
215
|
+
if (this.full._ !== "channelFull" || !this.full.guardBotId) return null;
|
|
216
|
+
return new User$2(this.peers.user(this.full.guardBotId));
|
|
217
|
+
}
|
|
213
218
|
/**
|
|
214
219
|
* For supergroups, ID of the basic group from which this supergroup was upgraded,
|
|
215
220
|
* and the identifier of the last message from the original group.
|
|
@@ -314,6 +319,7 @@ const FullChat$1 = /* @__PURE__ */ memoizeGetters(FullChat, [
|
|
|
314
319
|
"stickerSet",
|
|
315
320
|
"emojiSet",
|
|
316
321
|
"botInfo",
|
|
322
|
+
"guardBot",
|
|
317
323
|
"linkedChat",
|
|
318
324
|
"recentRequesters",
|
|
319
325
|
"stories",
|
|
@@ -83,6 +83,10 @@ class User {
|
|
|
83
83
|
get isBusinessBot() {
|
|
84
84
|
return this.raw.botBusiness;
|
|
85
85
|
}
|
|
86
|
+
/** Whether this bot can approve join requests */
|
|
87
|
+
get isBotGuard() {
|
|
88
|
+
return this.raw.botGuard;
|
|
89
|
+
}
|
|
86
90
|
/** Whether this user is a bot that has access to all messages */
|
|
87
91
|
get isBotWithHistory() {
|
|
88
92
|
return this.raw.botChatHistory;
|
|
@@ -70,6 +70,8 @@ export declare class User {
|
|
|
70
70
|
* Telegram Business account to receive its messages
|
|
71
71
|
*/
|
|
72
72
|
get isBusinessBot(): boolean;
|
|
73
|
+
/** Whether this bot can approve join requests */
|
|
74
|
+
get isBotGuard(): boolean;
|
|
73
75
|
/** Whether this user is a bot that has access to all messages */
|
|
74
76
|
get isBotWithHistory(): boolean;
|
|
75
77
|
/** Whether this user is a bot that can't be added to chats */
|
|
@@ -70,6 +70,8 @@ export declare class User {
|
|
|
70
70
|
* Telegram Business account to receive its messages
|
|
71
71
|
*/
|
|
72
72
|
get isBusinessBot(): boolean;
|
|
73
|
+
/** Whether this bot can approve join requests */
|
|
74
|
+
get isBotGuard(): boolean;
|
|
73
75
|
/** Whether this user is a bot that has access to all messages */
|
|
74
76
|
get isBotWithHistory(): boolean;
|
|
75
77
|
/** Whether this user is a bot that can't be added to chats */
|
|
@@ -76,6 +76,10 @@ class User {
|
|
|
76
76
|
get isBusinessBot() {
|
|
77
77
|
return this.raw.botBusiness;
|
|
78
78
|
}
|
|
79
|
+
/** Whether this bot can approve join requests */
|
|
80
|
+
get isBotGuard() {
|
|
81
|
+
return this.raw.botGuard;
|
|
82
|
+
}
|
|
79
83
|
/** Whether this user is a bot that has access to all messages */
|
|
80
84
|
get isBotWithHistory() {
|
|
81
85
|
return this.raw.botChatHistory;
|
|
@@ -65,6 +65,8 @@ class UserTypingUpdate {
|
|
|
65
65
|
switch (this.raw.action._) {
|
|
66
66
|
case "sendMessageTypingAction":
|
|
67
67
|
case "sendMessageTextDraftAction":
|
|
68
|
+
case "inputSendMessageRichMessageDraftAction":
|
|
69
|
+
case "sendMessageRichMessageDraftAction":
|
|
68
70
|
return "typing";
|
|
69
71
|
case "sendMessageCancelAction":
|
|
70
72
|
return "cancel";
|
|
@@ -58,6 +58,8 @@ class UserTypingUpdate {
|
|
|
58
58
|
switch (this.raw.action._) {
|
|
59
59
|
case "sendMessageTypingAction":
|
|
60
60
|
case "sendMessageTextDraftAction":
|
|
61
|
+
case "inputSendMessageRichMessageDraftAction":
|
|
62
|
+
case "sendMessageRichMessageDraftAction":
|
|
61
63
|
return "typing";
|
|
62
64
|
case "sendMessageCancelAction":
|
|
63
65
|
return "cancel";
|
|
@@ -21,6 +21,178 @@ const innerTl = require("../../tl/inner-tl.cjs");
|
|
|
21
21
|
const WARN_EVERY = 100;
|
|
22
22
|
const KEEP_ALIVE_INTERVAL = 15 * 60 * 1e3;
|
|
23
23
|
const UPDATES_TOO_LONG = { _: "updatesTooLong" };
|
|
24
|
+
function collectRichTextPeerIds(text, peers) {
|
|
25
|
+
if (!text) return;
|
|
26
|
+
switch (text._) {
|
|
27
|
+
case "textEmpty":
|
|
28
|
+
case "textPlain":
|
|
29
|
+
case "textEmail":
|
|
30
|
+
case "textPhone":
|
|
31
|
+
case "textImage":
|
|
32
|
+
case "textMath":
|
|
33
|
+
case "textCustomEmoji":
|
|
34
|
+
break;
|
|
35
|
+
case "textBold":
|
|
36
|
+
case "textItalic":
|
|
37
|
+
case "textUnderline":
|
|
38
|
+
case "textStrike":
|
|
39
|
+
case "textFixed":
|
|
40
|
+
case "textUrl":
|
|
41
|
+
case "textSubscript":
|
|
42
|
+
case "textSuperscript":
|
|
43
|
+
case "textMarked":
|
|
44
|
+
case "textAnchor":
|
|
45
|
+
case "textSpoiler":
|
|
46
|
+
case "textMention":
|
|
47
|
+
case "textHashtag":
|
|
48
|
+
case "textBotCommand":
|
|
49
|
+
case "textCashtag":
|
|
50
|
+
case "textAutoUrl":
|
|
51
|
+
case "textAutoEmail":
|
|
52
|
+
case "textAutoPhone":
|
|
53
|
+
case "textBankCard":
|
|
54
|
+
case "textDate":
|
|
55
|
+
collectRichTextPeerIds(text.text, peers);
|
|
56
|
+
break;
|
|
57
|
+
case "textConcat":
|
|
58
|
+
for (const child of text.texts) collectRichTextPeerIds(child, peers);
|
|
59
|
+
break;
|
|
60
|
+
case "textMentionName":
|
|
61
|
+
peers.add(text.userId);
|
|
62
|
+
collectRichTextPeerIds(text.text, peers);
|
|
63
|
+
break;
|
|
64
|
+
default:
|
|
65
|
+
utils$1.assertNever();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function collectPageCaptionPeerIds(caption, peers) {
|
|
69
|
+
if (!caption) return;
|
|
70
|
+
collectRichTextPeerIds(caption.text, peers);
|
|
71
|
+
collectRichTextPeerIds(caption.credit, peers);
|
|
72
|
+
}
|
|
73
|
+
function collectPageBlockPeerIds(block, peers) {
|
|
74
|
+
if (!block) return;
|
|
75
|
+
switch (block._) {
|
|
76
|
+
case "pageBlockUnsupported":
|
|
77
|
+
case "pageBlockDivider":
|
|
78
|
+
case "pageBlockAnchor":
|
|
79
|
+
case "pageBlockMath":
|
|
80
|
+
break;
|
|
81
|
+
case "pageBlockTitle":
|
|
82
|
+
case "pageBlockSubtitle":
|
|
83
|
+
case "pageBlockHeader":
|
|
84
|
+
case "pageBlockSubheader":
|
|
85
|
+
case "pageBlockParagraph":
|
|
86
|
+
case "pageBlockPreformatted":
|
|
87
|
+
case "pageBlockFooter":
|
|
88
|
+
case "pageBlockKicker":
|
|
89
|
+
case "pageBlockThinking":
|
|
90
|
+
case "pageBlockHeading1":
|
|
91
|
+
case "pageBlockHeading2":
|
|
92
|
+
case "pageBlockHeading3":
|
|
93
|
+
case "pageBlockHeading4":
|
|
94
|
+
case "pageBlockHeading5":
|
|
95
|
+
case "pageBlockHeading6":
|
|
96
|
+
collectRichTextPeerIds(block.text, peers);
|
|
97
|
+
break;
|
|
98
|
+
case "pageBlockAuthorDate":
|
|
99
|
+
collectRichTextPeerIds(block.author, peers);
|
|
100
|
+
break;
|
|
101
|
+
case "pageBlockList":
|
|
102
|
+
for (const item of block.items) collectPageListItemPeerIds(item, peers);
|
|
103
|
+
break;
|
|
104
|
+
case "pageBlockOrderedList":
|
|
105
|
+
for (const item of block.items) collectPageListOrderedItemPeerIds(item, peers);
|
|
106
|
+
break;
|
|
107
|
+
case "pageBlockBlockquote":
|
|
108
|
+
case "pageBlockPullquote":
|
|
109
|
+
collectRichTextPeerIds(block.text, peers);
|
|
110
|
+
collectRichTextPeerIds(block.caption, peers);
|
|
111
|
+
break;
|
|
112
|
+
case "pageBlockPhoto":
|
|
113
|
+
case "pageBlockVideo":
|
|
114
|
+
case "pageBlockEmbed":
|
|
115
|
+
case "pageBlockAudio":
|
|
116
|
+
case "pageBlockMap":
|
|
117
|
+
case "inputPageBlockMap":
|
|
118
|
+
collectPageCaptionPeerIds(block.caption, peers);
|
|
119
|
+
break;
|
|
120
|
+
case "pageBlockCover":
|
|
121
|
+
collectPageBlockPeerIds(block.cover, peers);
|
|
122
|
+
break;
|
|
123
|
+
case "pageBlockEmbedPost":
|
|
124
|
+
for (const child of block.blocks) collectPageBlockPeerIds(child, peers);
|
|
125
|
+
collectPageCaptionPeerIds(block.caption, peers);
|
|
126
|
+
break;
|
|
127
|
+
case "pageBlockCollage":
|
|
128
|
+
case "pageBlockSlideshow":
|
|
129
|
+
for (const child of block.items) collectPageBlockPeerIds(child, peers);
|
|
130
|
+
collectPageCaptionPeerIds(block.caption, peers);
|
|
131
|
+
break;
|
|
132
|
+
case "pageBlockChannel":
|
|
133
|
+
switch (block.channel._) {
|
|
134
|
+
case "chatEmpty":
|
|
135
|
+
case "chat":
|
|
136
|
+
case "chatForbidden":
|
|
137
|
+
peers.add(peerUtils.getMarkedPeerId(block.channel.id, "chat"));
|
|
138
|
+
break;
|
|
139
|
+
case "channel":
|
|
140
|
+
case "channelForbidden":
|
|
141
|
+
peers.add(peerUtils.getMarkedPeerId(block.channel.id, "channel"));
|
|
142
|
+
break;
|
|
143
|
+
default:
|
|
144
|
+
utils$1.assertNever(block.channel);
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
case "pageBlockTable":
|
|
148
|
+
collectRichTextPeerIds(block.title, peers);
|
|
149
|
+
for (const row of block.rows) {
|
|
150
|
+
for (const cell of row.cells) collectRichTextPeerIds(cell.text, peers);
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
case "pageBlockDetails":
|
|
154
|
+
for (const child of block.blocks) collectPageBlockPeerIds(child, peers);
|
|
155
|
+
collectRichTextPeerIds(block.title, peers);
|
|
156
|
+
break;
|
|
157
|
+
case "pageBlockRelatedArticles":
|
|
158
|
+
collectRichTextPeerIds(block.title, peers);
|
|
159
|
+
break;
|
|
160
|
+
case "pageBlockBlockquoteBlocks":
|
|
161
|
+
for (const child of block.blocks) collectPageBlockPeerIds(child, peers);
|
|
162
|
+
collectRichTextPeerIds(block.caption, peers);
|
|
163
|
+
break;
|
|
164
|
+
default:
|
|
165
|
+
utils$1.assertNever();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function collectPageListItemPeerIds(item, peers) {
|
|
169
|
+
switch (item._) {
|
|
170
|
+
case "pageListItemText":
|
|
171
|
+
collectRichTextPeerIds(item.text, peers);
|
|
172
|
+
break;
|
|
173
|
+
case "pageListItemBlocks":
|
|
174
|
+
for (const block of item.blocks) collectPageBlockPeerIds(block, peers);
|
|
175
|
+
break;
|
|
176
|
+
default:
|
|
177
|
+
utils$1.assertNever();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function collectPageListOrderedItemPeerIds(item, peers) {
|
|
181
|
+
switch (item._) {
|
|
182
|
+
case "pageListOrderedItemText":
|
|
183
|
+
collectRichTextPeerIds(item.text, peers);
|
|
184
|
+
break;
|
|
185
|
+
case "pageListOrderedItemBlocks":
|
|
186
|
+
for (const block of item.blocks) collectPageBlockPeerIds(block, peers);
|
|
187
|
+
break;
|
|
188
|
+
default:
|
|
189
|
+
utils$1.assertNever();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function collectRichMessagePeerIds(richMessage, peers) {
|
|
193
|
+
if (!richMessage) return;
|
|
194
|
+
for (const block of richMessage.blocks) collectPageBlockPeerIds(block, peers);
|
|
195
|
+
}
|
|
24
196
|
class UpdatesManager {
|
|
25
197
|
constructor(client, params = {}) {
|
|
26
198
|
this.client = client;
|
|
@@ -501,6 +673,13 @@ class UpdatesManager {
|
|
|
501
673
|
}
|
|
502
674
|
}
|
|
503
675
|
}
|
|
676
|
+
if (msg.richMessage) {
|
|
677
|
+
const richMessagePeers = /* @__PURE__ */ new Set();
|
|
678
|
+
collectRichMessagePeerIds(msg.richMessage, richMessagePeers);
|
|
679
|
+
for (const peer of richMessagePeers) {
|
|
680
|
+
if (!await fetchPeer(peer)) return missing;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
504
683
|
if (msg.media) {
|
|
505
684
|
switch (msg.media._) {
|
|
506
685
|
case "messageMediaContact":
|
|
@@ -550,6 +729,13 @@ class UpdatesManager {
|
|
|
550
729
|
}
|
|
551
730
|
}
|
|
552
731
|
}
|
|
732
|
+
if ("richMessage" in upd.draft && upd.draft.richMessage) {
|
|
733
|
+
const richMessagePeers = /* @__PURE__ */ new Set();
|
|
734
|
+
collectRichMessagePeerIds(upd.draft.richMessage, richMessagePeers);
|
|
735
|
+
for (const peer of richMessagePeers) {
|
|
736
|
+
if (!await fetchPeer(peer)) return missing;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
553
739
|
}
|
|
554
740
|
return missing;
|
|
555
741
|
}
|
|
@@ -574,6 +760,11 @@ class UpdatesManager {
|
|
|
574
760
|
store(msg.viaBotId);
|
|
575
761
|
store(msg.guestchatViaFrom);
|
|
576
762
|
store(msg.fwdFrom?.fromId);
|
|
763
|
+
if (msg.richMessage) {
|
|
764
|
+
const richMessagePeers = /* @__PURE__ */ new Set();
|
|
765
|
+
collectRichMessagePeerIds(msg.richMessage, richMessagePeers);
|
|
766
|
+
store([...richMessagePeers]);
|
|
767
|
+
}
|
|
577
768
|
if (msg.media) {
|
|
578
769
|
switch (msg.media._) {
|
|
579
770
|
case "messageMediaWebPage":
|
|
@@ -1367,6 +1558,7 @@ class UpdatesManager {
|
|
|
1367
1558
|
localPts,
|
|
1368
1559
|
pending.ptsBefore
|
|
1369
1560
|
);
|
|
1561
|
+
postponedTimer.emitBefore(pending.timeout);
|
|
1370
1562
|
} else {
|
|
1371
1563
|
log.debug(
|
|
1372
1564
|
"gap for postponed %s (cid = %d) wasn't filled, fetching diff (current pts %d, need %d)",
|
|
@@ -1444,6 +1636,8 @@ class UpdatesManager {
|
|
|
1444
1636
|
this.qts,
|
|
1445
1637
|
pending.qtsBefore
|
|
1446
1638
|
);
|
|
1639
|
+
pendingQtsUpdatesPostponed.removeIndex(i);
|
|
1640
|
+
i--;
|
|
1447
1641
|
continue;
|
|
1448
1642
|
}
|
|
1449
1643
|
if (this.qts < pending.qtsBefore) {
|
|
@@ -1456,6 +1650,7 @@ class UpdatesManager {
|
|
|
1456
1650
|
this.qts,
|
|
1457
1651
|
pending.qtsBefore
|
|
1458
1652
|
);
|
|
1653
|
+
postponedTimer.emitBefore(pending.timeout);
|
|
1459
1654
|
} else {
|
|
1460
1655
|
log.debug(
|
|
1461
1656
|
"gap for postponed %s wasn't filled, fetching diff (current qts %d, need %d)",
|
|
@@ -14,6 +14,178 @@ import { RpcError } from "../../tl/inner-tl.js";
|
|
|
14
14
|
const WARN_EVERY = 100;
|
|
15
15
|
const KEEP_ALIVE_INTERVAL = 15 * 60 * 1e3;
|
|
16
16
|
const UPDATES_TOO_LONG = { _: "updatesTooLong" };
|
|
17
|
+
function collectRichTextPeerIds(text, peers) {
|
|
18
|
+
if (!text) return;
|
|
19
|
+
switch (text._) {
|
|
20
|
+
case "textEmpty":
|
|
21
|
+
case "textPlain":
|
|
22
|
+
case "textEmail":
|
|
23
|
+
case "textPhone":
|
|
24
|
+
case "textImage":
|
|
25
|
+
case "textMath":
|
|
26
|
+
case "textCustomEmoji":
|
|
27
|
+
break;
|
|
28
|
+
case "textBold":
|
|
29
|
+
case "textItalic":
|
|
30
|
+
case "textUnderline":
|
|
31
|
+
case "textStrike":
|
|
32
|
+
case "textFixed":
|
|
33
|
+
case "textUrl":
|
|
34
|
+
case "textSubscript":
|
|
35
|
+
case "textSuperscript":
|
|
36
|
+
case "textMarked":
|
|
37
|
+
case "textAnchor":
|
|
38
|
+
case "textSpoiler":
|
|
39
|
+
case "textMention":
|
|
40
|
+
case "textHashtag":
|
|
41
|
+
case "textBotCommand":
|
|
42
|
+
case "textCashtag":
|
|
43
|
+
case "textAutoUrl":
|
|
44
|
+
case "textAutoEmail":
|
|
45
|
+
case "textAutoPhone":
|
|
46
|
+
case "textBankCard":
|
|
47
|
+
case "textDate":
|
|
48
|
+
collectRichTextPeerIds(text.text, peers);
|
|
49
|
+
break;
|
|
50
|
+
case "textConcat":
|
|
51
|
+
for (const child of text.texts) collectRichTextPeerIds(child, peers);
|
|
52
|
+
break;
|
|
53
|
+
case "textMentionName":
|
|
54
|
+
peers.add(text.userId);
|
|
55
|
+
collectRichTextPeerIds(text.text, peers);
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
assertNever();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function collectPageCaptionPeerIds(caption, peers) {
|
|
62
|
+
if (!caption) return;
|
|
63
|
+
collectRichTextPeerIds(caption.text, peers);
|
|
64
|
+
collectRichTextPeerIds(caption.credit, peers);
|
|
65
|
+
}
|
|
66
|
+
function collectPageBlockPeerIds(block, peers) {
|
|
67
|
+
if (!block) return;
|
|
68
|
+
switch (block._) {
|
|
69
|
+
case "pageBlockUnsupported":
|
|
70
|
+
case "pageBlockDivider":
|
|
71
|
+
case "pageBlockAnchor":
|
|
72
|
+
case "pageBlockMath":
|
|
73
|
+
break;
|
|
74
|
+
case "pageBlockTitle":
|
|
75
|
+
case "pageBlockSubtitle":
|
|
76
|
+
case "pageBlockHeader":
|
|
77
|
+
case "pageBlockSubheader":
|
|
78
|
+
case "pageBlockParagraph":
|
|
79
|
+
case "pageBlockPreformatted":
|
|
80
|
+
case "pageBlockFooter":
|
|
81
|
+
case "pageBlockKicker":
|
|
82
|
+
case "pageBlockThinking":
|
|
83
|
+
case "pageBlockHeading1":
|
|
84
|
+
case "pageBlockHeading2":
|
|
85
|
+
case "pageBlockHeading3":
|
|
86
|
+
case "pageBlockHeading4":
|
|
87
|
+
case "pageBlockHeading5":
|
|
88
|
+
case "pageBlockHeading6":
|
|
89
|
+
collectRichTextPeerIds(block.text, peers);
|
|
90
|
+
break;
|
|
91
|
+
case "pageBlockAuthorDate":
|
|
92
|
+
collectRichTextPeerIds(block.author, peers);
|
|
93
|
+
break;
|
|
94
|
+
case "pageBlockList":
|
|
95
|
+
for (const item of block.items) collectPageListItemPeerIds(item, peers);
|
|
96
|
+
break;
|
|
97
|
+
case "pageBlockOrderedList":
|
|
98
|
+
for (const item of block.items) collectPageListOrderedItemPeerIds(item, peers);
|
|
99
|
+
break;
|
|
100
|
+
case "pageBlockBlockquote":
|
|
101
|
+
case "pageBlockPullquote":
|
|
102
|
+
collectRichTextPeerIds(block.text, peers);
|
|
103
|
+
collectRichTextPeerIds(block.caption, peers);
|
|
104
|
+
break;
|
|
105
|
+
case "pageBlockPhoto":
|
|
106
|
+
case "pageBlockVideo":
|
|
107
|
+
case "pageBlockEmbed":
|
|
108
|
+
case "pageBlockAudio":
|
|
109
|
+
case "pageBlockMap":
|
|
110
|
+
case "inputPageBlockMap":
|
|
111
|
+
collectPageCaptionPeerIds(block.caption, peers);
|
|
112
|
+
break;
|
|
113
|
+
case "pageBlockCover":
|
|
114
|
+
collectPageBlockPeerIds(block.cover, peers);
|
|
115
|
+
break;
|
|
116
|
+
case "pageBlockEmbedPost":
|
|
117
|
+
for (const child of block.blocks) collectPageBlockPeerIds(child, peers);
|
|
118
|
+
collectPageCaptionPeerIds(block.caption, peers);
|
|
119
|
+
break;
|
|
120
|
+
case "pageBlockCollage":
|
|
121
|
+
case "pageBlockSlideshow":
|
|
122
|
+
for (const child of block.items) collectPageBlockPeerIds(child, peers);
|
|
123
|
+
collectPageCaptionPeerIds(block.caption, peers);
|
|
124
|
+
break;
|
|
125
|
+
case "pageBlockChannel":
|
|
126
|
+
switch (block.channel._) {
|
|
127
|
+
case "chatEmpty":
|
|
128
|
+
case "chat":
|
|
129
|
+
case "chatForbidden":
|
|
130
|
+
peers.add(getMarkedPeerId(block.channel.id, "chat"));
|
|
131
|
+
break;
|
|
132
|
+
case "channel":
|
|
133
|
+
case "channelForbidden":
|
|
134
|
+
peers.add(getMarkedPeerId(block.channel.id, "channel"));
|
|
135
|
+
break;
|
|
136
|
+
default:
|
|
137
|
+
assertNever(block.channel);
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
case "pageBlockTable":
|
|
141
|
+
collectRichTextPeerIds(block.title, peers);
|
|
142
|
+
for (const row of block.rows) {
|
|
143
|
+
for (const cell of row.cells) collectRichTextPeerIds(cell.text, peers);
|
|
144
|
+
}
|
|
145
|
+
break;
|
|
146
|
+
case "pageBlockDetails":
|
|
147
|
+
for (const child of block.blocks) collectPageBlockPeerIds(child, peers);
|
|
148
|
+
collectRichTextPeerIds(block.title, peers);
|
|
149
|
+
break;
|
|
150
|
+
case "pageBlockRelatedArticles":
|
|
151
|
+
collectRichTextPeerIds(block.title, peers);
|
|
152
|
+
break;
|
|
153
|
+
case "pageBlockBlockquoteBlocks":
|
|
154
|
+
for (const child of block.blocks) collectPageBlockPeerIds(child, peers);
|
|
155
|
+
collectRichTextPeerIds(block.caption, peers);
|
|
156
|
+
break;
|
|
157
|
+
default:
|
|
158
|
+
assertNever();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function collectPageListItemPeerIds(item, peers) {
|
|
162
|
+
switch (item._) {
|
|
163
|
+
case "pageListItemText":
|
|
164
|
+
collectRichTextPeerIds(item.text, peers);
|
|
165
|
+
break;
|
|
166
|
+
case "pageListItemBlocks":
|
|
167
|
+
for (const block of item.blocks) collectPageBlockPeerIds(block, peers);
|
|
168
|
+
break;
|
|
169
|
+
default:
|
|
170
|
+
assertNever();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function collectPageListOrderedItemPeerIds(item, peers) {
|
|
174
|
+
switch (item._) {
|
|
175
|
+
case "pageListOrderedItemText":
|
|
176
|
+
collectRichTextPeerIds(item.text, peers);
|
|
177
|
+
break;
|
|
178
|
+
case "pageListOrderedItemBlocks":
|
|
179
|
+
for (const block of item.blocks) collectPageBlockPeerIds(block, peers);
|
|
180
|
+
break;
|
|
181
|
+
default:
|
|
182
|
+
assertNever();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function collectRichMessagePeerIds(richMessage, peers) {
|
|
186
|
+
if (!richMessage) return;
|
|
187
|
+
for (const block of richMessage.blocks) collectPageBlockPeerIds(block, peers);
|
|
188
|
+
}
|
|
17
189
|
class UpdatesManager {
|
|
18
190
|
constructor(client, params = {}) {
|
|
19
191
|
this.client = client;
|
|
@@ -494,6 +666,13 @@ class UpdatesManager {
|
|
|
494
666
|
}
|
|
495
667
|
}
|
|
496
668
|
}
|
|
669
|
+
if (msg.richMessage) {
|
|
670
|
+
const richMessagePeers = /* @__PURE__ */ new Set();
|
|
671
|
+
collectRichMessagePeerIds(msg.richMessage, richMessagePeers);
|
|
672
|
+
for (const peer of richMessagePeers) {
|
|
673
|
+
if (!await fetchPeer(peer)) return missing;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
497
676
|
if (msg.media) {
|
|
498
677
|
switch (msg.media._) {
|
|
499
678
|
case "messageMediaContact":
|
|
@@ -543,6 +722,13 @@ class UpdatesManager {
|
|
|
543
722
|
}
|
|
544
723
|
}
|
|
545
724
|
}
|
|
725
|
+
if ("richMessage" in upd.draft && upd.draft.richMessage) {
|
|
726
|
+
const richMessagePeers = /* @__PURE__ */ new Set();
|
|
727
|
+
collectRichMessagePeerIds(upd.draft.richMessage, richMessagePeers);
|
|
728
|
+
for (const peer of richMessagePeers) {
|
|
729
|
+
if (!await fetchPeer(peer)) return missing;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
546
732
|
}
|
|
547
733
|
return missing;
|
|
548
734
|
}
|
|
@@ -567,6 +753,11 @@ class UpdatesManager {
|
|
|
567
753
|
store(msg.viaBotId);
|
|
568
754
|
store(msg.guestchatViaFrom);
|
|
569
755
|
store(msg.fwdFrom?.fromId);
|
|
756
|
+
if (msg.richMessage) {
|
|
757
|
+
const richMessagePeers = /* @__PURE__ */ new Set();
|
|
758
|
+
collectRichMessagePeerIds(msg.richMessage, richMessagePeers);
|
|
759
|
+
store([...richMessagePeers]);
|
|
760
|
+
}
|
|
570
761
|
if (msg.media) {
|
|
571
762
|
switch (msg.media._) {
|
|
572
763
|
case "messageMediaWebPage":
|
|
@@ -1360,6 +1551,7 @@ class UpdatesManager {
|
|
|
1360
1551
|
localPts,
|
|
1361
1552
|
pending.ptsBefore
|
|
1362
1553
|
);
|
|
1554
|
+
postponedTimer.emitBefore(pending.timeout);
|
|
1363
1555
|
} else {
|
|
1364
1556
|
log.debug(
|
|
1365
1557
|
"gap for postponed %s (cid = %d) wasn't filled, fetching diff (current pts %d, need %d)",
|
|
@@ -1437,6 +1629,8 @@ class UpdatesManager {
|
|
|
1437
1629
|
this.qts,
|
|
1438
1630
|
pending.qtsBefore
|
|
1439
1631
|
);
|
|
1632
|
+
pendingQtsUpdatesPostponed.removeIndex(i);
|
|
1633
|
+
i--;
|
|
1440
1634
|
continue;
|
|
1441
1635
|
}
|
|
1442
1636
|
if (this.qts < pending.qtsBefore) {
|
|
@@ -1449,6 +1643,7 @@ class UpdatesManager {
|
|
|
1449
1643
|
this.qts,
|
|
1450
1644
|
pending.qtsBefore
|
|
1451
1645
|
);
|
|
1646
|
+
postponedTimer.emitBefore(pending.timeout);
|
|
1452
1647
|
} else {
|
|
1453
1648
|
log.debug(
|
|
1454
1649
|
"gap for postponed %s wasn't filled, fetching diff (current qts %d, need %d)",
|