@mtcute/core 0.30.0 → 0.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.cjs +8 -0
- package/client.js +8 -0
- package/highlevel/client.d.cts +63 -1
- package/highlevel/client.d.ts +63 -1
- package/highlevel/methods/files/normalize-input-media.cjs +8 -0
- package/highlevel/methods/files/normalize-input-media.js +9 -1
- package/highlevel/methods/messages/create-rich-streaming-draft.cjs +39 -0
- package/highlevel/methods/messages/create-rich-streaming-draft.d.cts +42 -0
- package/highlevel/methods/messages/create-rich-streaming-draft.d.ts +42 -0
- package/highlevel/methods/messages/create-rich-streaming-draft.js +34 -0
- package/highlevel/methods/messages/normalize-rich-message.cjs +157 -0
- package/highlevel/methods/messages/normalize-rich-message.d.cts +10 -0
- package/highlevel/methods/messages/normalize-rich-message.d.ts +10 -0
- package/highlevel/methods/messages/normalize-rich-message.js +152 -0
- package/highlevel/methods/messages/send-rich-message.cjs +49 -0
- package/highlevel/methods/messages/send-rich-message.d.cts +38 -0
- package/highlevel/methods/messages/send-rich-message.d.ts +38 -0
- package/highlevel/methods/messages/send-rich-message.js +44 -0
- package/highlevel/methods.d.cts +3 -0
- package/highlevel/methods.d.ts +3 -0
- package/highlevel/types/bots/inline-message/factories.cjs +14 -0
- package/highlevel/types/bots/inline-message/factories.d.cts +9 -1
- package/highlevel/types/bots/inline-message/factories.d.ts +9 -1
- package/highlevel/types/bots/inline-message/factories.js +14 -0
- package/highlevel/types/bots/inline-message/types.d.cts +17 -1
- package/highlevel/types/bots/inline-message/types.d.ts +17 -1
- package/highlevel/types/media/input-media/types.d.cts +1 -1
- package/highlevel/types/media/input-media/types.d.ts +1 -1
- package/highlevel/types/messages/index.d.cts +1 -1
- package/highlevel/types/messages/index.d.ts +1 -1
- package/highlevel/types/messages/message.cjs +1 -1
- package/highlevel/types/messages/message.d.cts +1 -1
- package/highlevel/types/messages/message.d.ts +1 -1
- package/highlevel/types/messages/message.js +1 -1
- package/highlevel/types/messages/rich/index.d.cts +4 -0
- package/highlevel/types/messages/rich/index.d.ts +4 -0
- package/highlevel/types/messages/rich/inner.cjs +219 -0
- package/highlevel/types/messages/rich/inner.d.cts +127 -0
- package/highlevel/types/messages/rich/inner.d.ts +127 -0
- package/highlevel/types/messages/rich/inner.js +214 -0
- package/highlevel/types/messages/{rich-message.cjs → rich/rich-message.cjs} +6 -6
- package/highlevel/types/messages/{rich-message.d.cts → rich/rich-message.d.cts} +5 -5
- package/highlevel/types/messages/{rich-message.d.ts → rich/rich-message.d.ts} +5 -5
- package/highlevel/types/messages/{rich-message.js → rich/rich-message.js} +6 -6
- package/highlevel/types/messages/rich/types.d.cts +76 -0
- package/highlevel/types/messages/rich/types.d.ts +76 -0
- package/highlevel/updates/manager.cjs +4 -0
- package/highlevel/updates/manager.js +4 -0
- package/highlevel/utils/entities.cjs +176 -0
- package/highlevel/utils/entities.d.cts +18 -0
- package/highlevel/utils/entities.d.ts +18 -0
- package/highlevel/utils/entities.js +177 -1
- package/index.cjs +3 -1
- package/index.js +3 -1
- package/methods.cjs +4 -0
- package/methods.js +4 -0
- package/network/mtproxy/_fake-tls.cjs +169 -107
- package/network/mtproxy/_fake-tls.js +169 -107
- package/network/mtproxy/_fake-tls.test.d.cts +1 -0
- package/network/mtproxy/_fake-tls.test.d.ts +1 -0
- package/network/network-manager.cjs +1 -1
- package/network/network-manager.js +1 -1
- package/package.json +1 -1
- package/tl/api-schema.json +1 -1
- package/tl/binary/reader.cjs +115 -109
- package/tl/binary/reader.js +115 -109
- package/tl/binary/writer.cjs +243 -245
- package/tl/binary/writer.js +243 -245
- package/tl/index.d.cts +227 -216
- package/tl/index.d.ts +227 -216
- package/tl/inner-tl.cjs +3 -1
- package/tl/inner-tl.js +3 -1
- package/types/utils.d.cts +4 -0
- package/types/utils.d.ts +4 -0
- package/utils.cjs +2 -0
- package/utils.js +3 -1
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { parallelMap } from "@fuman/utils";
|
|
2
|
+
import { MtArgumentError, MtTypeAssertionError } from "../../../types/errors.js";
|
|
3
|
+
import { assertTypeIs } from "../../../utils/type-assertions.js";
|
|
4
|
+
import { _normalizeInputMedia } from "../files/normalize-input-media.js";
|
|
5
|
+
function _richMediaCacheKey(media) {
|
|
6
|
+
if (typeof media === "string") return `auto:${media}`;
|
|
7
|
+
if ("_" in media) return void 0;
|
|
8
|
+
if (typeof media.file === "string") return `${media.type}:${media.file}`;
|
|
9
|
+
return media;
|
|
10
|
+
}
|
|
11
|
+
async function _uploadRichMedia(client, peer, id, media, params) {
|
|
12
|
+
const cacheKey = params.uploadCache != null ? _richMediaCacheKey(media) : void 0;
|
|
13
|
+
if (cacheKey !== void 0) {
|
|
14
|
+
const cached = params.uploadCache.get(cacheKey);
|
|
15
|
+
if (cached != null) return cached;
|
|
16
|
+
}
|
|
17
|
+
const input = typeof media === "string" ? { type: "auto", file: media } : media;
|
|
18
|
+
const normalized = await _normalizeInputMedia(client, input, {
|
|
19
|
+
uploadPeer: peer,
|
|
20
|
+
abortSignal: params.abortSignal,
|
|
21
|
+
progressCallback: params.progressCallback?.bind(null, id)
|
|
22
|
+
}, true);
|
|
23
|
+
if (normalized._ !== "inputMediaPhoto" && normalized._ !== "inputMediaDocument") {
|
|
24
|
+
throw new MtTypeAssertionError("sendRichMessage (upload)", "inputMediaDocument | inputMediaPhoto", normalized._);
|
|
25
|
+
}
|
|
26
|
+
if (cacheKey !== void 0) params.uploadCache.set(cacheKey, normalized);
|
|
27
|
+
return normalized;
|
|
28
|
+
}
|
|
29
|
+
async function _normalizeInputRichMessage(client, peer, input, params) {
|
|
30
|
+
if ("_" in input) return input;
|
|
31
|
+
if (input.type !== "blocks") {
|
|
32
|
+
let richFiles;
|
|
33
|
+
if (input.attachments) {
|
|
34
|
+
const medias = [...Object.entries(input.attachments)];
|
|
35
|
+
const normalized = await parallelMap(
|
|
36
|
+
medias,
|
|
37
|
+
async ([id, media]) => [id, await _uploadRichMedia(client, peer, id, media, params)],
|
|
38
|
+
{ limit: 4, signal: params.abortSignal }
|
|
39
|
+
);
|
|
40
|
+
richFiles = normalized.map(
|
|
41
|
+
([id, media]) => media._ === "inputMediaDocument" ? { _: "inputRichFileDocument", id, document: media.id } : { _: "inputRichFilePhoto", id, photo: media.id }
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return input.type === "markdown" ? {
|
|
45
|
+
_: "inputRichMessageMarkdown",
|
|
46
|
+
rtl: input.rtl,
|
|
47
|
+
noautolink: input.skipEntityDetection,
|
|
48
|
+
files: richFiles,
|
|
49
|
+
markdown: input.content
|
|
50
|
+
} : {
|
|
51
|
+
_: "inputRichMessageHTML",
|
|
52
|
+
rtl: input.rtl,
|
|
53
|
+
noautolink: input.skipEntityDetection,
|
|
54
|
+
files: richFiles,
|
|
55
|
+
html: input.content
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const photos = [];
|
|
59
|
+
const documents = [];
|
|
60
|
+
const fileBlocks = [];
|
|
61
|
+
function processBlock(node) {
|
|
62
|
+
if ("file" in node) {
|
|
63
|
+
const block = processBlock(node.block);
|
|
64
|
+
fileBlocks.push({ block, media: node.file });
|
|
65
|
+
return block;
|
|
66
|
+
}
|
|
67
|
+
switch (node._) {
|
|
68
|
+
case "pageBlockCover":
|
|
69
|
+
return { ...node, cover: processBlock(node.cover) };
|
|
70
|
+
case "pageBlockCollage":
|
|
71
|
+
case "pageBlockSlideshow":
|
|
72
|
+
return { ...node, items: node.items.map(processBlock) };
|
|
73
|
+
case "pageBlockDetails":
|
|
74
|
+
case "pageBlockEmbedPost":
|
|
75
|
+
case "pageBlockBlockquoteBlocks":
|
|
76
|
+
return { ...node, blocks: node.blocks.map(processBlock) };
|
|
77
|
+
case "pageBlockList":
|
|
78
|
+
return {
|
|
79
|
+
...node,
|
|
80
|
+
items: node.items.map(
|
|
81
|
+
(item) => item._ === "pageListItemBlocks" ? {
|
|
82
|
+
...item,
|
|
83
|
+
blocks: item.blocks.map(processBlock)
|
|
84
|
+
} : item
|
|
85
|
+
)
|
|
86
|
+
};
|
|
87
|
+
case "pageBlockOrderedList":
|
|
88
|
+
return {
|
|
89
|
+
...node,
|
|
90
|
+
items: node.items.map(
|
|
91
|
+
(item) => item._ === "pageListOrderedItemBlocks" ? { ...item, blocks: item.blocks.map(processBlock) } : item
|
|
92
|
+
)
|
|
93
|
+
};
|
|
94
|
+
default:
|
|
95
|
+
return node;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const blocks = input.blocks.map(processBlock);
|
|
99
|
+
const uploaded = await parallelMap(
|
|
100
|
+
fileBlocks,
|
|
101
|
+
async ({ block, media }, idx) => {
|
|
102
|
+
const uploaded2 = await _uploadRichMedia(client, peer, `block-${idx}`, media, params);
|
|
103
|
+
return { block, media: uploaded2 };
|
|
104
|
+
},
|
|
105
|
+
{ limit: 4, signal: params.abortSignal }
|
|
106
|
+
);
|
|
107
|
+
for (const { block, media } of uploaded) {
|
|
108
|
+
if (media._ === "inputMediaPhoto") {
|
|
109
|
+
const photo = media.id;
|
|
110
|
+
assertTypeIs("sendRichMessage (upload)", photo, "inputPhoto");
|
|
111
|
+
photos.push(photo);
|
|
112
|
+
switch (block._) {
|
|
113
|
+
case "pageBlockPhoto":
|
|
114
|
+
block.photoId = photo.id;
|
|
115
|
+
break;
|
|
116
|
+
case "pageBlockEmbed":
|
|
117
|
+
block.posterPhotoId = photo.id;
|
|
118
|
+
break;
|
|
119
|
+
case "pageBlockEmbedPost":
|
|
120
|
+
block.authorPhotoId = photo.id;
|
|
121
|
+
break;
|
|
122
|
+
default:
|
|
123
|
+
throw new MtArgumentError(`sendRichMessage: expected photo ${photo.id} to be used in a photo block, but got ${block._}`);
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
const document = media.id;
|
|
127
|
+
assertTypeIs("sendRichMessage (upload)", document, "inputDocument");
|
|
128
|
+
documents.push(document);
|
|
129
|
+
switch (block._) {
|
|
130
|
+
case "pageBlockVideo":
|
|
131
|
+
block.videoId = document.id;
|
|
132
|
+
break;
|
|
133
|
+
case "pageBlockAudio":
|
|
134
|
+
block.audioId = document.id;
|
|
135
|
+
break;
|
|
136
|
+
default:
|
|
137
|
+
throw new MtArgumentError(`sendRichMessage: expected document ${document.id} to be used in a document block, but got ${block._}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
_: "inputRichMessage",
|
|
143
|
+
rtl: input.rtl,
|
|
144
|
+
noautolink: input.skipEntityDetection,
|
|
145
|
+
blocks,
|
|
146
|
+
photos: photos.length ? photos : void 0,
|
|
147
|
+
documents: documents.length ? documents : void 0
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
export {
|
|
151
|
+
_normalizeInputRichMessage
|
|
152
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
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 resolvePeer = require("../users/resolve-peer.cjs");
|
|
10
|
+
const findInUpdate = require("./find-in-update.cjs");
|
|
11
|
+
const normalizeRichMessage = require("./normalize-rich-message.cjs");
|
|
12
|
+
const sendCommon = require("./send-common.cjs");
|
|
13
|
+
const factories = require("../../types/bots/keyboards/factories.cjs");
|
|
14
|
+
async function sendRichMessage(client, chatId, params) {
|
|
15
|
+
const { peer, replyTo, scheduleDate, chainId, quickReplyShortcut } = await sendCommon._processCommonSendParameters(
|
|
16
|
+
client,
|
|
17
|
+
chatId,
|
|
18
|
+
params
|
|
19
|
+
);
|
|
20
|
+
const richMessage = await normalizeRichMessage._normalizeInputRichMessage(client, peer, params.content, params);
|
|
21
|
+
const randomId = params.randomId ?? longUtils.randomLong();
|
|
22
|
+
const res = await client.call(
|
|
23
|
+
{
|
|
24
|
+
_: "messages.sendMessage",
|
|
25
|
+
peer,
|
|
26
|
+
silent: params.silent,
|
|
27
|
+
replyTo,
|
|
28
|
+
randomId,
|
|
29
|
+
scheduleDate,
|
|
30
|
+
replyMarkup: factories._convertToTl(params.replyMarkup),
|
|
31
|
+
message: "",
|
|
32
|
+
clearDraft: params.clearDraft,
|
|
33
|
+
noforwards: params.forbidForwards,
|
|
34
|
+
sendAs: params.sendAs ? await resolvePeer.resolvePeer(client, params.sendAs) : void 0,
|
|
35
|
+
quickReplyShortcut,
|
|
36
|
+
effect: params.effect,
|
|
37
|
+
allowPaidFloodskip: params.allowPaidFloodskip,
|
|
38
|
+
allowPaidStars: params.allowPaidMessages,
|
|
39
|
+
richMessage
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
chainId,
|
|
43
|
+
abortSignal: params.abortSignal,
|
|
44
|
+
businessConnectionId: params.businessConnectionId
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
return findInUpdate._findMessageInUpdate(client, res, false, !params.shouldDispatch, false, randomId);
|
|
48
|
+
}
|
|
49
|
+
exports.sendRichMessage = sendRichMessage;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { default as Long } from 'long';
|
|
2
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
3
|
+
import { ReplyMarkup } from '../../types/bots/keyboards/index.js';
|
|
4
|
+
import { Message } from '../../types/messages/message.js';
|
|
5
|
+
import { InputRichMessage, RichMediaUploadCache } from '../../types/messages/rich/types.js';
|
|
6
|
+
import { InputPeerLike } from '../../types/peers/index.js';
|
|
7
|
+
import { CommonSendParams } from './send-common.js';
|
|
8
|
+
/**
|
|
9
|
+
* Send a rich message
|
|
10
|
+
*
|
|
11
|
+
* @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
|
|
12
|
+
* @param params Rich message contents and additional sending parameters
|
|
13
|
+
*/
|
|
14
|
+
export declare function sendRichMessage(client: ITelegramClient, chatId: InputPeerLike, params: CommonSendParams & {
|
|
15
|
+
content: InputRichMessage;
|
|
16
|
+
/** Override the default random ID, for streaming drafts */
|
|
17
|
+
randomId?: Long;
|
|
18
|
+
/**
|
|
19
|
+
* For bots: inline or reply markup or an instruction
|
|
20
|
+
* to hide a reply keyboard or to force a reply.
|
|
21
|
+
*/
|
|
22
|
+
replyMarkup?: ReplyMarkup;
|
|
23
|
+
/**
|
|
24
|
+
* Function that will be called after some part has been uploaded.
|
|
25
|
+
*
|
|
26
|
+
* @param id ID of the file being uploaded
|
|
27
|
+
* @param uploaded Number of bytes already uploaded
|
|
28
|
+
* @param total Total file size
|
|
29
|
+
*/
|
|
30
|
+
progressCallback?: (id: string, uploaded: number, total: number) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Cache for uploaded media, used to avoid re-uploading the same media multiple times.
|
|
33
|
+
*
|
|
34
|
+
* Pass a (potentially shared) {@link RichMediaUploadCache} to reuse media uploaded
|
|
35
|
+
* by an earlier call (e.g. a streaming draft) instead of uploading it again.
|
|
36
|
+
*/
|
|
37
|
+
uploadCache?: RichMediaUploadCache;
|
|
38
|
+
}): Promise<Message>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { default as Long } from 'long';
|
|
2
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
3
|
+
import { ReplyMarkup } from '../../types/bots/keyboards/index.js';
|
|
4
|
+
import { Message } from '../../types/messages/message.js';
|
|
5
|
+
import { InputRichMessage, RichMediaUploadCache } from '../../types/messages/rich/types.js';
|
|
6
|
+
import { InputPeerLike } from '../../types/peers/index.js';
|
|
7
|
+
import { CommonSendParams } from './send-common.js';
|
|
8
|
+
/**
|
|
9
|
+
* Send a rich message
|
|
10
|
+
*
|
|
11
|
+
* @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
|
|
12
|
+
* @param params Rich message contents and additional sending parameters
|
|
13
|
+
*/
|
|
14
|
+
export declare function sendRichMessage(client: ITelegramClient, chatId: InputPeerLike, params: CommonSendParams & {
|
|
15
|
+
content: InputRichMessage;
|
|
16
|
+
/** Override the default random ID, for streaming drafts */
|
|
17
|
+
randomId?: Long;
|
|
18
|
+
/**
|
|
19
|
+
* For bots: inline or reply markup or an instruction
|
|
20
|
+
* to hide a reply keyboard or to force a reply.
|
|
21
|
+
*/
|
|
22
|
+
replyMarkup?: ReplyMarkup;
|
|
23
|
+
/**
|
|
24
|
+
* Function that will be called after some part has been uploaded.
|
|
25
|
+
*
|
|
26
|
+
* @param id ID of the file being uploaded
|
|
27
|
+
* @param uploaded Number of bytes already uploaded
|
|
28
|
+
* @param total Total file size
|
|
29
|
+
*/
|
|
30
|
+
progressCallback?: (id: string, uploaded: number, total: number) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Cache for uploaded media, used to avoid re-uploading the same media multiple times.
|
|
33
|
+
*
|
|
34
|
+
* Pass a (potentially shared) {@link RichMediaUploadCache} to reuse media uploaded
|
|
35
|
+
* by an earlier call (e.g. a streaming draft) instead of uploading it again.
|
|
36
|
+
*/
|
|
37
|
+
uploadCache?: RichMediaUploadCache;
|
|
38
|
+
}): Promise<Message>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { randomLong } from "../../../utils/long-utils.js";
|
|
2
|
+
import { resolvePeer } from "../users/resolve-peer.js";
|
|
3
|
+
import { _findMessageInUpdate } from "./find-in-update.js";
|
|
4
|
+
import { _normalizeInputRichMessage } from "./normalize-rich-message.js";
|
|
5
|
+
import { _processCommonSendParameters } from "./send-common.js";
|
|
6
|
+
import { _convertToTl } from "../../types/bots/keyboards/factories.js";
|
|
7
|
+
async function sendRichMessage(client, chatId, params) {
|
|
8
|
+
const { peer, replyTo, scheduleDate, chainId, quickReplyShortcut } = await _processCommonSendParameters(
|
|
9
|
+
client,
|
|
10
|
+
chatId,
|
|
11
|
+
params
|
|
12
|
+
);
|
|
13
|
+
const richMessage = await _normalizeInputRichMessage(client, peer, params.content, params);
|
|
14
|
+
const randomId = params.randomId ?? randomLong();
|
|
15
|
+
const res = await client.call(
|
|
16
|
+
{
|
|
17
|
+
_: "messages.sendMessage",
|
|
18
|
+
peer,
|
|
19
|
+
silent: params.silent,
|
|
20
|
+
replyTo,
|
|
21
|
+
randomId,
|
|
22
|
+
scheduleDate,
|
|
23
|
+
replyMarkup: _convertToTl(params.replyMarkup),
|
|
24
|
+
message: "",
|
|
25
|
+
clearDraft: params.clearDraft,
|
|
26
|
+
noforwards: params.forbidForwards,
|
|
27
|
+
sendAs: params.sendAs ? await resolvePeer(client, params.sendAs) : void 0,
|
|
28
|
+
quickReplyShortcut,
|
|
29
|
+
effect: params.effect,
|
|
30
|
+
allowPaidFloodskip: params.allowPaidFloodskip,
|
|
31
|
+
allowPaidStars: params.allowPaidMessages,
|
|
32
|
+
richMessage
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
chainId,
|
|
36
|
+
abortSignal: params.abortSignal,
|
|
37
|
+
businessConnectionId: params.businessConnectionId
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
return _findMessageInUpdate(client, res, false, !params.shouldDispatch, false, randomId);
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
sendRichMessage
|
|
44
|
+
};
|
package/highlevel/methods.d.cts
CHANGED
|
@@ -163,6 +163,8 @@ export { iterInviteLinks } from './methods/invite-links/iter-invite-links.js';
|
|
|
163
163
|
export { revokeInviteLink } from './methods/invite-links/revoke-invite-link.js';
|
|
164
164
|
export { appendTodoList } from './methods/messages/append-todo-list.js';
|
|
165
165
|
export { closePoll } from './methods/messages/close-poll.js';
|
|
166
|
+
export { createRichStreamingDraft } from './methods/messages/create-rich-streaming-draft.js';
|
|
167
|
+
export type { RichStreamingDraft } from './methods/messages/create-rich-streaming-draft.js';
|
|
166
168
|
export { createStreamingDraft } from './methods/messages/create-streaming-draft.js';
|
|
167
169
|
export type { StreamingDraft } from './methods/messages/create-streaming-draft.js';
|
|
168
170
|
export { deleteMessagesById } from './methods/messages/delete-messages.js';
|
|
@@ -230,6 +232,7 @@ export { sendReaction } from './methods/messages/send-reaction.js';
|
|
|
230
232
|
export { replyText } from './methods/messages/send-reply.js';
|
|
231
233
|
export { replyMedia } from './methods/messages/send-reply.js';
|
|
232
234
|
export { replyMediaGroup } from './methods/messages/send-reply.js';
|
|
235
|
+
export { sendRichMessage } from './methods/messages/send-rich-message.js';
|
|
233
236
|
export { sendScheduled } from './methods/messages/send-scheduled.js';
|
|
234
237
|
export { sendText } from './methods/messages/send-text.js';
|
|
235
238
|
export { sendTyping } from './methods/messages/send-typing.js';
|
package/highlevel/methods.d.ts
CHANGED
|
@@ -163,6 +163,8 @@ export { iterInviteLinks } from './methods/invite-links/iter-invite-links.js';
|
|
|
163
163
|
export { revokeInviteLink } from './methods/invite-links/revoke-invite-link.js';
|
|
164
164
|
export { appendTodoList } from './methods/messages/append-todo-list.js';
|
|
165
165
|
export { closePoll } from './methods/messages/close-poll.js';
|
|
166
|
+
export { createRichStreamingDraft } from './methods/messages/create-rich-streaming-draft.js';
|
|
167
|
+
export type { RichStreamingDraft } from './methods/messages/create-rich-streaming-draft.js';
|
|
166
168
|
export { createStreamingDraft } from './methods/messages/create-streaming-draft.js';
|
|
167
169
|
export type { StreamingDraft } from './methods/messages/create-streaming-draft.js';
|
|
168
170
|
export { deleteMessagesById } from './methods/messages/delete-messages.js';
|
|
@@ -230,6 +232,7 @@ export { sendReaction } from './methods/messages/send-reaction.js';
|
|
|
230
232
|
export { replyText } from './methods/messages/send-reply.js';
|
|
231
233
|
export { replyMedia } from './methods/messages/send-reply.js';
|
|
232
234
|
export { replyMediaGroup } from './methods/messages/send-reply.js';
|
|
235
|
+
export { sendRichMessage } from './methods/messages/send-rich-message.js';
|
|
233
236
|
export { sendScheduled } from './methods/messages/send-scheduled.js';
|
|
234
237
|
export { sendText } from './methods/messages/send-text.js';
|
|
235
238
|
export { sendTyping } from './methods/messages/send-typing.js';
|
|
@@ -6,6 +6,7 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
|
|
|
6
6
|
"use strict";
|
|
7
7
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
8
|
const utils = require("../../../../types/utils.cjs");
|
|
9
|
+
const normalizeRichMessage = require("../../../methods/messages/normalize-rich-message.cjs");
|
|
9
10
|
const normalizeText = require("../../../methods/misc/normalize-text.cjs");
|
|
10
11
|
const factories = require("../keyboards/factories.cjs");
|
|
11
12
|
function text(text2, params = {}) {
|
|
@@ -14,6 +15,12 @@ function text(text2, params = {}) {
|
|
|
14
15
|
ret.text = text2;
|
|
15
16
|
return ret;
|
|
16
17
|
}
|
|
18
|
+
function rich(rich2, params = {}) {
|
|
19
|
+
const ret = params;
|
|
20
|
+
ret.type = "rich";
|
|
21
|
+
ret.content = rich2;
|
|
22
|
+
return ret;
|
|
23
|
+
}
|
|
17
24
|
function media(params = {}) {
|
|
18
25
|
const ret = params;
|
|
19
26
|
ret.type = "media";
|
|
@@ -61,6 +68,12 @@ async function _convertToTl(client, obj) {
|
|
|
61
68
|
invertMedia: obj.invertMedia
|
|
62
69
|
};
|
|
63
70
|
}
|
|
71
|
+
case "rich":
|
|
72
|
+
return {
|
|
73
|
+
_: "inputBotInlineMessageRichMessage",
|
|
74
|
+
replyMarkup: factories._convertToTl(obj.replyMarkup),
|
|
75
|
+
richMessage: "_" in obj.content ? obj.content : await normalizeRichMessage._normalizeInputRichMessage(client, { _: "inputPeerEmpty" }, obj.content, {})
|
|
76
|
+
};
|
|
64
77
|
case "media": {
|
|
65
78
|
const [message, entities] = await normalizeText._normalizeInputText(client, obj.text);
|
|
66
79
|
return {
|
|
@@ -139,6 +152,7 @@ exports.game = game;
|
|
|
139
152
|
exports.geo = geo;
|
|
140
153
|
exports.geoLive = geoLive;
|
|
141
154
|
exports.media = media;
|
|
155
|
+
exports.rich = rich;
|
|
142
156
|
exports.text = text;
|
|
143
157
|
exports.venue = venue;
|
|
144
158
|
exports.webpage = webpage;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { tl } from '../../../../tl/index.js';
|
|
2
2
|
import { ITelegramClient } from '../../../client.types.js';
|
|
3
3
|
import { InputText } from '../../../types/misc/entities.js';
|
|
4
|
-
import {
|
|
4
|
+
import { InputRichMessage } from '../../messages/rich/types.js';
|
|
5
|
+
import { InputInlineMessage, InputInlineMessageContact, InputInlineMessageGame, InputInlineMessageGeo, InputInlineMessageGeoLive, InputInlineMessageMedia, InputInlineMessageRich, InputInlineMessageText, InputInlineMessageVenue, InputInlineMessageWebpage } from './types.js';
|
|
5
6
|
/**
|
|
6
7
|
* Create a text inline message
|
|
7
8
|
*
|
|
@@ -9,6 +10,13 @@ import { InputInlineMessage, InputInlineMessageContact, InputInlineMessageGame,
|
|
|
9
10
|
* @param params
|
|
10
11
|
*/
|
|
11
12
|
export declare function text(text: InputText, params?: Omit<InputInlineMessageText, 'type' | 'text'>): InputInlineMessageText;
|
|
13
|
+
/**
|
|
14
|
+
* Create a rich inline message
|
|
15
|
+
*
|
|
16
|
+
* @param rich Input rich message
|
|
17
|
+
* @param params
|
|
18
|
+
*/
|
|
19
|
+
export declare function rich(rich: tl.TypeInputRichMessage | InputRichMessage, params?: Omit<InputInlineMessageRich, 'type' | 'content'>): InputInlineMessageRich;
|
|
12
20
|
/**
|
|
13
21
|
* Create an inline message containing
|
|
14
22
|
* media from the result
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { tl } from '../../../../tl/index.js';
|
|
2
2
|
import { ITelegramClient } from '../../../client.types.js';
|
|
3
3
|
import { InputText } from '../../../types/misc/entities.js';
|
|
4
|
-
import {
|
|
4
|
+
import { InputRichMessage } from '../../messages/rich/types.js';
|
|
5
|
+
import { InputInlineMessage, InputInlineMessageContact, InputInlineMessageGame, InputInlineMessageGeo, InputInlineMessageGeoLive, InputInlineMessageMedia, InputInlineMessageRich, InputInlineMessageText, InputInlineMessageVenue, InputInlineMessageWebpage } from './types.js';
|
|
5
6
|
/**
|
|
6
7
|
* Create a text inline message
|
|
7
8
|
*
|
|
@@ -9,6 +10,13 @@ import { InputInlineMessage, InputInlineMessageContact, InputInlineMessageGame,
|
|
|
9
10
|
* @param params
|
|
10
11
|
*/
|
|
11
12
|
export declare function text(text: InputText, params?: Omit<InputInlineMessageText, 'type' | 'text'>): InputInlineMessageText;
|
|
13
|
+
/**
|
|
14
|
+
* Create a rich inline message
|
|
15
|
+
*
|
|
16
|
+
* @param rich Input rich message
|
|
17
|
+
* @param params
|
|
18
|
+
*/
|
|
19
|
+
export declare function rich(rich: tl.TypeInputRichMessage | InputRichMessage, params?: Omit<InputInlineMessageRich, 'type' | 'content'>): InputInlineMessageRich;
|
|
12
20
|
/**
|
|
13
21
|
* Create an inline message containing
|
|
14
22
|
* media from the result
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assertNever } from "../../../../types/utils.js";
|
|
2
|
+
import { _normalizeInputRichMessage } from "../../../methods/messages/normalize-rich-message.js";
|
|
2
3
|
import { _normalizeInputText } from "../../../methods/misc/normalize-text.js";
|
|
3
4
|
import { _convertToTl as _convertToTl$1 } from "../keyboards/factories.js";
|
|
4
5
|
function text(text2, params = {}) {
|
|
@@ -7,6 +8,12 @@ function text(text2, params = {}) {
|
|
|
7
8
|
ret.text = text2;
|
|
8
9
|
return ret;
|
|
9
10
|
}
|
|
11
|
+
function rich(rich2, params = {}) {
|
|
12
|
+
const ret = params;
|
|
13
|
+
ret.type = "rich";
|
|
14
|
+
ret.content = rich2;
|
|
15
|
+
return ret;
|
|
16
|
+
}
|
|
10
17
|
function media(params = {}) {
|
|
11
18
|
const ret = params;
|
|
12
19
|
ret.type = "media";
|
|
@@ -54,6 +61,12 @@ async function _convertToTl(client, obj) {
|
|
|
54
61
|
invertMedia: obj.invertMedia
|
|
55
62
|
};
|
|
56
63
|
}
|
|
64
|
+
case "rich":
|
|
65
|
+
return {
|
|
66
|
+
_: "inputBotInlineMessageRichMessage",
|
|
67
|
+
replyMarkup: _convertToTl$1(obj.replyMarkup),
|
|
68
|
+
richMessage: "_" in obj.content ? obj.content : await _normalizeInputRichMessage(client, { _: "inputPeerEmpty" }, obj.content, {})
|
|
69
|
+
};
|
|
57
70
|
case "media": {
|
|
58
71
|
const [message, entities] = await _normalizeInputText(client, obj.text);
|
|
59
72
|
return {
|
|
@@ -133,6 +146,7 @@ export {
|
|
|
133
146
|
geo,
|
|
134
147
|
geoLive,
|
|
135
148
|
media,
|
|
149
|
+
rich,
|
|
136
150
|
text,
|
|
137
151
|
venue,
|
|
138
152
|
webpage
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { tl } from '../../../../tl/index.js';
|
|
1
2
|
import { InputMediaContact, InputMediaGeo, InputMediaGeoLive, InputMediaVenue, InputMediaWebpage } from '../../media/index.js';
|
|
3
|
+
import { InputRichMessage } from '../../messages/rich/index.js';
|
|
2
4
|
import { InputText } from '../../misc/entities.js';
|
|
3
5
|
import { ReplyMarkup } from '../index.js';
|
|
4
6
|
/**
|
|
@@ -26,6 +28,20 @@ export interface InputInlineMessageText {
|
|
|
26
28
|
*/
|
|
27
29
|
invertMedia?: boolean;
|
|
28
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Inline message containing a rich message
|
|
33
|
+
*/
|
|
34
|
+
export interface InputInlineMessageRich {
|
|
35
|
+
type: 'rich';
|
|
36
|
+
/**
|
|
37
|
+
* Contents of the message
|
|
38
|
+
*/
|
|
39
|
+
content: tl.TypeInputRichMessage | InputRichMessage;
|
|
40
|
+
/**
|
|
41
|
+
* Message reply markup
|
|
42
|
+
*/
|
|
43
|
+
replyMarkup?: ReplyMarkup;
|
|
44
|
+
}
|
|
29
45
|
/**
|
|
30
46
|
* Inline message containing media, which is automatically
|
|
31
47
|
* inferred from the result itself.
|
|
@@ -111,4 +127,4 @@ export interface InputInlineMessageWebpage extends InputMediaWebpage {
|
|
|
111
127
|
*/
|
|
112
128
|
invertMedia?: boolean;
|
|
113
129
|
}
|
|
114
|
-
export type InputInlineMessage = InputInlineMessageText | InputInlineMessageMedia | InputInlineMessageGeo | InputInlineMessageGeoLive | InputInlineMessageVenue | InputInlineMessageGame | InputInlineMessageContact | InputInlineMessageWebpage;
|
|
130
|
+
export type InputInlineMessage = InputInlineMessageText | InputInlineMessageMedia | InputInlineMessageGeo | InputInlineMessageGeoLive | InputInlineMessageVenue | InputInlineMessageGame | InputInlineMessageContact | InputInlineMessageWebpage | InputInlineMessageRich;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { tl } from '../../../../tl/index.js';
|
|
1
2
|
import { InputMediaContact, InputMediaGeo, InputMediaGeoLive, InputMediaVenue, InputMediaWebpage } from '../../media/index.js';
|
|
3
|
+
import { InputRichMessage } from '../../messages/rich/index.js';
|
|
2
4
|
import { InputText } from '../../misc/entities.js';
|
|
3
5
|
import { ReplyMarkup } from '../index.js';
|
|
4
6
|
/**
|
|
@@ -26,6 +28,20 @@ export interface InputInlineMessageText {
|
|
|
26
28
|
*/
|
|
27
29
|
invertMedia?: boolean;
|
|
28
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Inline message containing a rich message
|
|
33
|
+
*/
|
|
34
|
+
export interface InputInlineMessageRich {
|
|
35
|
+
type: 'rich';
|
|
36
|
+
/**
|
|
37
|
+
* Contents of the message
|
|
38
|
+
*/
|
|
39
|
+
content: tl.TypeInputRichMessage | InputRichMessage;
|
|
40
|
+
/**
|
|
41
|
+
* Message reply markup
|
|
42
|
+
*/
|
|
43
|
+
replyMarkup?: ReplyMarkup;
|
|
44
|
+
}
|
|
29
45
|
/**
|
|
30
46
|
* Inline message containing media, which is automatically
|
|
31
47
|
* inferred from the result itself.
|
|
@@ -111,4 +127,4 @@ export interface InputInlineMessageWebpage extends InputMediaWebpage {
|
|
|
111
127
|
*/
|
|
112
128
|
invertMedia?: boolean;
|
|
113
129
|
}
|
|
114
|
-
export type InputInlineMessage = InputInlineMessageText | InputInlineMessageMedia | InputInlineMessageGeo | InputInlineMessageGeoLive | InputInlineMessageVenue | InputInlineMessageGame | InputInlineMessageContact | InputInlineMessageWebpage;
|
|
130
|
+
export type InputInlineMessage = InputInlineMessageText | InputInlineMessageMedia | InputInlineMessageGeo | InputInlineMessageGeoLive | InputInlineMessageVenue | InputInlineMessageGame | InputInlineMessageContact | InputInlineMessageWebpage | InputInlineMessageRich;
|
|
@@ -543,4 +543,4 @@ export interface InputMediaTodoList {
|
|
|
543
543
|
*
|
|
544
544
|
* @link InputMedia
|
|
545
545
|
*/
|
|
546
|
-
export type InputMediaLike = InputMediaAudio | InputMediaVoice | InputMediaDocument | InputMediaPhoto | InputMediaVideo | InputMediaAuto | InputMediaSticker | InputMediaVenue | InputMediaGeo | InputMediaGeoLive | InputMediaDice | InputMediaContact | InputMediaGame | InputMediaInvoice | InputMediaPoll | InputMediaQuiz | InputMediaStory | InputMediaWebpage | InputMediaPaidMedia | InputMediaTodoList | tl.TypeInputMedia;
|
|
546
|
+
export type InputMediaLike = InputMediaAudio | InputMediaVoice | InputMediaDocument | InputMediaPhoto | InputMediaVideo | InputMediaAuto | InputMediaSticker | InputMediaVenue | InputMediaGeo | InputMediaGeoLive | InputMediaDice | InputMediaContact | InputMediaGame | InputMediaInvoice | InputMediaPoll | InputMediaQuiz | InputMediaStory | InputMediaWebpage | InputMediaPaidMedia | InputMediaTodoList | tl.TypeInputMedia | tl.TypeInputPhoto | tl.TypeInputDocument;
|
|
@@ -543,4 +543,4 @@ export interface InputMediaTodoList {
|
|
|
543
543
|
*
|
|
544
544
|
* @link InputMedia
|
|
545
545
|
*/
|
|
546
|
-
export type InputMediaLike = InputMediaAudio | InputMediaVoice | InputMediaDocument | InputMediaPhoto | InputMediaVideo | InputMediaAuto | InputMediaSticker | InputMediaVenue | InputMediaGeo | InputMediaGeoLive | InputMediaDice | InputMediaContact | InputMediaGame | InputMediaInvoice | InputMediaPoll | InputMediaQuiz | InputMediaStory | InputMediaWebpage | InputMediaPaidMedia | InputMediaTodoList | tl.TypeInputMedia;
|
|
546
|
+
export type InputMediaLike = InputMediaAudio | InputMediaVoice | InputMediaDocument | InputMediaPhoto | InputMediaVideo | InputMediaAuto | InputMediaSticker | InputMediaVenue | InputMediaGeo | InputMediaGeoLive | InputMediaDice | InputMediaContact | InputMediaGame | InputMediaInvoice | InputMediaPoll | InputMediaQuiz | InputMediaStory | InputMediaWebpage | InputMediaPaidMedia | InputMediaTodoList | tl.TypeInputMedia | tl.TypeInputPhoto | tl.TypeInputDocument;
|
|
@@ -11,6 +11,6 @@ export * from './message-reactions.js';
|
|
|
11
11
|
export * from './message-replies.js';
|
|
12
12
|
export * from './message.js';
|
|
13
13
|
export * from './replied-message.js';
|
|
14
|
-
export * from './rich
|
|
14
|
+
export * from './rich/index.js';
|
|
15
15
|
export * from './search-filters.js';
|
|
16
16
|
export * from './suggested-post.js';
|
|
@@ -11,6 +11,6 @@ export * from './message-reactions.js';
|
|
|
11
11
|
export * from './message-replies.js';
|
|
12
12
|
export * from './message.js';
|
|
13
13
|
export * from './replied-message.js';
|
|
14
|
-
export * from './rich
|
|
14
|
+
export * from './rich/index.js';
|
|
15
15
|
export * from './search-filters.js';
|
|
16
16
|
export * from './suggested-post.js';
|
|
@@ -20,7 +20,7 @@ const messageMedia = require("./message-media.cjs");
|
|
|
20
20
|
const messageReactions = require("./message-reactions.cjs");
|
|
21
21
|
const messageReplies = require("./message-replies.cjs");
|
|
22
22
|
const repliedMessage = require("./replied-message.cjs");
|
|
23
|
-
const richMessage = require("./rich-message.cjs");
|
|
23
|
+
const richMessage = require("./rich/rich-message.cjs");
|
|
24
24
|
const suggestedPost = require("./suggested-post.cjs");
|
|
25
25
|
const inspectable = require("../../utils/inspectable.cjs");
|
|
26
26
|
const factories = require("../bots/keyboards/factories.cjs");
|
|
@@ -12,7 +12,7 @@ import { MessageForwardInfo } from './message-forward.js';
|
|
|
12
12
|
import { MessageReactions } from './message-reactions.js';
|
|
13
13
|
import { MessageRepliesInfo } from './message-replies.js';
|
|
14
14
|
import { RepliedMessageInfo } from './replied-message.js';
|
|
15
|
-
import { RichMessage } from './rich-message.js';
|
|
15
|
+
import { RichMessage } from './rich/rich-message.js';
|
|
16
16
|
import { SuggestedPostInfo } from './suggested-post.js';
|
|
17
17
|
/**
|
|
18
18
|
* A Telegram message.
|
|
@@ -12,7 +12,7 @@ import { MessageForwardInfo } from './message-forward.js';
|
|
|
12
12
|
import { MessageReactions } from './message-reactions.js';
|
|
13
13
|
import { MessageRepliesInfo } from './message-replies.js';
|
|
14
14
|
import { RepliedMessageInfo } from './replied-message.js';
|
|
15
|
-
import { RichMessage } from './rich-message.js';
|
|
15
|
+
import { RichMessage } from './rich/rich-message.js';
|
|
16
16
|
import { SuggestedPostInfo } from './suggested-post.js';
|
|
17
17
|
/**
|
|
18
18
|
* A Telegram message.
|
|
@@ -13,7 +13,7 @@ import { _messageMediaFromTl } from "./message-media.js";
|
|
|
13
13
|
import { MessageReactions as MessageReactions$2 } from "./message-reactions.js";
|
|
14
14
|
import { MessageRepliesInfo as MessageRepliesInfo$2 } from "./message-replies.js";
|
|
15
15
|
import { RepliedMessageInfo as RepliedMessageInfo$2 } from "./replied-message.js";
|
|
16
|
-
import { RichMessage as RichMessage$2 } from "./rich-message.js";
|
|
16
|
+
import { RichMessage as RichMessage$2 } from "./rich/rich-message.js";
|
|
17
17
|
import { SuggestedPostInfo as SuggestedPostInfo$1 } from "./suggested-post.js";
|
|
18
18
|
import { makeInspectable } from "../../utils/inspectable.js";
|
|
19
19
|
import { _rowsTo2d } from "../bots/keyboards/factories.js";
|