@mtcute/core 0.30.0 → 0.30.2
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/download-iterable.cjs +80 -45
- package/highlevel/methods/files/download-iterable.js +80 -45
- package/highlevel/methods/files/normalize-input-media.cjs +9 -1
- package/highlevel/methods/files/normalize-input-media.js +10 -2
- package/highlevel/methods/files/upload-file.cjs +6 -1
- package/highlevel/methods/files/upload-file.js +6 -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 +168 -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 +163 -0
- package/highlevel/methods/messages/send-common.cjs +3 -2
- package/highlevel/methods/messages/send-common.d.cts +4 -1
- package/highlevel/methods/messages/send-common.d.ts +4 -1
- package/highlevel/methods/messages/send-common.js +3 -2
- 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/files/utils.d.cts +9 -0
- package/highlevel/types/files/utils.d.ts +9 -0
- 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 +10 -169
- package/highlevel/updates/manager.js +10 -169
- 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/index.d.cts +1 -0
- package/highlevel/utils/index.d.ts +1 -0
- package/highlevel/utils/walk-page-blocks.cjs +164 -0
- package/highlevel/utils/walk-page-blocks.d.cts +9 -0
- package/highlevel/utils/walk-page-blocks.d.ts +9 -0
- package/highlevel/utils/walk-page-blocks.js +159 -0
- package/index.cjs +3 -1
- package/index.js +3 -1
- package/methods.cjs +4 -0
- package/methods.js +4 -0
- package/network/authorization.cjs +1 -1
- package/network/authorization.js +1 -1
- package/network/delay-gate.cjs +29 -0
- package/network/delay-gate.d.cts +5 -0
- package/network/delay-gate.d.ts +5 -0
- package/network/delay-gate.js +24 -0
- package/network/delay-gate.test.d.cts +1 -0
- package/network/delay-gate.test.d.ts +1 -0
- package/network/message-id-store.cjs +30 -0
- package/network/message-id-store.d.cts +7 -0
- package/network/message-id-store.d.ts +7 -0
- package/network/message-id-store.js +25 -0
- package/network/message-id-store.test.d.cts +1 -0
- package/network/message-id-store.test.d.ts +1 -0
- package/network/middlewares/bundle.cjs +2 -0
- package/network/middlewares/bundle.d.cts +1 -0
- package/network/middlewares/bundle.d.ts +1 -0
- package/network/middlewares/bundle.js +2 -0
- package/network/middlewares/default.cjs +6 -1
- package/network/middlewares/default.js +6 -1
- package/network/middlewares/flood-waiter.test.d.cts +1 -0
- package/network/middlewares/flood-waiter.test.d.ts +1 -0
- package/network/middlewares/internal-errors.test.d.cts +1 -0
- package/network/middlewares/internal-errors.test.d.ts +1 -0
- package/network/middlewares/media-throttle.cjs +65 -0
- package/network/middlewares/media-throttle.d.cts +5 -0
- package/network/middlewares/media-throttle.d.ts +5 -0
- package/network/middlewares/media-throttle.js +60 -0
- package/network/middlewares/media-throttle.test.d.cts +1 -0
- package/network/middlewares/media-throttle.test.d.ts +1 -0
- package/network/middlewares/on-error.test.d.cts +1 -0
- package/network/middlewares/on-error.test.d.ts +1 -0
- package/network/middlewares/on-method.test.d.cts +1 -0
- package/network/middlewares/on-method.test.d.ts +1 -0
- package/network/mtproto-session.cjs +9 -2
- package/network/mtproto-session.d.cts +5 -2
- package/network/mtproto-session.d.ts +5 -2
- package/network/mtproto-session.js +9 -2
- 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 +7 -0
- package/network/multi-session-connection.d.cts +2 -0
- package/network/multi-session-connection.d.ts +2 -0
- package/network/multi-session-connection.js +7 -0
- package/network/network-manager.cjs +7 -1
- package/network/network-manager.js +7 -1
- package/network/resource-limiter.cjs +60 -0
- package/network/resource-limiter.d.cts +11 -0
- package/network/resource-limiter.d.ts +11 -0
- package/network/resource-limiter.js +55 -0
- package/network/resource-limiter.test.d.cts +1 -0
- package/network/resource-limiter.test.d.ts +1 -0
- package/network/server-salt.cjs +7 -3
- package/network/server-salt.d.cts +2 -0
- package/network/server-salt.d.ts +2 -0
- package/network/server-salt.js +7 -3
- package/network/session-connection.cjs +106 -20
- package/network/session-connection.d.cts +11 -0
- package/network/session-connection.d.ts +11 -0
- package/network/session-connection.js +106 -20
- 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 +4 -0
- package/utils.js +5 -1
|
@@ -5,11 +5,11 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
|
|
|
5
5
|
}
|
|
6
6
|
"use strict";
|
|
7
7
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
-
const longUtils = require("
|
|
9
|
-
const inspectable = require("
|
|
10
|
-
const memoize = require("
|
|
11
|
-
const documentUtils = require("
|
|
12
|
-
const photo = require("
|
|
8
|
+
const longUtils = require("../../../../utils/long-utils.cjs");
|
|
9
|
+
const inspectable = require("../../../utils/inspectable.cjs");
|
|
10
|
+
const memoize = require("../../../utils/memoize.cjs");
|
|
11
|
+
const documentUtils = require("../../media/document-utils.cjs");
|
|
12
|
+
const photo = require("../../media/photo.cjs");
|
|
13
13
|
class RichMessage {
|
|
14
14
|
constructor(raw) {
|
|
15
15
|
this.raw = raw;
|
|
@@ -31,7 +31,7 @@ class RichMessage {
|
|
|
31
31
|
}
|
|
32
32
|
return map;
|
|
33
33
|
}
|
|
34
|
-
/** Documents (usually videos) in this message */
|
|
34
|
+
/** Documents (usually videos and audios) in this message */
|
|
35
35
|
get documents() {
|
|
36
36
|
const map = new longUtils.LongMap();
|
|
37
37
|
for (const photo2 of this.raw.documents) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { tl } from '
|
|
2
|
-
import { ParsedDocument } from '
|
|
3
|
-
import { LongMap } from '
|
|
4
|
-
import { Photo } from '
|
|
1
|
+
import { tl } from '../../../../tl/index.js';
|
|
2
|
+
import { ParsedDocument } from '../../media/document-utils.js';
|
|
3
|
+
import { LongMap } from '../../../../utils/long-utils.js';
|
|
4
|
+
import { Photo } from '../../media/photo.js';
|
|
5
5
|
export declare class RichMessage {
|
|
6
6
|
readonly raw: tl.TypeRichMessage;
|
|
7
7
|
constructor(raw: tl.TypeRichMessage);
|
|
@@ -11,7 +11,7 @@ export declare class RichMessage {
|
|
|
11
11
|
get isPart(): boolean;
|
|
12
12
|
/** Photos in this message */
|
|
13
13
|
get photos(): LongMap<Photo>;
|
|
14
|
-
/** Documents (usually videos) in this message */
|
|
14
|
+
/** Documents (usually videos and audios) in this message */
|
|
15
15
|
get documents(): LongMap<ParsedDocument>;
|
|
16
16
|
/** Blocks in this message */
|
|
17
17
|
get blocks(): tl.TypePageBlock[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { tl } from '
|
|
2
|
-
import { ParsedDocument } from '
|
|
3
|
-
import { LongMap } from '
|
|
4
|
-
import { Photo } from '
|
|
1
|
+
import { tl } from '../../../../tl/index.js';
|
|
2
|
+
import { ParsedDocument } from '../../media/document-utils.js';
|
|
3
|
+
import { LongMap } from '../../../../utils/long-utils.js';
|
|
4
|
+
import { Photo } from '../../media/photo.js';
|
|
5
5
|
export declare class RichMessage {
|
|
6
6
|
readonly raw: tl.TypeRichMessage;
|
|
7
7
|
constructor(raw: tl.TypeRichMessage);
|
|
@@ -11,7 +11,7 @@ export declare class RichMessage {
|
|
|
11
11
|
get isPart(): boolean;
|
|
12
12
|
/** Photos in this message */
|
|
13
13
|
get photos(): LongMap<Photo>;
|
|
14
|
-
/** Documents (usually videos) in this message */
|
|
14
|
+
/** Documents (usually videos and audios) in this message */
|
|
15
15
|
get documents(): LongMap<ParsedDocument>;
|
|
16
16
|
/** Blocks in this message */
|
|
17
17
|
get blocks(): tl.TypePageBlock[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { LongMap } from "
|
|
2
|
-
import { makeInspectable } from "
|
|
3
|
-
import { memoizeGetters } from "
|
|
4
|
-
import { parseDocument } from "
|
|
5
|
-
import { Photo as Photo$2 } from "
|
|
1
|
+
import { LongMap } from "../../../../utils/long-utils.js";
|
|
2
|
+
import { makeInspectable } from "../../../utils/inspectable.js";
|
|
3
|
+
import { memoizeGetters } from "../../../utils/memoize.js";
|
|
4
|
+
import { parseDocument } from "../../media/document-utils.js";
|
|
5
|
+
import { Photo as Photo$2 } from "../../media/photo.js";
|
|
6
6
|
class RichMessage {
|
|
7
7
|
constructor(raw) {
|
|
8
8
|
this.raw = raw;
|
|
@@ -24,7 +24,7 @@ class RichMessage {
|
|
|
24
24
|
}
|
|
25
25
|
return map;
|
|
26
26
|
}
|
|
27
|
-
/** Documents (usually videos) in this message */
|
|
27
|
+
/** Documents (usually videos and audios) in this message */
|
|
28
28
|
get documents() {
|
|
29
29
|
const map = new LongMap();
|
|
30
30
|
for (const photo of this.raw.documents) {
|
|
@@ -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 {};
|
|
@@ -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 {};
|
|
@@ -15,183 +15,20 @@ const sortedArray = require("../../utils/sorted-array.cjs");
|
|
|
15
15
|
const batchedQueries = require("../methods/chats/batched-queries.cjs");
|
|
16
16
|
const peersIndex = require("../types/peers/peers-index.cjs");
|
|
17
17
|
const peerUtils$1 = require("../utils/peer-utils.cjs");
|
|
18
|
+
const walkPageBlocks = require("../utils/walk-page-blocks.cjs");
|
|
18
19
|
const types = require("./types.cjs");
|
|
19
20
|
const utils$2 = require("./utils.cjs");
|
|
20
21
|
const innerTl = require("../../tl/inner-tl.cjs");
|
|
21
22
|
const WARN_EVERY = 100;
|
|
22
23
|
const KEEP_ALIVE_INTERVAL = 15 * 60 * 1e3;
|
|
23
24
|
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
25
|
function collectRichMessagePeerIds(richMessage, peers) {
|
|
193
26
|
if (!richMessage) return;
|
|
194
|
-
|
|
27
|
+
walkPageBlocks.walkPageBlocks(richMessage.blocks, {
|
|
28
|
+
richText: (text) => {
|
|
29
|
+
if (text._ === "textMentionName") peers.add(text.userId);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
195
32
|
}
|
|
196
33
|
class UpdatesManager {
|
|
197
34
|
constructor(client, params = {}) {
|
|
@@ -1558,6 +1395,7 @@ class UpdatesManager {
|
|
|
1558
1395
|
localPts,
|
|
1559
1396
|
pending.ptsBefore
|
|
1560
1397
|
);
|
|
1398
|
+
postponedTimer.emitBefore(pending.timeout);
|
|
1561
1399
|
} else {
|
|
1562
1400
|
log.debug(
|
|
1563
1401
|
"gap for postponed %s (cid = %d) wasn't filled, fetching diff (current pts %d, need %d)",
|
|
@@ -1635,6 +1473,8 @@ class UpdatesManager {
|
|
|
1635
1473
|
this.qts,
|
|
1636
1474
|
pending.qtsBefore
|
|
1637
1475
|
);
|
|
1476
|
+
pendingQtsUpdatesPostponed.removeIndex(i);
|
|
1477
|
+
i--;
|
|
1638
1478
|
continue;
|
|
1639
1479
|
}
|
|
1640
1480
|
if (this.qts < pending.qtsBefore) {
|
|
@@ -1647,6 +1487,7 @@ class UpdatesManager {
|
|
|
1647
1487
|
this.qts,
|
|
1648
1488
|
pending.qtsBefore
|
|
1649
1489
|
);
|
|
1490
|
+
postponedTimer.emitBefore(pending.timeout);
|
|
1650
1491
|
} else {
|
|
1651
1492
|
log.debug(
|
|
1652
1493
|
"gap for postponed %s wasn't filled, fetching diff (current qts %d, need %d)",
|
|
@@ -8,183 +8,20 @@ import { SortedArray } from "../../utils/sorted-array.js";
|
|
|
8
8
|
import { _getChannelsBatched, _getUsersBatched } from "../methods/chats/batched-queries.js";
|
|
9
9
|
import { PeersIndex } from "../types/peers/peers-index.js";
|
|
10
10
|
import { toInputChannel, isInputPeerChannel, isInputPeerUser, toInputUser } from "../utils/peer-utils.js";
|
|
11
|
+
import { walkPageBlocks } from "../utils/walk-page-blocks.js";
|
|
11
12
|
import { RawUpdateInfo } from "./types.js";
|
|
12
13
|
import { toPendingUpdate, messageToUpdate, isMessageEmpty, createDummyUpdatesContainer, extractChannelIdFromUpdate } from "./utils.js";
|
|
13
14
|
import { RpcError } from "../../tl/inner-tl.js";
|
|
14
15
|
const WARN_EVERY = 100;
|
|
15
16
|
const KEEP_ALIVE_INTERVAL = 15 * 60 * 1e3;
|
|
16
17
|
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
18
|
function collectRichMessagePeerIds(richMessage, peers) {
|
|
186
19
|
if (!richMessage) return;
|
|
187
|
-
|
|
20
|
+
walkPageBlocks(richMessage.blocks, {
|
|
21
|
+
richText: (text) => {
|
|
22
|
+
if (text._ === "textMentionName") peers.add(text.userId);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
188
25
|
}
|
|
189
26
|
class UpdatesManager {
|
|
190
27
|
constructor(client, params = {}) {
|
|
@@ -1551,6 +1388,7 @@ class UpdatesManager {
|
|
|
1551
1388
|
localPts,
|
|
1552
1389
|
pending.ptsBefore
|
|
1553
1390
|
);
|
|
1391
|
+
postponedTimer.emitBefore(pending.timeout);
|
|
1554
1392
|
} else {
|
|
1555
1393
|
log.debug(
|
|
1556
1394
|
"gap for postponed %s (cid = %d) wasn't filled, fetching diff (current pts %d, need %d)",
|
|
@@ -1628,6 +1466,8 @@ class UpdatesManager {
|
|
|
1628
1466
|
this.qts,
|
|
1629
1467
|
pending.qtsBefore
|
|
1630
1468
|
);
|
|
1469
|
+
pendingQtsUpdatesPostponed.removeIndex(i);
|
|
1470
|
+
i--;
|
|
1631
1471
|
continue;
|
|
1632
1472
|
}
|
|
1633
1473
|
if (this.qts < pending.qtsBefore) {
|
|
@@ -1640,6 +1480,7 @@ class UpdatesManager {
|
|
|
1640
1480
|
this.qts,
|
|
1641
1481
|
pending.qtsBefore
|
|
1642
1482
|
);
|
|
1483
|
+
postponedTimer.emitBefore(pending.timeout);
|
|
1643
1484
|
} else {
|
|
1644
1485
|
log.debug(
|
|
1645
1486
|
"gap for postponed %s wasn't filled, fetching diff (current qts %d, need %d)",
|