@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,127 @@
|
|
|
1
|
+
import { tl } from '../../../../tl/index.js';
|
|
2
|
+
import { InputMediaAudio, InputMediaPhoto, InputMediaVideo } from '../../media/index.js';
|
|
3
|
+
import { InputText } from '../../misc/entities.js';
|
|
4
|
+
import { InputPageBlock, InputPageBlockOrFile, InputPageBlockWithFile } from './types.js';
|
|
5
|
+
import { default as Long } from 'long';
|
|
6
|
+
/**
|
|
7
|
+
* Input rich text, accepted by page block factories.
|
|
8
|
+
*
|
|
9
|
+
* Can be either a {@link tl.TypeRichText} (passed as-is), or an {@link InputText}
|
|
10
|
+
* (a plain string or a {@link TextWithEntities}, e.g. from `html`/`md` tagged templates),
|
|
11
|
+
* which is converted to {@link tl.TypeRichText}.
|
|
12
|
+
*/
|
|
13
|
+
export type InputRichText = InputText | tl.TypeRichText;
|
|
14
|
+
/** Input page caption (used by media page blocks) */
|
|
15
|
+
export interface InputPageCaption {
|
|
16
|
+
/** Caption text */
|
|
17
|
+
text?: InputRichText;
|
|
18
|
+
/** Caption credit (e.g. author) */
|
|
19
|
+
credit?: InputRichText;
|
|
20
|
+
}
|
|
21
|
+
type Block<T extends tl.TypePageBlock['_']> = Extract<InputPageBlock, {
|
|
22
|
+
_: T;
|
|
23
|
+
}>;
|
|
24
|
+
type ListItem = Block<'pageBlockList'>['items'][number];
|
|
25
|
+
type OrderedListItem = Block<'pageBlockOrderedList'>['items'][number];
|
|
26
|
+
/** Create a footer block */
|
|
27
|
+
export declare function footer(text: InputRichText): tl.RawPageBlockFooter;
|
|
28
|
+
/** Create a paragraph block */
|
|
29
|
+
export declare function paragraph(text: InputRichText): tl.RawPageBlockParagraph;
|
|
30
|
+
/** Create a "thinking" block */
|
|
31
|
+
export declare function thinking(text: InputRichText): tl.RawPageBlockThinking;
|
|
32
|
+
/** Create a heading block (`<h1>`–`<h6>`, depending on `level`) */
|
|
33
|
+
export declare function heading<Level extends 1 | 2 | 3 | 4 | 5 | 6>(level: Level, text: InputRichText): Extract<tl.TypePageBlock, {
|
|
34
|
+
_: `pageBlockHeading${Level}`;
|
|
35
|
+
}>;
|
|
36
|
+
/** Create a divider (`<hr>`) block */
|
|
37
|
+
export declare function divider(): tl.RawPageBlockDivider;
|
|
38
|
+
/** Create an anchor block, to be referenced by name */
|
|
39
|
+
export declare function anchor(name: string): tl.RawPageBlockAnchor;
|
|
40
|
+
/** Create a TeX math block */
|
|
41
|
+
export declare function math(source: string): tl.RawPageBlockMath;
|
|
42
|
+
/** Create a preformatted (code) block */
|
|
43
|
+
export declare function preformatted(text: InputRichText, language?: string): tl.RawPageBlockPreformatted;
|
|
44
|
+
/**
|
|
45
|
+
* Create a blockquote block.
|
|
46
|
+
*
|
|
47
|
+
* Pass an array of blocks instead of rich text to create a blockquote
|
|
48
|
+
* containing other blocks (`pageBlockBlockquoteBlocks`).
|
|
49
|
+
*/
|
|
50
|
+
export declare function blockquote(content: InputRichText | InputPageBlockOrFile[], caption?: InputRichText): tl.RawPageBlockBlockquote | Block<'pageBlockBlockquoteBlocks'>;
|
|
51
|
+
/** Create a pullquote block */
|
|
52
|
+
export declare function pullquote(text: InputRichText, caption?: InputRichText): tl.RawPageBlockPullquote;
|
|
53
|
+
/** Create a map block */
|
|
54
|
+
export declare function map(params: {
|
|
55
|
+
latitude: number;
|
|
56
|
+
longitude: number;
|
|
57
|
+
zoom: number;
|
|
58
|
+
width: number;
|
|
59
|
+
height: number;
|
|
60
|
+
caption?: InputRichText | InputPageCaption;
|
|
61
|
+
}): tl.RawInputPageBlockMap;
|
|
62
|
+
/** Create a list item (for {@link list}) */
|
|
63
|
+
export declare function listItem(content: InputRichText | InputPageBlockOrFile[], params?: {
|
|
64
|
+
checkbox?: boolean;
|
|
65
|
+
checked?: boolean;
|
|
66
|
+
}): ListItem;
|
|
67
|
+
/** Create an unordered list block */
|
|
68
|
+
export declare function list(items: ListItem[]): Block<'pageBlockList'>;
|
|
69
|
+
/** Create an ordered list item (for {@link orderedList}) */
|
|
70
|
+
export declare function orderedListItem(content: InputRichText | InputPageBlockOrFile[], params?: {
|
|
71
|
+
checkbox?: boolean;
|
|
72
|
+
checked?: boolean;
|
|
73
|
+
num?: string;
|
|
74
|
+
value?: number;
|
|
75
|
+
type?: string;
|
|
76
|
+
}): OrderedListItem;
|
|
77
|
+
/** Create an ordered list block */
|
|
78
|
+
export declare function orderedList(items: OrderedListItem[], params?: {
|
|
79
|
+
reversed?: boolean;
|
|
80
|
+
start?: number;
|
|
81
|
+
type?: string;
|
|
82
|
+
}): Block<'pageBlockOrderedList'>;
|
|
83
|
+
/** Create a table cell (for {@link tableRow}) */
|
|
84
|
+
export declare function tableCell(text?: InputRichText, params?: {
|
|
85
|
+
header?: boolean;
|
|
86
|
+
alignCenter?: boolean;
|
|
87
|
+
alignRight?: boolean;
|
|
88
|
+
valignMiddle?: boolean;
|
|
89
|
+
valignBottom?: boolean;
|
|
90
|
+
colspan?: number;
|
|
91
|
+
rowspan?: number;
|
|
92
|
+
}): tl.RawPageTableCell;
|
|
93
|
+
/** Create a table row (for {@link table}) */
|
|
94
|
+
export declare function tableRow(cells: tl.TypePageTableCell[]): tl.RawPageTableRow;
|
|
95
|
+
/** Create a table block */
|
|
96
|
+
export declare function table(rows: tl.TypePageTableRow[], params?: {
|
|
97
|
+
title?: InputRichText;
|
|
98
|
+
bordered?: boolean;
|
|
99
|
+
striped?: boolean;
|
|
100
|
+
}): tl.RawPageBlockTable;
|
|
101
|
+
/** Create a collage block */
|
|
102
|
+
export declare function collage(items: InputPageBlockOrFile[], caption?: InputRichText | InputPageCaption): Block<'pageBlockCollage'>;
|
|
103
|
+
/** Create a slideshow block */
|
|
104
|
+
export declare function slideshow(items: InputPageBlockOrFile[], caption?: InputRichText | InputPageCaption): Block<'pageBlockSlideshow'>;
|
|
105
|
+
/** Create a collapsible details block */
|
|
106
|
+
export declare function details(title: InputRichText, blocks: InputPageBlockOrFile[], params?: {
|
|
107
|
+
open?: boolean;
|
|
108
|
+
}): Block<'pageBlockDetails'>;
|
|
109
|
+
/** Create a photo block, uploading the given file */
|
|
110
|
+
export declare function photo(file: string | tl.TypeInputPhoto | InputMediaPhoto, params?: {
|
|
111
|
+
caption?: InputRichText | InputPageCaption;
|
|
112
|
+
url?: string;
|
|
113
|
+
webpageId?: Long;
|
|
114
|
+
spoiler?: boolean;
|
|
115
|
+
}): InputPageBlockWithFile;
|
|
116
|
+
/** Create a video block, uploading the given file */
|
|
117
|
+
export declare function video(file: string | tl.TypeInputDocument | InputMediaVideo, params?: {
|
|
118
|
+
caption?: InputRichText | InputPageCaption;
|
|
119
|
+
autoplay?: boolean;
|
|
120
|
+
loop?: boolean;
|
|
121
|
+
spoiler?: boolean;
|
|
122
|
+
}): InputPageBlockWithFile;
|
|
123
|
+
/** Create an audio block, uploading the given file */
|
|
124
|
+
export declare function audio(file: string | tl.TypeInputDocument | InputMediaAudio, params?: {
|
|
125
|
+
caption?: InputRichText | InputPageCaption;
|
|
126
|
+
}): InputPageBlockWithFile;
|
|
127
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { tl } from '../../../../tl/index.js';
|
|
2
|
+
import { InputMediaAudio, InputMediaPhoto, InputMediaVideo } from '../../media/index.js';
|
|
3
|
+
import { InputText } from '../../misc/entities.js';
|
|
4
|
+
import { InputPageBlock, InputPageBlockOrFile, InputPageBlockWithFile } from './types.js';
|
|
5
|
+
import { default as Long } from 'long';
|
|
6
|
+
/**
|
|
7
|
+
* Input rich text, accepted by page block factories.
|
|
8
|
+
*
|
|
9
|
+
* Can be either a {@link tl.TypeRichText} (passed as-is), or an {@link InputText}
|
|
10
|
+
* (a plain string or a {@link TextWithEntities}, e.g. from `html`/`md` tagged templates),
|
|
11
|
+
* which is converted to {@link tl.TypeRichText}.
|
|
12
|
+
*/
|
|
13
|
+
export type InputRichText = InputText | tl.TypeRichText;
|
|
14
|
+
/** Input page caption (used by media page blocks) */
|
|
15
|
+
export interface InputPageCaption {
|
|
16
|
+
/** Caption text */
|
|
17
|
+
text?: InputRichText;
|
|
18
|
+
/** Caption credit (e.g. author) */
|
|
19
|
+
credit?: InputRichText;
|
|
20
|
+
}
|
|
21
|
+
type Block<T extends tl.TypePageBlock['_']> = Extract<InputPageBlock, {
|
|
22
|
+
_: T;
|
|
23
|
+
}>;
|
|
24
|
+
type ListItem = Block<'pageBlockList'>['items'][number];
|
|
25
|
+
type OrderedListItem = Block<'pageBlockOrderedList'>['items'][number];
|
|
26
|
+
/** Create a footer block */
|
|
27
|
+
export declare function footer(text: InputRichText): tl.RawPageBlockFooter;
|
|
28
|
+
/** Create a paragraph block */
|
|
29
|
+
export declare function paragraph(text: InputRichText): tl.RawPageBlockParagraph;
|
|
30
|
+
/** Create a "thinking" block */
|
|
31
|
+
export declare function thinking(text: InputRichText): tl.RawPageBlockThinking;
|
|
32
|
+
/** Create a heading block (`<h1>`–`<h6>`, depending on `level`) */
|
|
33
|
+
export declare function heading<Level extends 1 | 2 | 3 | 4 | 5 | 6>(level: Level, text: InputRichText): Extract<tl.TypePageBlock, {
|
|
34
|
+
_: `pageBlockHeading${Level}`;
|
|
35
|
+
}>;
|
|
36
|
+
/** Create a divider (`<hr>`) block */
|
|
37
|
+
export declare function divider(): tl.RawPageBlockDivider;
|
|
38
|
+
/** Create an anchor block, to be referenced by name */
|
|
39
|
+
export declare function anchor(name: string): tl.RawPageBlockAnchor;
|
|
40
|
+
/** Create a TeX math block */
|
|
41
|
+
export declare function math(source: string): tl.RawPageBlockMath;
|
|
42
|
+
/** Create a preformatted (code) block */
|
|
43
|
+
export declare function preformatted(text: InputRichText, language?: string): tl.RawPageBlockPreformatted;
|
|
44
|
+
/**
|
|
45
|
+
* Create a blockquote block.
|
|
46
|
+
*
|
|
47
|
+
* Pass an array of blocks instead of rich text to create a blockquote
|
|
48
|
+
* containing other blocks (`pageBlockBlockquoteBlocks`).
|
|
49
|
+
*/
|
|
50
|
+
export declare function blockquote(content: InputRichText | InputPageBlockOrFile[], caption?: InputRichText): tl.RawPageBlockBlockquote | Block<'pageBlockBlockquoteBlocks'>;
|
|
51
|
+
/** Create a pullquote block */
|
|
52
|
+
export declare function pullquote(text: InputRichText, caption?: InputRichText): tl.RawPageBlockPullquote;
|
|
53
|
+
/** Create a map block */
|
|
54
|
+
export declare function map(params: {
|
|
55
|
+
latitude: number;
|
|
56
|
+
longitude: number;
|
|
57
|
+
zoom: number;
|
|
58
|
+
width: number;
|
|
59
|
+
height: number;
|
|
60
|
+
caption?: InputRichText | InputPageCaption;
|
|
61
|
+
}): tl.RawInputPageBlockMap;
|
|
62
|
+
/** Create a list item (for {@link list}) */
|
|
63
|
+
export declare function listItem(content: InputRichText | InputPageBlockOrFile[], params?: {
|
|
64
|
+
checkbox?: boolean;
|
|
65
|
+
checked?: boolean;
|
|
66
|
+
}): ListItem;
|
|
67
|
+
/** Create an unordered list block */
|
|
68
|
+
export declare function list(items: ListItem[]): Block<'pageBlockList'>;
|
|
69
|
+
/** Create an ordered list item (for {@link orderedList}) */
|
|
70
|
+
export declare function orderedListItem(content: InputRichText | InputPageBlockOrFile[], params?: {
|
|
71
|
+
checkbox?: boolean;
|
|
72
|
+
checked?: boolean;
|
|
73
|
+
num?: string;
|
|
74
|
+
value?: number;
|
|
75
|
+
type?: string;
|
|
76
|
+
}): OrderedListItem;
|
|
77
|
+
/** Create an ordered list block */
|
|
78
|
+
export declare function orderedList(items: OrderedListItem[], params?: {
|
|
79
|
+
reversed?: boolean;
|
|
80
|
+
start?: number;
|
|
81
|
+
type?: string;
|
|
82
|
+
}): Block<'pageBlockOrderedList'>;
|
|
83
|
+
/** Create a table cell (for {@link tableRow}) */
|
|
84
|
+
export declare function tableCell(text?: InputRichText, params?: {
|
|
85
|
+
header?: boolean;
|
|
86
|
+
alignCenter?: boolean;
|
|
87
|
+
alignRight?: boolean;
|
|
88
|
+
valignMiddle?: boolean;
|
|
89
|
+
valignBottom?: boolean;
|
|
90
|
+
colspan?: number;
|
|
91
|
+
rowspan?: number;
|
|
92
|
+
}): tl.RawPageTableCell;
|
|
93
|
+
/** Create a table row (for {@link table}) */
|
|
94
|
+
export declare function tableRow(cells: tl.TypePageTableCell[]): tl.RawPageTableRow;
|
|
95
|
+
/** Create a table block */
|
|
96
|
+
export declare function table(rows: tl.TypePageTableRow[], params?: {
|
|
97
|
+
title?: InputRichText;
|
|
98
|
+
bordered?: boolean;
|
|
99
|
+
striped?: boolean;
|
|
100
|
+
}): tl.RawPageBlockTable;
|
|
101
|
+
/** Create a collage block */
|
|
102
|
+
export declare function collage(items: InputPageBlockOrFile[], caption?: InputRichText | InputPageCaption): Block<'pageBlockCollage'>;
|
|
103
|
+
/** Create a slideshow block */
|
|
104
|
+
export declare function slideshow(items: InputPageBlockOrFile[], caption?: InputRichText | InputPageCaption): Block<'pageBlockSlideshow'>;
|
|
105
|
+
/** Create a collapsible details block */
|
|
106
|
+
export declare function details(title: InputRichText, blocks: InputPageBlockOrFile[], params?: {
|
|
107
|
+
open?: boolean;
|
|
108
|
+
}): Block<'pageBlockDetails'>;
|
|
109
|
+
/** Create a photo block, uploading the given file */
|
|
110
|
+
export declare function photo(file: string | tl.TypeInputPhoto | InputMediaPhoto, params?: {
|
|
111
|
+
caption?: InputRichText | InputPageCaption;
|
|
112
|
+
url?: string;
|
|
113
|
+
webpageId?: Long;
|
|
114
|
+
spoiler?: boolean;
|
|
115
|
+
}): InputPageBlockWithFile;
|
|
116
|
+
/** Create a video block, uploading the given file */
|
|
117
|
+
export declare function video(file: string | tl.TypeInputDocument | InputMediaVideo, params?: {
|
|
118
|
+
caption?: InputRichText | InputPageCaption;
|
|
119
|
+
autoplay?: boolean;
|
|
120
|
+
loop?: boolean;
|
|
121
|
+
spoiler?: boolean;
|
|
122
|
+
}): InputPageBlockWithFile;
|
|
123
|
+
/** Create an audio block, uploading the given file */
|
|
124
|
+
export declare function audio(file: string | tl.TypeInputDocument | InputMediaAudio, params?: {
|
|
125
|
+
caption?: InputRichText | InputPageCaption;
|
|
126
|
+
}): InputPageBlockWithFile;
|
|
127
|
+
export {};
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import Long from "long";
|
|
2
|
+
import { textWithEntitiesToRichText } from "../../../utils/entities.js";
|
|
3
|
+
const RICH_EMPTY = { _: "textEmpty" };
|
|
4
|
+
function normalizeRichText(text) {
|
|
5
|
+
if (typeof text === "string") return { _: "textPlain", text };
|
|
6
|
+
if ("_" in text) return text;
|
|
7
|
+
return textWithEntitiesToRichText(text);
|
|
8
|
+
}
|
|
9
|
+
function normalizeCaption(input) {
|
|
10
|
+
if (input == null) return { _: "pageCaption", text: RICH_EMPTY, credit: RICH_EMPTY };
|
|
11
|
+
if (typeof input === "string" || "_" in input || "entities" in input) {
|
|
12
|
+
return { _: "pageCaption", text: normalizeRichText(input), credit: RICH_EMPTY };
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
_: "pageCaption",
|
|
16
|
+
text: input.text != null ? normalizeRichText(input.text) : RICH_EMPTY,
|
|
17
|
+
credit: "credit" in input && input.credit != null ? normalizeRichText(input.credit) : RICH_EMPTY
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function footer(text) {
|
|
21
|
+
return { _: "pageBlockFooter", text: normalizeRichText(text) };
|
|
22
|
+
}
|
|
23
|
+
function paragraph(text) {
|
|
24
|
+
return { _: "pageBlockParagraph", text: normalizeRichText(text) };
|
|
25
|
+
}
|
|
26
|
+
function thinking(text) {
|
|
27
|
+
return { _: "pageBlockThinking", text: normalizeRichText(text) };
|
|
28
|
+
}
|
|
29
|
+
function heading(level, text) {
|
|
30
|
+
return { _: `pageBlockHeading${level}`, text: normalizeRichText(text) };
|
|
31
|
+
}
|
|
32
|
+
function divider() {
|
|
33
|
+
return { _: "pageBlockDivider" };
|
|
34
|
+
}
|
|
35
|
+
function anchor(name) {
|
|
36
|
+
return { _: "pageBlockAnchor", name };
|
|
37
|
+
}
|
|
38
|
+
function math(source) {
|
|
39
|
+
return { _: "pageBlockMath", source };
|
|
40
|
+
}
|
|
41
|
+
function preformatted(text, language = "") {
|
|
42
|
+
return { _: "pageBlockPreformatted", text: normalizeRichText(text), language };
|
|
43
|
+
}
|
|
44
|
+
function blockquote(content, caption) {
|
|
45
|
+
const normalizedCaption = caption != null ? normalizeRichText(caption) : RICH_EMPTY;
|
|
46
|
+
if (Array.isArray(content)) {
|
|
47
|
+
return { _: "pageBlockBlockquoteBlocks", blocks: content, caption: normalizedCaption };
|
|
48
|
+
}
|
|
49
|
+
return { _: "pageBlockBlockquote", text: normalizeRichText(content), caption: normalizedCaption };
|
|
50
|
+
}
|
|
51
|
+
function pullquote(text, caption) {
|
|
52
|
+
return {
|
|
53
|
+
_: "pageBlockPullquote",
|
|
54
|
+
text: normalizeRichText(text),
|
|
55
|
+
caption: caption != null ? normalizeRichText(caption) : RICH_EMPTY
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function map(params) {
|
|
59
|
+
return {
|
|
60
|
+
_: "inputPageBlockMap",
|
|
61
|
+
geo: { _: "inputGeoPoint", lat: params.latitude, long: params.longitude },
|
|
62
|
+
zoom: params.zoom,
|
|
63
|
+
w: params.width,
|
|
64
|
+
h: params.height,
|
|
65
|
+
caption: normalizeCaption(params.caption)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function listItem(content, params = {}) {
|
|
69
|
+
if (Array.isArray(content)) {
|
|
70
|
+
return {
|
|
71
|
+
_: "pageListItemBlocks",
|
|
72
|
+
blocks: content,
|
|
73
|
+
checkbox: params.checkbox,
|
|
74
|
+
checked: params.checked
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
_: "pageListItemText",
|
|
79
|
+
text: normalizeRichText(content),
|
|
80
|
+
checkbox: params.checkbox,
|
|
81
|
+
checked: params.checked
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function list(items) {
|
|
85
|
+
return { _: "pageBlockList", items };
|
|
86
|
+
}
|
|
87
|
+
function orderedListItem(content, params = {}) {
|
|
88
|
+
if (Array.isArray(content)) {
|
|
89
|
+
return {
|
|
90
|
+
_: "pageListOrderedItemBlocks",
|
|
91
|
+
blocks: content,
|
|
92
|
+
checkbox: params.checkbox,
|
|
93
|
+
checked: params.checked,
|
|
94
|
+
num: params.num,
|
|
95
|
+
value: params.value,
|
|
96
|
+
type: params.type
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
_: "pageListOrderedItemText",
|
|
101
|
+
text: normalizeRichText(content),
|
|
102
|
+
checkbox: params.checkbox,
|
|
103
|
+
checked: params.checked,
|
|
104
|
+
num: params.num,
|
|
105
|
+
value: params.value,
|
|
106
|
+
type: params.type
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function orderedList(items, params = {}) {
|
|
110
|
+
return {
|
|
111
|
+
_: "pageBlockOrderedList",
|
|
112
|
+
items,
|
|
113
|
+
reversed: params.reversed,
|
|
114
|
+
start: params.start,
|
|
115
|
+
type: params.type
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function tableCell(text, params = {}) {
|
|
119
|
+
return {
|
|
120
|
+
_: "pageTableCell",
|
|
121
|
+
text: text != null ? normalizeRichText(text) : void 0,
|
|
122
|
+
header: params.header,
|
|
123
|
+
alignCenter: params.alignCenter,
|
|
124
|
+
alignRight: params.alignRight,
|
|
125
|
+
valignMiddle: params.valignMiddle,
|
|
126
|
+
valignBottom: params.valignBottom,
|
|
127
|
+
colspan: params.colspan,
|
|
128
|
+
rowspan: params.rowspan
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function tableRow(cells) {
|
|
132
|
+
return { _: "pageTableRow", cells };
|
|
133
|
+
}
|
|
134
|
+
function table(rows, params = {}) {
|
|
135
|
+
return {
|
|
136
|
+
_: "pageBlockTable",
|
|
137
|
+
title: params.title != null ? normalizeRichText(params.title) : RICH_EMPTY,
|
|
138
|
+
rows,
|
|
139
|
+
bordered: params.bordered,
|
|
140
|
+
striped: params.striped
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function collage(items, caption) {
|
|
144
|
+
return { _: "pageBlockCollage", items, caption: normalizeCaption(caption) };
|
|
145
|
+
}
|
|
146
|
+
function slideshow(items, caption) {
|
|
147
|
+
return { _: "pageBlockSlideshow", items, caption: normalizeCaption(caption) };
|
|
148
|
+
}
|
|
149
|
+
function details(title, blocks, params = {}) {
|
|
150
|
+
return { _: "pageBlockDetails", blocks, title: normalizeRichText(title), open: params.open };
|
|
151
|
+
}
|
|
152
|
+
function photo(file, params = {}) {
|
|
153
|
+
return {
|
|
154
|
+
// the default `auto` mode would upload it as a document, but we already know it should be a photo
|
|
155
|
+
file: typeof file === "string" ? { type: "photo", file } : file,
|
|
156
|
+
block: {
|
|
157
|
+
_: "pageBlockPhoto",
|
|
158
|
+
photoId: Long.ZERO,
|
|
159
|
+
caption: normalizeCaption(params.caption),
|
|
160
|
+
url: params.url,
|
|
161
|
+
webpageId: params.webpageId,
|
|
162
|
+
spoiler: params.spoiler
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function video(file, params = {}) {
|
|
167
|
+
return {
|
|
168
|
+
file,
|
|
169
|
+
block: {
|
|
170
|
+
_: "pageBlockVideo",
|
|
171
|
+
videoId: Long.ZERO,
|
|
172
|
+
caption: normalizeCaption(params.caption),
|
|
173
|
+
autoplay: params.autoplay,
|
|
174
|
+
loop: params.loop,
|
|
175
|
+
spoiler: params.spoiler
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function audio(file, params = {}) {
|
|
180
|
+
return {
|
|
181
|
+
file,
|
|
182
|
+
block: {
|
|
183
|
+
_: "pageBlockAudio",
|
|
184
|
+
audioId: Long.ZERO,
|
|
185
|
+
caption: normalizeCaption(params.caption)
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
export {
|
|
190
|
+
anchor,
|
|
191
|
+
audio,
|
|
192
|
+
blockquote,
|
|
193
|
+
collage,
|
|
194
|
+
details,
|
|
195
|
+
divider,
|
|
196
|
+
footer,
|
|
197
|
+
heading,
|
|
198
|
+
list,
|
|
199
|
+
listItem,
|
|
200
|
+
map,
|
|
201
|
+
math,
|
|
202
|
+
orderedList,
|
|
203
|
+
orderedListItem,
|
|
204
|
+
paragraph,
|
|
205
|
+
photo,
|
|
206
|
+
preformatted,
|
|
207
|
+
pullquote,
|
|
208
|
+
slideshow,
|
|
209
|
+
table,
|
|
210
|
+
tableCell,
|
|
211
|
+
tableRow,
|
|
212
|
+
thinking,
|
|
213
|
+
video
|
|
214
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
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 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
|
+
class RichMessage {
|
|
14
|
+
constructor(raw) {
|
|
15
|
+
this.raw = raw;
|
|
16
|
+
}
|
|
17
|
+
/** Whether this message is RTL */
|
|
18
|
+
get isRtl() {
|
|
19
|
+
return this.raw.rtl;
|
|
20
|
+
}
|
|
21
|
+
/** Whether this message is partial */
|
|
22
|
+
get isPart() {
|
|
23
|
+
return this.raw.part;
|
|
24
|
+
}
|
|
25
|
+
/** Photos in this message */
|
|
26
|
+
get photos() {
|
|
27
|
+
const map = new longUtils.LongMap();
|
|
28
|
+
for (const photo$1 of this.raw.photos) {
|
|
29
|
+
if (photo$1._ === "photoEmpty") continue;
|
|
30
|
+
map.set(photo$1.id, new photo.Photo(photo$1));
|
|
31
|
+
}
|
|
32
|
+
return map;
|
|
33
|
+
}
|
|
34
|
+
/** Documents (usually videos and audios) in this message */
|
|
35
|
+
get documents() {
|
|
36
|
+
const map = new longUtils.LongMap();
|
|
37
|
+
for (const photo2 of this.raw.documents) {
|
|
38
|
+
if (photo2._ === "documentEmpty") continue;
|
|
39
|
+
map.set(photo2.id, documentUtils.parseDocument(photo2));
|
|
40
|
+
}
|
|
41
|
+
return map;
|
|
42
|
+
}
|
|
43
|
+
/** Blocks in this message */
|
|
44
|
+
get blocks() {
|
|
45
|
+
return this.raw.blocks;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const RichMessage$1 = /* @__PURE__ */ inspectable.makeInspectable(RichMessage);
|
|
49
|
+
const RichMessage$2 = /* @__PURE__ */ memoize.memoizeGetters(RichMessage$1, ["documents", "blocks"]);
|
|
50
|
+
exports.RichMessage = RichMessage$2;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
export declare class RichMessage {
|
|
6
|
+
readonly raw: tl.TypeRichMessage;
|
|
7
|
+
constructor(raw: tl.TypeRichMessage);
|
|
8
|
+
/** Whether this message is RTL */
|
|
9
|
+
get isRtl(): boolean;
|
|
10
|
+
/** Whether this message is partial */
|
|
11
|
+
get isPart(): boolean;
|
|
12
|
+
/** Photos in this message */
|
|
13
|
+
get photos(): LongMap<Photo>;
|
|
14
|
+
/** Documents (usually videos and audios) in this message */
|
|
15
|
+
get documents(): LongMap<ParsedDocument>;
|
|
16
|
+
/** Blocks in this message */
|
|
17
|
+
get blocks(): tl.TypePageBlock[];
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
export declare class RichMessage {
|
|
6
|
+
readonly raw: tl.TypeRichMessage;
|
|
7
|
+
constructor(raw: tl.TypeRichMessage);
|
|
8
|
+
/** Whether this message is RTL */
|
|
9
|
+
get isRtl(): boolean;
|
|
10
|
+
/** Whether this message is partial */
|
|
11
|
+
get isPart(): boolean;
|
|
12
|
+
/** Photos in this message */
|
|
13
|
+
get photos(): LongMap<Photo>;
|
|
14
|
+
/** Documents (usually videos and audios) in this message */
|
|
15
|
+
get documents(): LongMap<ParsedDocument>;
|
|
16
|
+
/** Blocks in this message */
|
|
17
|
+
get blocks(): tl.TypePageBlock[];
|
|
18
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
class RichMessage {
|
|
7
|
+
constructor(raw) {
|
|
8
|
+
this.raw = raw;
|
|
9
|
+
}
|
|
10
|
+
/** Whether this message is RTL */
|
|
11
|
+
get isRtl() {
|
|
12
|
+
return this.raw.rtl;
|
|
13
|
+
}
|
|
14
|
+
/** Whether this message is partial */
|
|
15
|
+
get isPart() {
|
|
16
|
+
return this.raw.part;
|
|
17
|
+
}
|
|
18
|
+
/** Photos in this message */
|
|
19
|
+
get photos() {
|
|
20
|
+
const map = new LongMap();
|
|
21
|
+
for (const photo of this.raw.photos) {
|
|
22
|
+
if (photo._ === "photoEmpty") continue;
|
|
23
|
+
map.set(photo.id, new Photo$2(photo));
|
|
24
|
+
}
|
|
25
|
+
return map;
|
|
26
|
+
}
|
|
27
|
+
/** Documents (usually videos and audios) in this message */
|
|
28
|
+
get documents() {
|
|
29
|
+
const map = new LongMap();
|
|
30
|
+
for (const photo of this.raw.documents) {
|
|
31
|
+
if (photo._ === "documentEmpty") continue;
|
|
32
|
+
map.set(photo.id, parseDocument(photo));
|
|
33
|
+
}
|
|
34
|
+
return map;
|
|
35
|
+
}
|
|
36
|
+
/** Blocks in this message */
|
|
37
|
+
get blocks() {
|
|
38
|
+
return this.raw.blocks;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const RichMessage$1 = /* @__PURE__ */ makeInspectable(RichMessage);
|
|
42
|
+
const RichMessage$2 = /* @__PURE__ */ memoizeGetters(RichMessage$1, ["documents", "blocks"]);
|
|
43
|
+
export {
|
|
44
|
+
RichMessage$2 as RichMessage
|
|
45
|
+
};
|
|
@@ -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 {};
|