@mtcute/core 0.32.0 → 0.32.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.
@@ -3539,6 +3539,8 @@ export interface TelegramClient extends ITelegramClient {
3539
3539
  * New message media
3540
3540
  */
3541
3541
  media?: InputMediaLike;
3542
+ /** New rich message content */
3543
+ richMessage?: InputRichMessage;
3542
3544
  /**
3543
3545
  * Whether to disable links preview in this message
3544
3546
  */
@@ -3554,12 +3556,14 @@ export interface TelegramClient extends ITelegramClient {
3554
3556
  */
3555
3557
  scheduleDate?: Date | number;
3556
3558
  /**
3557
- * For media, upload progress callback.
3559
+ * For media and rich message attachments, upload progress callback.
3558
3560
  *
3559
3561
  * @param uploaded Number of bytes uploaded
3560
3562
  * @param total Total file size in bytes
3561
3563
  */
3562
3564
  progressCallback?: (uploaded: number, total: number) => void;
3565
+ /** Cache for uploaded rich message media, see {@link createRichStreamingDraft} */
3566
+ uploadCache?: RichMediaUploadCache;
3563
3567
  /**
3564
3568
  * Whether to dispatch the edit message event
3565
3569
  * to the client's update handler.
@@ -3539,6 +3539,8 @@ export interface TelegramClient extends ITelegramClient {
3539
3539
  * New message media
3540
3540
  */
3541
3541
  media?: InputMediaLike;
3542
+ /** New rich message content */
3543
+ richMessage?: InputRichMessage;
3542
3544
  /**
3543
3545
  * Whether to disable links preview in this message
3544
3546
  */
@@ -3554,12 +3556,14 @@ export interface TelegramClient extends ITelegramClient {
3554
3556
  */
3555
3557
  scheduleDate?: Date | number;
3556
3558
  /**
3557
- * For media, upload progress callback.
3559
+ * For media and rich message attachments, upload progress callback.
3558
3560
  *
3559
3561
  * @param uploaded Number of bytes uploaded
3560
3562
  * @param total Total file size in bytes
3561
3563
  */
3562
3564
  progressCallback?: (uploaded: number, total: number) => void;
3565
+ /** Cache for uploaded rich message media, see {@link createRichStreamingDraft} */
3566
+ uploadCache?: RichMediaUploadCache;
3563
3567
  /**
3564
3568
  * Whether to dispatch the edit message event
3565
3569
  * to the client's update handler.
@@ -9,6 +9,7 @@ const normalizeInputMedia = require("../files/normalize-input-media.cjs");
9
9
  const normalizeText = require("../misc/normalize-text.cjs");
10
10
  const resolvePeer = require("../users/resolve-peer.cjs");
11
11
  const findInUpdate = require("./find-in-update.cjs");
12
+ const normalizeRichMessage = require("./normalize-rich-message.cjs");
12
13
  const inputMessageId = require("../../types/messages/input-message-id.cjs");
13
14
  const factories = require("../../types/bots/keyboards/factories.cjs");
14
15
  async function editMessage(client, params) {
@@ -16,6 +17,7 @@ async function editMessage(client, params) {
16
17
  let content;
17
18
  let entities;
18
19
  let media;
20
+ const peer = await resolvePeer.resolvePeer(client, chatId);
19
21
  if (params.media) {
20
22
  media = await normalizeInputMedia._normalizeInputMedia(client, params.media, params);
21
23
  if ("caption" in params.media && params.media.caption !== void 0) {
@@ -28,12 +30,16 @@ async function editMessage(client, params) {
28
30
  const res = await client.call({
29
31
  _: "messages.editMessage",
30
32
  id: message,
31
- peer: await resolvePeer.resolvePeer(client, chatId),
33
+ peer,
32
34
  noWebpage: params.disableWebPreview,
33
35
  replyMarkup: factories._convertToTl(params.replyMarkup),
34
36
  message: content,
35
37
  entities,
36
38
  media,
39
+ richMessage: params.richMessage ? await normalizeRichMessage._normalizeInputRichMessage(client, peer, params.richMessage, {
40
+ progressCallback: params.progressCallback ? (_id, uploaded, total) => params.progressCallback?.(uploaded, total) : void 0,
41
+ uploadCache: params.uploadCache
42
+ }) : void 0,
37
43
  invertMedia: params.invertMedia
38
44
  }, {
39
45
  businessConnectionId: params.businessConnectionId
@@ -1,5 +1,5 @@
1
1
  import { ITelegramClient } from '../../client.types.js';
2
- import { InputMediaLike, InputMessageId, InputText, Message, ReplyMarkup } from '../../types/index.js';
2
+ import { InputMediaLike, InputMessageId, InputRichMessage, InputText, Message, ReplyMarkup, RichMediaUploadCache } from '../../types/index.js';
3
3
  /**
4
4
  * Edit message text, media, reply markup and schedule date.
5
5
  *
@@ -18,6 +18,8 @@ export declare function editMessage(client: ITelegramClient, params: InputMessag
18
18
  * New message media
19
19
  */
20
20
  media?: InputMediaLike;
21
+ /** New rich message content */
22
+ richMessage?: InputRichMessage;
21
23
  /**
22
24
  * Whether to disable links preview in this message
23
25
  */
@@ -33,12 +35,14 @@ export declare function editMessage(client: ITelegramClient, params: InputMessag
33
35
  */
34
36
  scheduleDate?: Date | number;
35
37
  /**
36
- * For media, upload progress callback.
38
+ * For media and rich message attachments, upload progress callback.
37
39
  *
38
40
  * @param uploaded Number of bytes uploaded
39
41
  * @param total Total file size in bytes
40
42
  */
41
43
  progressCallback?: (uploaded: number, total: number) => void;
44
+ /** Cache for uploaded rich message media, see {@link createRichStreamingDraft} */
45
+ uploadCache?: RichMediaUploadCache;
42
46
  /**
43
47
  * Whether to dispatch the edit message event
44
48
  * to the client's update handler.
@@ -1,5 +1,5 @@
1
1
  import { ITelegramClient } from '../../client.types.js';
2
- import { InputMediaLike, InputMessageId, InputText, Message, ReplyMarkup } from '../../types/index.js';
2
+ import { InputMediaLike, InputMessageId, InputRichMessage, InputText, Message, ReplyMarkup, RichMediaUploadCache } from '../../types/index.js';
3
3
  /**
4
4
  * Edit message text, media, reply markup and schedule date.
5
5
  *
@@ -18,6 +18,8 @@ export declare function editMessage(client: ITelegramClient, params: InputMessag
18
18
  * New message media
19
19
  */
20
20
  media?: InputMediaLike;
21
+ /** New rich message content */
22
+ richMessage?: InputRichMessage;
21
23
  /**
22
24
  * Whether to disable links preview in this message
23
25
  */
@@ -33,12 +35,14 @@ export declare function editMessage(client: ITelegramClient, params: InputMessag
33
35
  */
34
36
  scheduleDate?: Date | number;
35
37
  /**
36
- * For media, upload progress callback.
38
+ * For media and rich message attachments, upload progress callback.
37
39
  *
38
40
  * @param uploaded Number of bytes uploaded
39
41
  * @param total Total file size in bytes
40
42
  */
41
43
  progressCallback?: (uploaded: number, total: number) => void;
44
+ /** Cache for uploaded rich message media, see {@link createRichStreamingDraft} */
45
+ uploadCache?: RichMediaUploadCache;
42
46
  /**
43
47
  * Whether to dispatch the edit message event
44
48
  * to the client's update handler.
@@ -2,6 +2,7 @@ import { _normalizeInputMedia } from "../files/normalize-input-media.js";
2
2
  import { _normalizeInputText } from "../misc/normalize-text.js";
3
3
  import { resolvePeer } from "../users/resolve-peer.js";
4
4
  import { _findMessageInUpdate } from "./find-in-update.js";
5
+ import { _normalizeInputRichMessage } from "./normalize-rich-message.js";
5
6
  import { normalizeInputMessageId } from "../../types/messages/input-message-id.js";
6
7
  import { _convertToTl } from "../../types/bots/keyboards/factories.js";
7
8
  async function editMessage(client, params) {
@@ -9,6 +10,7 @@ async function editMessage(client, params) {
9
10
  let content;
10
11
  let entities;
11
12
  let media;
13
+ const peer = await resolvePeer(client, chatId);
12
14
  if (params.media) {
13
15
  media = await _normalizeInputMedia(client, params.media, params);
14
16
  if ("caption" in params.media && params.media.caption !== void 0) {
@@ -21,12 +23,16 @@ async function editMessage(client, params) {
21
23
  const res = await client.call({
22
24
  _: "messages.editMessage",
23
25
  id: message,
24
- peer: await resolvePeer(client, chatId),
26
+ peer,
25
27
  noWebpage: params.disableWebPreview,
26
28
  replyMarkup: _convertToTl(params.replyMarkup),
27
29
  message: content,
28
30
  entities,
29
31
  media,
32
+ richMessage: params.richMessage ? await _normalizeInputRichMessage(client, peer, params.richMessage, {
33
+ progressCallback: params.progressCallback ? (_id, uploaded, total) => params.progressCallback?.(uploaded, total) : void 0,
34
+ uploadCache: params.uploadCache
35
+ }) : void 0,
30
36
  invertMedia: params.invertMedia
31
37
  }, {
32
38
  businessConnectionId: params.businessConnectionId
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -227,7 +227,7 @@ class NetworkManager {
227
227
  _: "initConnection",
228
228
  deviceModel,
229
229
  systemVersion: "1.0",
230
- appVersion: "0.32.0",
230
+ appVersion: "0.32.1",
231
231
  systemLangCode: "en",
232
232
  langPack: "",
233
233
  // "langPacks are for official apps only"
@@ -220,7 +220,7 @@ class NetworkManager {
220
220
  _: "initConnection",
221
221
  deviceModel,
222
222
  systemVersion: "1.0",
223
- appVersion: "0.32.0",
223
+ appVersion: "0.32.1",
224
224
  systemLangCode: "en",
225
225
  langPack: "",
226
226
  // "langPacks are for official apps only"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mtcute/core",
3
3
  "type": "module",
4
- "version": "0.32.0",
4
+ "version": "0.32.1",
5
5
  "description": "Type-safe library for MTProto (Telegram API)",
6
6
  "license": "MIT",
7
7
  "scripts": {},