@mtcute/core 0.21.0 → 0.22.0
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 +13 -8
- package/client.js +13 -8
- package/highlevel/base.cjs +3 -3
- package/highlevel/base.js +3 -3
- package/highlevel/client.d.cts +27 -49
- package/highlevel/client.d.ts +27 -49
- package/highlevel/methods/auth/sign-in-qr.cjs +4 -4
- package/highlevel/methods/files/download-iterable.cjs +25 -0
- package/highlevel/methods/files/download-iterable.js +25 -0
- package/highlevel/methods/files/upload-file.js +1 -1
- package/highlevel/methods/messages/forward-messages.cjs +2 -1
- package/highlevel/methods/messages/forward-messages.d.cts +6 -0
- package/highlevel/methods/messages/forward-messages.d.ts +6 -0
- package/highlevel/methods/messages/forward-messages.js +2 -1
- package/highlevel/methods/messages/get-web-page-preview.cjs +22 -0
- package/highlevel/methods/messages/get-web-page-preview.d.cts +9 -0
- package/highlevel/methods/messages/get-web-page-preview.d.ts +9 -0
- package/highlevel/methods/messages/get-web-page-preview.js +17 -0
- package/highlevel/methods/messages/send-common.d.cts +5 -0
- package/highlevel/methods/messages/send-common.d.ts +5 -0
- package/highlevel/methods/messages/send-media-group.cjs +2 -1
- package/highlevel/methods/messages/send-media-group.js +2 -1
- package/highlevel/methods/messages/send-media.cjs +2 -1
- package/highlevel/methods/messages/send-media.js +2 -1
- package/highlevel/methods/messages/send-paid-reaction.cjs +8 -2
- package/highlevel/methods/messages/send-paid-reaction.d.cts +8 -2
- package/highlevel/methods/messages/send-paid-reaction.d.ts +8 -2
- package/highlevel/methods/messages/send-paid-reaction.js +8 -2
- package/highlevel/methods/messages/send-text.cjs +2 -1
- package/highlevel/methods/messages/send-text.js +2 -1
- package/highlevel/methods/premium/pin-star-gift.cjs +24 -0
- package/highlevel/methods/premium/pin-star-gift.d.cts +13 -0
- package/highlevel/methods/premium/pin-star-gift.d.ts +13 -0
- package/highlevel/methods/premium/pin-star-gift.js +19 -0
- package/highlevel/methods/{premium/get-star-gifts.cjs → users/get-peer-settings.cjs} +10 -6
- package/highlevel/methods/users/get-peer-settings.d.cts +4 -0
- package/highlevel/methods/users/get-peer-settings.d.ts +4 -0
- package/highlevel/methods/users/get-peer-settings.js +14 -0
- package/highlevel/methods/users/resolve-peer.cjs +16 -31
- package/highlevel/methods/users/resolve-peer.js +7 -22
- package/highlevel/methods.d.cts +3 -2
- package/highlevel/methods.d.ts +3 -2
- package/highlevel/storage/repository/peers.d.cts +2 -3
- package/highlevel/storage/repository/peers.d.ts +2 -3
- package/highlevel/storage/service/peers.cjs +10 -4
- package/highlevel/storage/service/peers.d.cts +1 -0
- package/highlevel/storage/service/peers.d.ts +1 -0
- package/highlevel/storage/service/peers.js +10 -4
- package/highlevel/types/bots/keyboards/factories.cjs +4 -4
- package/highlevel/types/media/document.cjs +1 -1
- package/highlevel/types/media/document.js +1 -1
- package/highlevel/types/media/web-page.cjs +40 -3
- package/highlevel/types/media/web-page.d.cts +23 -1
- package/highlevel/types/media/web-page.d.ts +23 -1
- package/highlevel/types/media/web-page.js +41 -4
- package/highlevel/types/messages/message-media.cjs +1 -1
- package/highlevel/types/messages/message-media.d.cts +2 -2
- package/highlevel/types/messages/message-media.d.ts +2 -2
- package/highlevel/types/messages/message-media.js +2 -2
- package/highlevel/types/messages/message.cjs +4 -0
- package/highlevel/types/messages/message.d.cts +2 -0
- package/highlevel/types/messages/message.d.ts +2 -0
- package/highlevel/types/messages/message.js +4 -0
- package/highlevel/types/peers/chat-event/actions.cjs +5 -0
- package/highlevel/types/peers/chat-event/actions.js +5 -0
- package/highlevel/types/peers/chat.cjs +4 -0
- package/highlevel/types/peers/chat.d.cts +2 -0
- package/highlevel/types/peers/chat.d.ts +2 -0
- package/highlevel/types/peers/chat.js +4 -0
- package/highlevel/types/peers/full-chat.cjs +4 -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 +4 -0
- package/highlevel/types/peers/index.d.cts +1 -0
- package/highlevel/types/peers/index.d.ts +1 -0
- package/highlevel/types/peers/peer-settings.cjs +101 -0
- package/highlevel/types/peers/peer-settings.d.cts +84 -0
- package/highlevel/types/peers/peer-settings.d.ts +84 -0
- package/highlevel/types/peers/peer-settings.js +96 -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/premium/saved-star-gift.cjs +4 -1
- package/highlevel/types/premium/saved-star-gift.d.cts +2 -3
- package/highlevel/types/premium/saved-star-gift.d.ts +2 -3
- package/highlevel/types/premium/saved-star-gift.js +5 -2
- package/highlevel/types/premium/stars-gift-unique.cjs +4 -0
- package/highlevel/types/premium/stars-gift-unique.d.cts +2 -0
- package/highlevel/types/premium/stars-gift-unique.d.ts +2 -0
- package/highlevel/types/premium/stars-gift-unique.js +4 -0
- package/highlevel/types/premium/stars-transaction.cjs +14 -0
- package/highlevel/types/premium/stars-transaction.d.cts +14 -0
- package/highlevel/types/premium/stars-transaction.d.ts +14 -0
- package/highlevel/types/premium/stars-transaction.js +14 -0
- package/highlevel/types/stories/story-viewer.cjs +1 -1
- package/highlevel/types/stories/story-viewer.js +1 -1
- package/highlevel/types/updates/history-read-update.cjs +1 -0
- package/highlevel/types/updates/history-read-update.js +1 -0
- package/highlevel/updates/manager.js +2 -2
- package/highlevel/utils/file-utils.js +1 -1
- package/highlevel/utils/inline-utils.cjs +5 -5
- package/highlevel/utils/inline-utils.js +1 -1
- package/highlevel/worker/storage.cjs +2 -0
- package/highlevel/worker/storage.d.cts +1 -0
- package/highlevel/worker/storage.d.ts +1 -0
- package/highlevel/worker/storage.js +2 -0
- package/index.cjs +3 -1
- package/index.js +5 -3
- package/methods.cjs +6 -4
- package/methods.js +6 -4
- package/network/authorization.js +2 -2
- package/network/network-manager.cjs +1 -1
- package/network/network-manager.js +1 -1
- package/network/persistent-connection.cjs +6 -4
- package/network/persistent-connection.js +6 -4
- package/network/session-connection.cjs +14 -7
- package/network/session-connection.d.cts +1 -1
- package/network/session-connection.d.ts +1 -1
- package/network/session-connection.js +15 -8
- package/package.json +4 -4
- package/storage/memory/repository/peers.cjs +2 -2
- package/storage/memory/repository/peers.d.cts +1 -1
- package/storage/memory/repository/peers.d.ts +1 -1
- package/storage/memory/repository/peers.js +2 -2
- package/storage/sqlite/repository/peers.cjs +3 -5
- package/storage/sqlite/repository/peers.d.cts +1 -2
- package/storage/sqlite/repository/peers.d.ts +1 -2
- package/storage/sqlite/repository/peers.js +3 -5
- package/utils/binary/asn1-parser.js +1 -1
- package/utils/binary/compat.cjs +150 -0
- package/utils/binary/compat.d.cts +13 -0
- package/utils/binary/compat.d.ts +13 -0
- package/utils/binary/compat.js +145 -0
- package/utils/binary/compat.test.d.cts +1 -0
- package/utils/binary/compat.test.d.ts +1 -0
- package/utils/binary/serialization.cjs +59 -0
- package/utils/binary/serialization.d.cts +10 -0
- package/utils/binary/serialization.d.ts +10 -0
- package/utils/binary/serialization.js +54 -0
- package/utils/index.d.cts +2 -0
- package/utils/index.d.ts +2 -0
- package/utils/long-utils.js +1 -1
- package/utils/peer-utils.js +1 -1
- package/utils.cjs +8 -0
- package/utils.js +8 -0
- package/highlevel/methods/premium/get-star-gifts.d.cts +0 -23
- package/highlevel/methods/premium/get-star-gifts.d.ts +0 -23
- package/highlevel/methods/premium/get-star-gifts.js +0 -10
- package/highlevel/methods/premium/iter-star-gifts.cjs +0 -29
- package/highlevel/methods/premium/iter-star-gifts.d.cts +0 -26
- package/highlevel/methods/premium/iter-star-gifts.d.ts +0 -26
- package/highlevel/methods/premium/iter-star-gifts.js +0 -24
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
|
|
2
|
+
globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
|
|
3
|
+
console.warn("[@mtcute/core] CommonJS support is deprecated and will be removed in 0.25.0. 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 utils = require("@fuman/utils");
|
|
9
|
+
const webPage = require("../../types/media/web-page.cjs");
|
|
10
|
+
const normalizeText = require("../misc/normalize-text.cjs");
|
|
11
|
+
async function getWebPagePreview(client, text) {
|
|
12
|
+
const [message, entities] = await normalizeText._normalizeInputText(client, text);
|
|
13
|
+
const res = await client.call({
|
|
14
|
+
_: "messages.getWebPagePreview",
|
|
15
|
+
message,
|
|
16
|
+
entities
|
|
17
|
+
});
|
|
18
|
+
if (res.media._ === "messageMediaEmpty") return null;
|
|
19
|
+
utils.assert(res.media._ === "messageMediaWebPage");
|
|
20
|
+
return new webPage.WebPageMedia(res.media);
|
|
21
|
+
}
|
|
22
|
+
exports.getWebPagePreview = getWebPagePreview;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputText } from '../../types/misc/entities.js';
|
|
3
|
+
import { WebPageMedia } from '../../types/media/web-page.js';
|
|
4
|
+
/**
|
|
5
|
+
* Get a preview of a web page contained in the message
|
|
6
|
+
*
|
|
7
|
+
* @param text Text of the message, or simply the link for which the preview should be retrieved
|
|
8
|
+
*/
|
|
9
|
+
export declare function getWebPagePreview(client: ITelegramClient, text: InputText): Promise<WebPageMedia | null>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputText } from '../../types/misc/entities.js';
|
|
3
|
+
import { WebPageMedia } from '../../types/media/web-page.js';
|
|
4
|
+
/**
|
|
5
|
+
* Get a preview of a web page contained in the message
|
|
6
|
+
*
|
|
7
|
+
* @param text Text of the message, or simply the link for which the preview should be retrieved
|
|
8
|
+
*/
|
|
9
|
+
export declare function getWebPagePreview(client: ITelegramClient, text: InputText): Promise<WebPageMedia | null>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { assert } from "@fuman/utils";
|
|
2
|
+
import { WebPageMedia as WebPageMedia$2 } from "../../types/media/web-page.js";
|
|
3
|
+
import { _normalizeInputText } from "../misc/normalize-text.js";
|
|
4
|
+
async function getWebPagePreview(client, text) {
|
|
5
|
+
const [message, entities] = await _normalizeInputText(client, text);
|
|
6
|
+
const res = await client.call({
|
|
7
|
+
_: "messages.getWebPagePreview",
|
|
8
|
+
message,
|
|
9
|
+
entities
|
|
10
|
+
});
|
|
11
|
+
if (res.media._ === "messageMediaEmpty") return null;
|
|
12
|
+
assert(res.media._ === "messageMediaWebPage");
|
|
13
|
+
return new WebPageMedia$2(res.media);
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
getWebPagePreview
|
|
17
|
+
};
|
|
@@ -98,6 +98,11 @@ export interface CommonSendParams {
|
|
|
98
98
|
* The Stars will be withdrawn from the bot's balance.
|
|
99
99
|
*/
|
|
100
100
|
allowPaidFloodskip?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Whether to allow payment for messages.
|
|
103
|
+
* If set, the value represents the maximum number of stars to be paid
|
|
104
|
+
*/
|
|
105
|
+
allowPaidMessages?: tl.Long;
|
|
101
106
|
/**
|
|
102
107
|
* ID of a message effect to use when sending the message
|
|
103
108
|
* (see {@link TelegramClient.getAvailableMessageEffects})
|
|
@@ -98,6 +98,11 @@ export interface CommonSendParams {
|
|
|
98
98
|
* The Stars will be withdrawn from the bot's balance.
|
|
99
99
|
*/
|
|
100
100
|
allowPaidFloodskip?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Whether to allow payment for messages.
|
|
103
|
+
* If set, the value represents the maximum number of stars to be paid
|
|
104
|
+
*/
|
|
105
|
+
allowPaidMessages?: tl.Long;
|
|
101
106
|
/**
|
|
102
107
|
* ID of a message effect to use when sending the message
|
|
103
108
|
* (see {@link TelegramClient.getAvailableMessageEffects})
|
|
@@ -73,7 +73,8 @@ async function sendMediaGroup(client, chatId, medias, params) {
|
|
|
73
73
|
invertMedia: params.invertMedia,
|
|
74
74
|
quickReplyShortcut,
|
|
75
75
|
effect: params.effect,
|
|
76
|
-
allowPaidFloodskip: params.allowPaidFloodskip
|
|
76
|
+
allowPaidFloodskip: params.allowPaidFloodskip,
|
|
77
|
+
allowPaidStars: params.allowPaidMessages
|
|
77
78
|
},
|
|
78
79
|
{ chainId }
|
|
79
80
|
);
|
|
@@ -66,7 +66,8 @@ async function sendMediaGroup(client, chatId, medias, params) {
|
|
|
66
66
|
invertMedia: params.invertMedia,
|
|
67
67
|
quickReplyShortcut,
|
|
68
68
|
effect: params.effect,
|
|
69
|
-
allowPaidFloodskip: params.allowPaidFloodskip
|
|
69
|
+
allowPaidFloodskip: params.allowPaidFloodskip,
|
|
70
|
+
allowPaidStars: params.allowPaidMessages
|
|
70
71
|
},
|
|
71
72
|
{ chainId }
|
|
72
73
|
);
|
|
@@ -58,7 +58,8 @@ async function sendMedia(client, chatId, media, params) {
|
|
|
58
58
|
invertMedia: params.invert,
|
|
59
59
|
quickReplyShortcut,
|
|
60
60
|
effect: params.effect,
|
|
61
|
-
allowPaidFloodskip: params.allowPaidFloodskip
|
|
61
|
+
allowPaidFloodskip: params.allowPaidFloodskip,
|
|
62
|
+
allowPaidStars: params.allowPaidMessages
|
|
62
63
|
},
|
|
63
64
|
{ chainId }
|
|
64
65
|
);
|
|
@@ -51,7 +51,8 @@ async function sendMedia(client, chatId, media, params) {
|
|
|
51
51
|
invertMedia: params.invert,
|
|
52
52
|
quickReplyShortcut,
|
|
53
53
|
effect: params.effect,
|
|
54
|
-
allowPaidFloodskip: params.allowPaidFloodskip
|
|
54
|
+
allowPaidFloodskip: params.allowPaidFloodskip,
|
|
55
|
+
allowPaidStars: params.allowPaidMessages
|
|
55
56
|
},
|
|
56
57
|
{ chainId }
|
|
57
58
|
);
|
|
@@ -15,9 +15,15 @@ const inputMessageId = require("../../types/messages/input-message-id.cjs");
|
|
|
15
15
|
const peersIndex = require("../../types/peers/peers-index.cjs");
|
|
16
16
|
const messageReactions = require("../../types/messages/message-reactions.cjs");
|
|
17
17
|
async function sendPaidReaction(client, params) {
|
|
18
|
-
const { anonymous, count = 1 } = params;
|
|
18
|
+
const { anonymous, asPeer, count = 1 } = params;
|
|
19
19
|
const { chatId, message } = inputMessageId.normalizeInputMessageId(params);
|
|
20
20
|
const peer = await resolvePeer.resolvePeer(client, chatId);
|
|
21
|
+
let privacy;
|
|
22
|
+
if (anonymous !== void 0) {
|
|
23
|
+
privacy = { _: anonymous ? "paidReactionPrivacyAnonymous" : "paidReactionPrivacyDefault" };
|
|
24
|
+
} else if (asPeer) {
|
|
25
|
+
privacy = { _: "paidReactionPrivacyPeer", peer: await resolvePeer.resolvePeer(client, asPeer) };
|
|
26
|
+
}
|
|
21
27
|
let res;
|
|
22
28
|
for (let i = 0; i < 3; i++) {
|
|
23
29
|
try {
|
|
@@ -26,7 +32,7 @@ async function sendPaidReaction(client, params) {
|
|
|
26
32
|
peer,
|
|
27
33
|
msgId: message,
|
|
28
34
|
count,
|
|
29
|
-
private:
|
|
35
|
+
private: privacy,
|
|
30
36
|
randomId: await client.getMtprotoMessageId()
|
|
31
37
|
});
|
|
32
38
|
break;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
-
import { InputMessageId, MessageReactions } from '../../types/index.js';
|
|
2
|
+
import { InputMessageId, InputPeerLike, MessageReactions } from '../../types/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Send a paid reaction using Telegram Stars.
|
|
5
5
|
*
|
|
@@ -8,8 +8,14 @@ import { InputMessageId, MessageReactions } from '../../types/index.js';
|
|
|
8
8
|
* The message is normally available for users, but may not be available for bots in PMs.
|
|
9
9
|
*/
|
|
10
10
|
export declare function sendPaidReaction(client: ITelegramClient, params: InputMessageId & {
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Whether to send the reaction anonymously
|
|
13
|
+
*/
|
|
12
14
|
anonymous?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Peer as which to send the reaction, mutually exclusive with `anonymous`
|
|
17
|
+
*/
|
|
18
|
+
asPeer?: InputPeerLike;
|
|
13
19
|
/**
|
|
14
20
|
* Number of reactions to send
|
|
15
21
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
-
import { InputMessageId, MessageReactions } from '../../types/index.js';
|
|
2
|
+
import { InputMessageId, InputPeerLike, MessageReactions } from '../../types/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Send a paid reaction using Telegram Stars.
|
|
5
5
|
*
|
|
@@ -8,8 +8,14 @@ import { InputMessageId, MessageReactions } from '../../types/index.js';
|
|
|
8
8
|
* The message is normally available for users, but may not be available for bots in PMs.
|
|
9
9
|
*/
|
|
10
10
|
export declare function sendPaidReaction(client: ITelegramClient, params: InputMessageId & {
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Whether to send the reaction anonymously
|
|
13
|
+
*/
|
|
12
14
|
anonymous?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Peer as which to send the reaction, mutually exclusive with `anonymous`
|
|
17
|
+
*/
|
|
18
|
+
asPeer?: InputPeerLike;
|
|
13
19
|
/**
|
|
14
20
|
* Number of reactions to send
|
|
15
21
|
*
|
|
@@ -8,9 +8,15 @@ import { normalizeInputMessageId } from "../../types/messages/input-message-id.j
|
|
|
8
8
|
import { PeersIndex } from "../../types/peers/peers-index.js";
|
|
9
9
|
import { MessageReactions as MessageReactions$2 } from "../../types/messages/message-reactions.js";
|
|
10
10
|
async function sendPaidReaction(client, params) {
|
|
11
|
-
const { anonymous, count = 1 } = params;
|
|
11
|
+
const { anonymous, asPeer, count = 1 } = params;
|
|
12
12
|
const { chatId, message } = normalizeInputMessageId(params);
|
|
13
13
|
const peer = await resolvePeer(client, chatId);
|
|
14
|
+
let privacy;
|
|
15
|
+
if (anonymous !== void 0) {
|
|
16
|
+
privacy = { _: anonymous ? "paidReactionPrivacyAnonymous" : "paidReactionPrivacyDefault" };
|
|
17
|
+
} else if (asPeer) {
|
|
18
|
+
privacy = { _: "paidReactionPrivacyPeer", peer: await resolvePeer(client, asPeer) };
|
|
19
|
+
}
|
|
14
20
|
let res;
|
|
15
21
|
for (let i = 0; i < 3; i++) {
|
|
16
22
|
try {
|
|
@@ -19,7 +25,7 @@ async function sendPaidReaction(client, params) {
|
|
|
19
25
|
peer,
|
|
20
26
|
msgId: message,
|
|
21
27
|
count,
|
|
22
|
-
private:
|
|
28
|
+
private: privacy,
|
|
23
29
|
randomId: await client.getMtprotoMessageId()
|
|
24
30
|
});
|
|
25
31
|
break;
|
|
@@ -49,7 +49,8 @@ async function sendText(client, chatId, text, params) {
|
|
|
49
49
|
invertMedia: params.invertMedia,
|
|
50
50
|
quickReplyShortcut,
|
|
51
51
|
effect: params.effect,
|
|
52
|
-
allowPaidFloodskip: params.allowPaidFloodskip
|
|
52
|
+
allowPaidFloodskip: params.allowPaidFloodskip,
|
|
53
|
+
allowPaidStars: params.allowPaidMessages
|
|
53
54
|
},
|
|
54
55
|
{ chainId }
|
|
55
56
|
);
|
|
@@ -42,7 +42,8 @@ async function sendText(client, chatId, text, params) {
|
|
|
42
42
|
invertMedia: params.invertMedia,
|
|
43
43
|
quickReplyShortcut,
|
|
44
44
|
effect: params.effect,
|
|
45
|
-
allowPaidFloodskip: params.allowPaidFloodskip
|
|
45
|
+
allowPaidFloodskip: params.allowPaidFloodskip,
|
|
46
|
+
allowPaidStars: params.allowPaidMessages
|
|
46
47
|
},
|
|
47
48
|
{ chainId }
|
|
48
49
|
);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
|
|
2
|
+
globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
|
|
3
|
+
console.warn("[@mtcute/core] CommonJS support is deprecated and will be removed in 0.25.0. 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 utils = require("@fuman/utils");
|
|
9
|
+
const typeAssertions = require("../../../utils/type-assertions.cjs");
|
|
10
|
+
const resolvePeer = require("../users/resolve-peer.cjs");
|
|
11
|
+
const _normalizeInputStarGift = require("./_normalize-input-star-gift.cjs");
|
|
12
|
+
async function togglePinnedStarGifts(client, params) {
|
|
13
|
+
const gifts = await utils.parallelMap(
|
|
14
|
+
Array.isArray(params.gifts) ? params.gifts : [params.gifts],
|
|
15
|
+
(it) => _normalizeInputStarGift._normalizeInputStarGift(client, it)
|
|
16
|
+
);
|
|
17
|
+
const res = await client.call({
|
|
18
|
+
_: "payments.toggleStarGiftsPinnedToTop",
|
|
19
|
+
stargift: gifts,
|
|
20
|
+
peer: await resolvePeer.resolvePeer(client, params.peer)
|
|
21
|
+
});
|
|
22
|
+
typeAssertions.assertTrue("payments.toggleStarGiftsPinnedToTop", res);
|
|
23
|
+
}
|
|
24
|
+
exports.togglePinnedStarGifts = togglePinnedStarGifts;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputPeerLike } from '../../types/peers/peer.js';
|
|
3
|
+
import { InputStarGift } from '../../types/premium/stars-gift.js';
|
|
4
|
+
import { MaybeArray } from '@fuman/utils';
|
|
5
|
+
/**
|
|
6
|
+
* Toggles whether one or more star gift is pinned to the top of the list
|
|
7
|
+
*/
|
|
8
|
+
export declare function togglePinnedStarGifts(client: ITelegramClient, params: {
|
|
9
|
+
/** One or more gifts to pin */
|
|
10
|
+
gifts: MaybeArray<InputStarGift>;
|
|
11
|
+
/** Peer where the gift is sent */
|
|
12
|
+
peer: InputPeerLike;
|
|
13
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputPeerLike } from '../../types/peers/peer.js';
|
|
3
|
+
import { InputStarGift } from '../../types/premium/stars-gift.js';
|
|
4
|
+
import { MaybeArray } from '@fuman/utils';
|
|
5
|
+
/**
|
|
6
|
+
* Toggles whether one or more star gift is pinned to the top of the list
|
|
7
|
+
*/
|
|
8
|
+
export declare function togglePinnedStarGifts(client: ITelegramClient, params: {
|
|
9
|
+
/** One or more gifts to pin */
|
|
10
|
+
gifts: MaybeArray<InputStarGift>;
|
|
11
|
+
/** Peer where the gift is sent */
|
|
12
|
+
peer: InputPeerLike;
|
|
13
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { parallelMap } from "@fuman/utils";
|
|
2
|
+
import { assertTrue } from "../../../utils/type-assertions.js";
|
|
3
|
+
import { resolvePeer } from "../users/resolve-peer.js";
|
|
4
|
+
import { _normalizeInputStarGift } from "./_normalize-input-star-gift.js";
|
|
5
|
+
async function togglePinnedStarGifts(client, params) {
|
|
6
|
+
const gifts = await parallelMap(
|
|
7
|
+
Array.isArray(params.gifts) ? params.gifts : [params.gifts],
|
|
8
|
+
(it) => _normalizeInputStarGift(client, it)
|
|
9
|
+
);
|
|
10
|
+
const res = await client.call({
|
|
11
|
+
_: "payments.toggleStarGiftsPinnedToTop",
|
|
12
|
+
stargift: gifts,
|
|
13
|
+
peer: await resolvePeer(client, params.peer)
|
|
14
|
+
});
|
|
15
|
+
assertTrue("payments.toggleStarGiftsPinnedToTop", res);
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
togglePinnedStarGifts
|
|
19
|
+
};
|
|
@@ -5,11 +5,15 @@ 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
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const resolvePeer = require("./resolve-peer.cjs");
|
|
9
|
+
const peerSettings = require("../../types/peers/peer-settings.cjs");
|
|
10
|
+
const peersIndex = require("../../types/peers/peers-index.cjs");
|
|
11
|
+
async function getPeerSettings(client, peerId) {
|
|
12
|
+
const res = await client.call({
|
|
13
|
+
_: "messages.getPeerSettings",
|
|
14
|
+
peer: await resolvePeer.resolvePeer(client, peerId)
|
|
13
15
|
});
|
|
16
|
+
const peers = peersIndex.PeersIndex.from(res);
|
|
17
|
+
return new peerSettings.PeerSettings(res.settings, peers);
|
|
14
18
|
}
|
|
15
|
-
exports.
|
|
19
|
+
exports.getPeerSettings = getPeerSettings;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputPeerLike, PeerSettings } from '../../types/index.js';
|
|
3
|
+
/** Get {@link PeerSettings} for a peer */
|
|
4
|
+
export declare function getPeerSettings(client: ITelegramClient, peerId: InputPeerLike): Promise<PeerSettings>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputPeerLike, PeerSettings } from '../../types/index.js';
|
|
3
|
+
/** Get {@link PeerSettings} for a peer */
|
|
4
|
+
export declare function getPeerSettings(client: ITelegramClient, peerId: InputPeerLike): Promise<PeerSettings>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { resolvePeer } from "./resolve-peer.js";
|
|
2
|
+
import { PeerSettings as PeerSettings$2 } from "../../types/peers/peer-settings.js";
|
|
3
|
+
import { PeersIndex } from "../../types/peers/peers-index.js";
|
|
4
|
+
async function getPeerSettings(client, peerId) {
|
|
5
|
+
const res = await client.call({
|
|
6
|
+
_: "messages.getPeerSettings",
|
|
7
|
+
peer: await resolvePeer(client, peerId)
|
|
8
|
+
});
|
|
9
|
+
const peers = PeersIndex.from(res);
|
|
10
|
+
return new PeerSettings$2(res.settings, peers);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
getPeerSettings
|
|
14
|
+
};
|
|
@@ -8,18 +8,18 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
8
8
|
const tl = require("@mtcute/tl");
|
|
9
9
|
const Long = require("long");
|
|
10
10
|
const errors$1 = require("../../../types/errors.cjs");
|
|
11
|
-
const peerUtils
|
|
11
|
+
const peerUtils = require("../../../utils/peer-utils.cjs");
|
|
12
12
|
const errors = require("../../types/errors.cjs");
|
|
13
|
-
const peerUtils = require("../../utils/peer-utils.cjs");
|
|
13
|
+
const peerUtils$1 = require("../../utils/peer-utils.cjs");
|
|
14
14
|
const batchedQueries = require("../chats/batched-queries.cjs");
|
|
15
15
|
function _normalizePeerId(peerId) {
|
|
16
16
|
if (typeof peerId === "object") {
|
|
17
17
|
if (tl.tl.isAnyPeer(peerId)) {
|
|
18
|
-
peerId = peerUtils
|
|
18
|
+
peerId = peerUtils.getMarkedPeerId(peerId);
|
|
19
19
|
} else if ("inputPeer" in peerId) {
|
|
20
20
|
peerId = peerId.inputPeer;
|
|
21
21
|
} else {
|
|
22
|
-
peerId = peerUtils.toInputPeer(peerId);
|
|
22
|
+
peerId = peerUtils$1.toInputPeer(peerId);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
if (typeof peerId === "object") {
|
|
@@ -27,7 +27,7 @@ function _normalizePeerId(peerId) {
|
|
|
27
27
|
case "mtcute.dummyInputPeerMinUser":
|
|
28
28
|
return peerId.userId;
|
|
29
29
|
case "mtcute.dummyInputPeerMinChannel":
|
|
30
|
-
return peerUtils
|
|
30
|
+
return peerUtils.toggleChannelIdMark(peerId.channelId);
|
|
31
31
|
default:
|
|
32
32
|
return peerId;
|
|
33
33
|
}
|
|
@@ -116,40 +116,25 @@ async function resolvePeer(client, peerId, force = false) {
|
|
|
116
116
|
}
|
|
117
117
|
throw new errors.MtPeerNotFoundError(`Could not find a peer by ${peerId}`);
|
|
118
118
|
}
|
|
119
|
-
const [peerType, bareId] = peerUtils
|
|
120
|
-
if (peerType === "chat"
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
userId: bareId,
|
|
126
|
-
accessHash: Long.ZERO
|
|
127
|
-
};
|
|
128
|
-
case "chat":
|
|
129
|
-
return {
|
|
130
|
-
_: "inputPeerChat",
|
|
131
|
-
chatId: bareId
|
|
132
|
-
};
|
|
133
|
-
case "channel":
|
|
134
|
-
return {
|
|
135
|
-
_: "inputPeerChannel",
|
|
136
|
-
channelId: bareId,
|
|
137
|
-
accessHash: Long.ZERO
|
|
138
|
-
};
|
|
139
|
-
}
|
|
119
|
+
const [peerType, bareId] = peerUtils.parseMarkedPeerId(peerId);
|
|
120
|
+
if (peerType === "chat") {
|
|
121
|
+
return {
|
|
122
|
+
_: "inputPeerChat",
|
|
123
|
+
chatId: bareId
|
|
124
|
+
};
|
|
140
125
|
}
|
|
141
126
|
const cached = await client.storage.peers.getCompleteById(peerId, true);
|
|
142
127
|
if (cached && (cached._ === "channel" || cached._ === "user")) {
|
|
143
|
-
const [username] = peerUtils.extractUsernames(cached);
|
|
128
|
+
const [username] = peerUtils$1.extractUsernames(cached);
|
|
144
129
|
if (username) {
|
|
145
130
|
const resolved = await resolvePeer(client, username, true);
|
|
146
|
-
if (peerUtils
|
|
131
|
+
if (peerUtils.getMarkedPeerId(resolved) === peerId) {
|
|
147
132
|
return resolved;
|
|
148
133
|
}
|
|
149
134
|
}
|
|
150
135
|
if (cached._ === "user" && cached.phone) {
|
|
151
136
|
const resolved = await resolvePeer(client, cached.phone, true);
|
|
152
|
-
if (peerUtils
|
|
137
|
+
if (peerUtils.getMarkedPeerId(resolved) === peerId) {
|
|
153
138
|
return resolved;
|
|
154
139
|
}
|
|
155
140
|
}
|
|
@@ -189,10 +174,10 @@ async function resolvePeer(client, peerId, force = false) {
|
|
|
189
174
|
throw new errors.MtPeerNotFoundError(`Peer ${peerId} is not found in local cache`);
|
|
190
175
|
}
|
|
191
176
|
async function resolveUser(client, peerId, force = false) {
|
|
192
|
-
return peerUtils.toInputUser(await resolvePeer(client, peerId, force), peerId);
|
|
177
|
+
return peerUtils$1.toInputUser(await resolvePeer(client, peerId, force), peerId);
|
|
193
178
|
}
|
|
194
179
|
async function resolveChannel(client, peerId, force = false) {
|
|
195
|
-
return peerUtils.toInputChannel(await resolvePeer(client, peerId, force), peerId);
|
|
180
|
+
return peerUtils$1.toInputChannel(await resolvePeer(client, peerId, force), peerId);
|
|
196
181
|
}
|
|
197
182
|
exports._normalizePeerId = _normalizePeerId;
|
|
198
183
|
exports.resolveChannel = resolveChannel;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { tl } from "@mtcute/tl";
|
|
2
2
|
import Long from "long";
|
|
3
3
|
import { MtTypeAssertionError } from "../../../types/errors.js";
|
|
4
|
-
import { getMarkedPeerId, toggleChannelIdMark
|
|
4
|
+
import { parseMarkedPeerId, getMarkedPeerId, toggleChannelIdMark } from "../../../utils/peer-utils.js";
|
|
5
5
|
import { MtPeerNotFoundError } from "../../types/errors.js";
|
|
6
|
-
import {
|
|
6
|
+
import { extractUsernames, toInputUser, toInputChannel, toInputPeer } from "../../utils/peer-utils.js";
|
|
7
7
|
import { _getChannelsBatched, _getUsersBatched } from "../chats/batched-queries.js";
|
|
8
8
|
function _normalizePeerId(peerId) {
|
|
9
9
|
if (typeof peerId === "object") {
|
|
@@ -110,26 +110,11 @@ async function resolvePeer(client, peerId, force = false) {
|
|
|
110
110
|
throw new MtPeerNotFoundError(`Could not find a peer by ${peerId}`);
|
|
111
111
|
}
|
|
112
112
|
const [peerType, bareId] = parseMarkedPeerId(peerId);
|
|
113
|
-
if (peerType === "chat"
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
userId: bareId,
|
|
119
|
-
accessHash: Long.ZERO
|
|
120
|
-
};
|
|
121
|
-
case "chat":
|
|
122
|
-
return {
|
|
123
|
-
_: "inputPeerChat",
|
|
124
|
-
chatId: bareId
|
|
125
|
-
};
|
|
126
|
-
case "channel":
|
|
127
|
-
return {
|
|
128
|
-
_: "inputPeerChannel",
|
|
129
|
-
channelId: bareId,
|
|
130
|
-
accessHash: Long.ZERO
|
|
131
|
-
};
|
|
132
|
-
}
|
|
113
|
+
if (peerType === "chat") {
|
|
114
|
+
return {
|
|
115
|
+
_: "inputPeerChat",
|
|
116
|
+
chatId: bareId
|
|
117
|
+
};
|
|
133
118
|
}
|
|
134
119
|
const cached = await client.storage.peers.getCompleteById(peerId, true);
|
|
135
120
|
if (cached && (cached._ === "channel" || cached._ === "user")) {
|
package/highlevel/methods.d.cts
CHANGED
|
@@ -156,6 +156,7 @@ export { getReactionUsers } from './methods/messages/get-reaction-users.js';
|
|
|
156
156
|
export type { GetReactionUsersOffset } from './methods/messages/get-reaction-users.js';
|
|
157
157
|
export { getReplyTo } from './methods/messages/get-reply-to.js';
|
|
158
158
|
export { getScheduledMessages } from './methods/messages/get-scheduled-messages.js';
|
|
159
|
+
export { getWebPagePreview } from './methods/messages/get-web-page-preview.js';
|
|
159
160
|
export { iterHistory } from './methods/messages/iter-history.js';
|
|
160
161
|
export { iterReactionUsers } from './methods/messages/iter-reaction-users.js';
|
|
161
162
|
export { iterSearchGlobal } from './methods/messages/iter-search-global.js';
|
|
@@ -226,13 +227,12 @@ export { getSavedStarGiftsById } from './methods/premium/get-saved-star-gifts-by
|
|
|
226
227
|
export { getSavedStarGifts } from './methods/premium/get-saved-star-gifts.js';
|
|
227
228
|
export { getStarGiftOptions } from './methods/premium/get-star-gift-options.js';
|
|
228
229
|
export { getStarGiftWithdrawalUrl } from './methods/premium/get-star-gift-withdrawal-url.js';
|
|
229
|
-
export { getStarGifts } from './methods/premium/get-star-gifts.js';
|
|
230
230
|
export { getStarsTransactions } from './methods/premium/get-stars-transactions.js';
|
|
231
231
|
export { getUniqueStarGift } from './methods/premium/get-unique-star-gift.js';
|
|
232
232
|
export { iterBoosters } from './methods/premium/iter-boosters.js';
|
|
233
233
|
export { iterSavedStarGifts } from './methods/premium/iter-saved-star-gifts.js';
|
|
234
|
-
export { iterStarGifts } from './methods/premium/iter-star-gifts.js';
|
|
235
234
|
export { iterStarsTransactions } from './methods/premium/iter-stars-transactions.js';
|
|
235
|
+
export { togglePinnedStarGifts } from './methods/premium/pin-star-gift.js';
|
|
236
236
|
export { sendStarGift } from './methods/premium/send-star-gift.js';
|
|
237
237
|
export { setBusinessIntro } from './methods/premium/set-business-intro.js';
|
|
238
238
|
export { setBusinessWorkHours } from './methods/premium/set-business-work-hours.js';
|
|
@@ -279,6 +279,7 @@ export { getCommonChats } from './methods/users/get-common-chats.js';
|
|
|
279
279
|
export { getGlobalTtl } from './methods/users/get-global-ttl.js';
|
|
280
280
|
export { getMe } from './methods/users/get-me.js';
|
|
281
281
|
export { getMyUsername } from './methods/users/get-my-username.js';
|
|
282
|
+
export { getPeerSettings } from './methods/users/get-peer-settings.js';
|
|
282
283
|
export { getProfilePhoto } from './methods/users/get-profile-photo.js';
|
|
283
284
|
export { getProfilePhotos } from './methods/users/get-profile-photos.js';
|
|
284
285
|
export { getUsers } from './methods/users/get-users.js';
|
package/highlevel/methods.d.ts
CHANGED
|
@@ -156,6 +156,7 @@ export { getReactionUsers } from './methods/messages/get-reaction-users.js';
|
|
|
156
156
|
export type { GetReactionUsersOffset } from './methods/messages/get-reaction-users.js';
|
|
157
157
|
export { getReplyTo } from './methods/messages/get-reply-to.js';
|
|
158
158
|
export { getScheduledMessages } from './methods/messages/get-scheduled-messages.js';
|
|
159
|
+
export { getWebPagePreview } from './methods/messages/get-web-page-preview.js';
|
|
159
160
|
export { iterHistory } from './methods/messages/iter-history.js';
|
|
160
161
|
export { iterReactionUsers } from './methods/messages/iter-reaction-users.js';
|
|
161
162
|
export { iterSearchGlobal } from './methods/messages/iter-search-global.js';
|
|
@@ -226,13 +227,12 @@ export { getSavedStarGiftsById } from './methods/premium/get-saved-star-gifts-by
|
|
|
226
227
|
export { getSavedStarGifts } from './methods/premium/get-saved-star-gifts.js';
|
|
227
228
|
export { getStarGiftOptions } from './methods/premium/get-star-gift-options.js';
|
|
228
229
|
export { getStarGiftWithdrawalUrl } from './methods/premium/get-star-gift-withdrawal-url.js';
|
|
229
|
-
export { getStarGifts } from './methods/premium/get-star-gifts.js';
|
|
230
230
|
export { getStarsTransactions } from './methods/premium/get-stars-transactions.js';
|
|
231
231
|
export { getUniqueStarGift } from './methods/premium/get-unique-star-gift.js';
|
|
232
232
|
export { iterBoosters } from './methods/premium/iter-boosters.js';
|
|
233
233
|
export { iterSavedStarGifts } from './methods/premium/iter-saved-star-gifts.js';
|
|
234
|
-
export { iterStarGifts } from './methods/premium/iter-star-gifts.js';
|
|
235
234
|
export { iterStarsTransactions } from './methods/premium/iter-stars-transactions.js';
|
|
235
|
+
export { togglePinnedStarGifts } from './methods/premium/pin-star-gift.js';
|
|
236
236
|
export { sendStarGift } from './methods/premium/send-star-gift.js';
|
|
237
237
|
export { setBusinessIntro } from './methods/premium/set-business-intro.js';
|
|
238
238
|
export { setBusinessWorkHours } from './methods/premium/set-business-work-hours.js';
|
|
@@ -279,6 +279,7 @@ export { getCommonChats } from './methods/users/get-common-chats.js';
|
|
|
279
279
|
export { getGlobalTtl } from './methods/users/get-global-ttl.js';
|
|
280
280
|
export { getMe } from './methods/users/get-me.js';
|
|
281
281
|
export { getMyUsername } from './methods/users/get-my-username.js';
|
|
282
|
+
export { getPeerSettings } from './methods/users/get-peer-settings.js';
|
|
282
283
|
export { getProfilePhoto } from './methods/users/get-profile-photo.js';
|
|
283
284
|
export { getProfilePhotos } from './methods/users/get-profile-photos.js';
|
|
284
285
|
export { getUsers } from './methods/users/get-users.js';
|
|
@@ -26,10 +26,9 @@ export interface IPeersRepository {
|
|
|
26
26
|
store: (peer: IPeersRepository.PeerInfo) => MaybePromise<void>;
|
|
27
27
|
/**
|
|
28
28
|
* Find a peer by their `id`.
|
|
29
|
-
*
|
|
30
|
-
* @param allowMin Whether to allow "min" peers to be returned
|
|
29
|
+
* Should return a "min" peer if one is available.
|
|
31
30
|
*/
|
|
32
|
-
getById: (id: number
|
|
31
|
+
getById: (id: number) => MaybePromise<IPeersRepository.PeerInfo | null>;
|
|
33
32
|
/**
|
|
34
33
|
* Find a peer by their username (where `usernames` includes `username`).
|
|
35
34
|
* Should never return "min" peers
|
|
@@ -26,10 +26,9 @@ export interface IPeersRepository {
|
|
|
26
26
|
store: (peer: IPeersRepository.PeerInfo) => MaybePromise<void>;
|
|
27
27
|
/**
|
|
28
28
|
* Find a peer by their `id`.
|
|
29
|
-
*
|
|
30
|
-
* @param allowMin Whether to allow "min" peers to be returned
|
|
29
|
+
* Should return a "min" peer if one is available.
|
|
31
30
|
*/
|
|
32
|
-
getById: (id: number
|
|
31
|
+
getById: (id: number) => MaybePromise<IPeersRepository.PeerInfo | null>;
|
|
33
32
|
/**
|
|
34
33
|
* Find a peer by their username (where `usernames` includes `username`).
|
|
35
34
|
* Should never return "min" peers
|