@mtcute/core 0.27.9 → 0.28.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 +12 -0
- package/client.js +12 -0
- package/highlevel/base.cjs +2 -0
- package/highlevel/base.js +2 -0
- package/highlevel/client.d.cts +27 -2
- package/highlevel/client.d.ts +27 -2
- package/highlevel/methods/chats/batched-queries.cjs +2 -4
- package/highlevel/methods/chats/batched-queries.d.cts +1 -1
- package/highlevel/methods/chats/batched-queries.d.ts +1 -1
- package/highlevel/methods/chats/batched-queries.js +2 -4
- package/highlevel/methods/chats/get-chats.cjs +27 -0
- package/highlevel/methods/chats/get-chats.d.cts +9 -0
- package/highlevel/methods/chats/get-chats.d.ts +9 -0
- package/highlevel/methods/chats/get-chats.js +22 -0
- package/highlevel/methods/chats/get-chats.test.d.cts +1 -0
- package/highlevel/methods/chats/get-chats.test.d.ts +1 -0
- package/highlevel/methods/chats/get-creator-after-leave.cjs +18 -0
- package/highlevel/methods/chats/get-creator-after-leave.d.cts +9 -0
- package/highlevel/methods/chats/get-creator-after-leave.d.ts +9 -0
- package/highlevel/methods/chats/get-creator-after-leave.js +13 -0
- package/highlevel/methods/chats/get-peers.cjs +16 -0
- package/highlevel/methods/chats/get-peers.d.cts +9 -0
- package/highlevel/methods/chats/get-peers.d.ts +9 -0
- package/highlevel/methods/chats/get-peers.js +11 -0
- package/highlevel/methods/chats/get-peers.test.d.cts +1 -0
- package/highlevel/methods/chats/get-peers.test.d.ts +1 -0
- package/highlevel/methods/contacts/set-contact-note.cjs +2 -0
- package/highlevel/methods/contacts/set-contact-note.js +2 -0
- package/highlevel/methods/files/download-iterable.cjs +17 -6
- package/highlevel/methods/files/download-iterable.js +17 -6
- package/highlevel/methods/gifts/get-resale-star-gifts.cjs +2 -1
- package/highlevel/methods/gifts/get-resale-star-gifts.d.cts +2 -0
- package/highlevel/methods/gifts/get-resale-star-gifts.d.ts +2 -0
- package/highlevel/methods/gifts/get-resale-star-gifts.js +2 -1
- package/highlevel/methods/users/get-users.d.cts +1 -2
- package/highlevel/methods/users/get-users.d.ts +1 -2
- package/highlevel/methods.d.cts +3 -0
- package/highlevel/methods.d.ts +3 -0
- package/highlevel/types/bots/keyboards/factories.cjs +26 -18
- package/highlevel/types/bots/keyboards/factories.d.cts +34 -10
- package/highlevel/types/bots/keyboards/factories.d.ts +34 -10
- package/highlevel/types/bots/keyboards/factories.js +26 -18
- package/highlevel/types/messages/message-action.cjs +18 -0
- package/highlevel/types/messages/message-action.d.cts +20 -1
- package/highlevel/types/messages/message-action.d.ts +20 -1
- package/highlevel/types/messages/message-action.js +18 -0
- package/highlevel/types/peers/chat.cjs +1 -1
- package/highlevel/types/peers/chat.js +1 -1
- package/highlevel/types/peers/peer.cjs +13 -3
- package/highlevel/types/peers/peer.d.cts +4 -0
- package/highlevel/types/peers/peer.d.ts +4 -0
- package/highlevel/types/peers/peer.js +13 -3
- package/highlevel/types/peers/user.cjs +3 -0
- package/highlevel/types/peers/user.d.cts +1 -0
- package/highlevel/types/peers/user.d.ts +1 -0
- package/highlevel/types/peers/user.js +3 -0
- package/highlevel/types/premium/saved-star-gift.cjs +4 -0
- package/highlevel/types/premium/saved-star-gift.d.cts +2 -0
- package/highlevel/types/premium/saved-star-gift.d.ts +2 -0
- package/highlevel/types/premium/saved-star-gift.js +4 -0
- package/highlevel/types/premium/star-gift-unique.cjs +43 -4
- package/highlevel/types/premium/star-gift-unique.d.cts +18 -4
- package/highlevel/types/premium/star-gift-unique.d.ts +18 -4
- package/highlevel/types/premium/star-gift-unique.js +43 -4
- package/highlevel/updates/manager.cjs +2 -0
- package/highlevel/updates/manager.js +2 -0
- package/methods.cjs +6 -0
- package/methods.js +6 -0
- package/network/mtproto-session.cjs +2 -0
- package/network/mtproto-session.js +2 -0
- package/network/network-manager.cjs +1 -1
- package/network/network-manager.js +1 -1
- package/network/session-connection.cjs +2 -0
- package/network/session-connection.js +2 -0
- package/network/transports/intermediate.cjs +2 -0
- package/network/transports/intermediate.js +2 -0
- package/package.json +3 -3
- package/storage/storage.cjs +2 -0
- package/storage/storage.js +2 -0
- package/utils/binary/compat.cjs +106 -4
- package/utils/binary/compat.d.cts +3 -0
- package/utils/binary/compat.d.ts +3 -0
- package/utils/binary/compat.js +107 -5
- package/utils/index.d.cts +2 -0
- package/utils/index.d.ts +2 -0
- package/utils.cjs +11 -0
- package/utils.js +6 -1
package/client.cjs
CHANGED
|
@@ -54,11 +54,14 @@ const getChatMember = require("./highlevel/methods/chats/get-chat-member.cjs");
|
|
|
54
54
|
const getChatMembers = require("./highlevel/methods/chats/get-chat-members.cjs");
|
|
55
55
|
const getChatPreview = require("./highlevel/methods/chats/get-chat-preview.cjs");
|
|
56
56
|
const getChat = require("./highlevel/methods/chats/get-chat.cjs");
|
|
57
|
+
const getChats = require("./highlevel/methods/chats/get-chats.cjs");
|
|
58
|
+
const getCreatorAfterLeave = require("./highlevel/methods/chats/get-creator-after-leave.cjs");
|
|
57
59
|
const getFullChat = require("./highlevel/methods/chats/get-full-chat.cjs");
|
|
58
60
|
const getFullUser = require("./highlevel/methods/chats/get-full-user.cjs");
|
|
59
61
|
const getMessageAuthor = require("./highlevel/methods/chats/get-message-author.cjs");
|
|
60
62
|
const getNearbyChats = require("./highlevel/methods/chats/get-nearby-chats.cjs");
|
|
61
63
|
const getPeer = require("./highlevel/methods/chats/get-peer.cjs");
|
|
64
|
+
const getPeers = require("./highlevel/methods/chats/get-peers.cjs");
|
|
62
65
|
const getSimilarChannels = require("./highlevel/methods/chats/get-similar-channels.cjs");
|
|
63
66
|
const getUser = require("./highlevel/methods/chats/get-user.cjs");
|
|
64
67
|
const iterChatEventLog = require("./highlevel/methods/chats/iter-chat-event-log.cjs");
|
|
@@ -597,6 +600,12 @@ TelegramClient.prototype.getChatPreview = function(...args) {
|
|
|
597
600
|
TelegramClient.prototype.getChat = function(...args) {
|
|
598
601
|
return getChat.getChat(this._client, ...args);
|
|
599
602
|
};
|
|
603
|
+
TelegramClient.prototype.getChats = function(...args) {
|
|
604
|
+
return getChats.getChats(this._client, ...args);
|
|
605
|
+
};
|
|
606
|
+
TelegramClient.prototype.getCreatorAfterLeave = function(...args) {
|
|
607
|
+
return getCreatorAfterLeave.getCreatorAfterLeave(this._client, ...args);
|
|
608
|
+
};
|
|
600
609
|
TelegramClient.prototype.getFullChat = function(...args) {
|
|
601
610
|
return getFullChat.getFullChat(this._client, ...args);
|
|
602
611
|
};
|
|
@@ -612,6 +621,9 @@ TelegramClient.prototype.getNearbyChats = function(...args) {
|
|
|
612
621
|
TelegramClient.prototype.getPeer = function(...args) {
|
|
613
622
|
return getPeer.getPeer(this._client, ...args);
|
|
614
623
|
};
|
|
624
|
+
TelegramClient.prototype.getPeers = function(...args) {
|
|
625
|
+
return getPeers.getPeers(this._client, ...args);
|
|
626
|
+
};
|
|
615
627
|
TelegramClient.prototype.getSimilarChannels = function(...args) {
|
|
616
628
|
return getSimilarChannels.getSimilarChannels(this._client, ...args);
|
|
617
629
|
};
|
package/client.js
CHANGED
|
@@ -47,11 +47,14 @@ import { getChatMember } from "./highlevel/methods/chats/get-chat-member.js";
|
|
|
47
47
|
import { getChatMembers } from "./highlevel/methods/chats/get-chat-members.js";
|
|
48
48
|
import { getChatPreview } from "./highlevel/methods/chats/get-chat-preview.js";
|
|
49
49
|
import { getChat } from "./highlevel/methods/chats/get-chat.js";
|
|
50
|
+
import { getChats } from "./highlevel/methods/chats/get-chats.js";
|
|
51
|
+
import { getCreatorAfterLeave } from "./highlevel/methods/chats/get-creator-after-leave.js";
|
|
50
52
|
import { getFullChat } from "./highlevel/methods/chats/get-full-chat.js";
|
|
51
53
|
import { getFullUser } from "./highlevel/methods/chats/get-full-user.js";
|
|
52
54
|
import { getMessageAuthor } from "./highlevel/methods/chats/get-message-author.js";
|
|
53
55
|
import { getNearbyChats } from "./highlevel/methods/chats/get-nearby-chats.js";
|
|
54
56
|
import { getPeer } from "./highlevel/methods/chats/get-peer.js";
|
|
57
|
+
import { getPeers } from "./highlevel/methods/chats/get-peers.js";
|
|
55
58
|
import { getSimilarChannels } from "./highlevel/methods/chats/get-similar-channels.js";
|
|
56
59
|
import { getUser } from "./highlevel/methods/chats/get-user.js";
|
|
57
60
|
import { iterChatEventLog } from "./highlevel/methods/chats/iter-chat-event-log.js";
|
|
@@ -590,6 +593,12 @@ TelegramClient.prototype.getChatPreview = function(...args) {
|
|
|
590
593
|
TelegramClient.prototype.getChat = function(...args) {
|
|
591
594
|
return getChat(this._client, ...args);
|
|
592
595
|
};
|
|
596
|
+
TelegramClient.prototype.getChats = function(...args) {
|
|
597
|
+
return getChats(this._client, ...args);
|
|
598
|
+
};
|
|
599
|
+
TelegramClient.prototype.getCreatorAfterLeave = function(...args) {
|
|
600
|
+
return getCreatorAfterLeave(this._client, ...args);
|
|
601
|
+
};
|
|
593
602
|
TelegramClient.prototype.getFullChat = function(...args) {
|
|
594
603
|
return getFullChat(this._client, ...args);
|
|
595
604
|
};
|
|
@@ -605,6 +614,9 @@ TelegramClient.prototype.getNearbyChats = function(...args) {
|
|
|
605
614
|
TelegramClient.prototype.getPeer = function(...args) {
|
|
606
615
|
return getPeer(this._client, ...args);
|
|
607
616
|
};
|
|
617
|
+
TelegramClient.prototype.getPeers = function(...args) {
|
|
618
|
+
return getPeers(this._client, ...args);
|
|
619
|
+
};
|
|
608
620
|
TelegramClient.prototype.getSimilarChannels = function(...args) {
|
|
609
621
|
return getSimilarChannels(this._client, ...args);
|
|
610
622
|
};
|
package/highlevel/base.cjs
CHANGED
|
@@ -13,6 +13,8 @@ const functionUtils = require("../utils/function-utils.cjs");
|
|
|
13
13
|
const logger = require("../utils/logger.cjs");
|
|
14
14
|
const typeAssertions = require("../utils/type-assertions.cjs");
|
|
15
15
|
require("@mtcute/tl-runtime");
|
|
16
|
+
require("@mtcute/tl/binary/reader.js");
|
|
17
|
+
require("@mtcute/tl/binary/writer.js");
|
|
16
18
|
const appConfigManager = require("./managers/app-config-manager.cjs");
|
|
17
19
|
const timers = require("./managers/timers.cjs");
|
|
18
20
|
const storage = require("./storage/storage.cjs");
|
package/highlevel/base.js
CHANGED
|
@@ -6,6 +6,8 @@ import { asyncResettable } from "../utils/function-utils.js";
|
|
|
6
6
|
import { LogManager } from "../utils/logger.js";
|
|
7
7
|
import { isTlRpcError } from "../utils/type-assertions.js";
|
|
8
8
|
import "@mtcute/tl-runtime";
|
|
9
|
+
import "@mtcute/tl/binary/reader.js";
|
|
10
|
+
import "@mtcute/tl/binary/writer.js";
|
|
9
11
|
import { AppConfigManager } from "./managers/app-config-manager.js";
|
|
10
12
|
import { TimersManager } from "./managers/timers.js";
|
|
11
13
|
import { TelegramStorageManager } from "./storage/storage.js";
|
package/highlevel/client.d.cts
CHANGED
|
@@ -1258,6 +1258,21 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1258
1258
|
* Use {@link getChatPreview} instead.
|
|
1259
1259
|
*/
|
|
1260
1260
|
getChat(chatId: InputPeerLike): Promise<Chat>;
|
|
1261
|
+
/**
|
|
1262
|
+
* Get basic information about multiple chats.
|
|
1263
|
+
*
|
|
1264
|
+
* **Available**: ✅ both users and bots
|
|
1265
|
+
*
|
|
1266
|
+
* @param chatIds Chat identifiers. Can be ID, username or TL object
|
|
1267
|
+
* @returns The list of chats in the same order as the input
|
|
1268
|
+
*/
|
|
1269
|
+
getChats(chatIds: InputPeerLike[]): Promise<(Chat | null)[]>;
|
|
1270
|
+
/**
|
|
1271
|
+
* Get the user who will be made the creator of the channel/supergroup if you were to leave it.
|
|
1272
|
+
*
|
|
1273
|
+
* You must be the creator of the channel/supergroup to use this method.
|
|
1274
|
+
*/
|
|
1275
|
+
getCreatorAfterLeave(chatId: InputPeerLike): Promise<User | null>;
|
|
1261
1276
|
/**
|
|
1262
1277
|
* Get full information about a chat.
|
|
1263
1278
|
*
|
|
@@ -1289,6 +1304,15 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1289
1304
|
getNearbyChats(latitude: number, longitude: number): Promise<Chat[]>;
|
|
1290
1305
|
/** Shorthand for {@link getChat} and {@link getUser} depending on the type of the peer */
|
|
1291
1306
|
getPeer(peer: InputPeerLike): Promise<Peer>;
|
|
1307
|
+
/**
|
|
1308
|
+
* Get basic information about multiple peers.
|
|
1309
|
+
*
|
|
1310
|
+
* **Available**: ✅ both users and bots
|
|
1311
|
+
*
|
|
1312
|
+
* @param chatIds Chat identifiers. Can be ID, username or TL object
|
|
1313
|
+
* @returns The list of peers in the same order as the input
|
|
1314
|
+
*/
|
|
1315
|
+
getPeers(chatIds: InputPeerLike[]): Promise<(Peer | null)[]>;
|
|
1292
1316
|
/**
|
|
1293
1317
|
* Get channels that are similar to a given channel
|
|
1294
1318
|
*
|
|
@@ -2447,6 +2471,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
2447
2471
|
* - `num`: Sort by its unique number
|
|
2448
2472
|
*/
|
|
2449
2473
|
sort?: 'price' | 'num';
|
|
2474
|
+
/** Whether to filter for options that can be used in a craft */
|
|
2475
|
+
forCraft?: boolean;
|
|
2450
2476
|
/**
|
|
2451
2477
|
* Hash of the `attributes` field, as returned by the server in the first response
|
|
2452
2478
|
*/
|
|
@@ -5167,11 +5193,10 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
5167
5193
|
* Get information about multiple users.
|
|
5168
5194
|
* You can retrieve up to 200 users at once.
|
|
5169
5195
|
*
|
|
5170
|
-
* Note that order is not guaranteed.
|
|
5171
|
-
*
|
|
5172
5196
|
* **Available**: ✅ both users and bots
|
|
5173
5197
|
*
|
|
5174
5198
|
* @param ids Users' identifiers. Can be ID, username, phone number, `"me"`, `"self"` or TL object
|
|
5199
|
+
* @returns The list of users in the same order as the input
|
|
5175
5200
|
*/
|
|
5176
5201
|
getUsers(ids: MaybeArray<InputPeerLike>): Promise<(User | null)[]>;
|
|
5177
5202
|
/**
|
package/highlevel/client.d.ts
CHANGED
|
@@ -1258,6 +1258,21 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1258
1258
|
* Use {@link getChatPreview} instead.
|
|
1259
1259
|
*/
|
|
1260
1260
|
getChat(chatId: InputPeerLike): Promise<Chat>;
|
|
1261
|
+
/**
|
|
1262
|
+
* Get basic information about multiple chats.
|
|
1263
|
+
*
|
|
1264
|
+
* **Available**: ✅ both users and bots
|
|
1265
|
+
*
|
|
1266
|
+
* @param chatIds Chat identifiers. Can be ID, username or TL object
|
|
1267
|
+
* @returns The list of chats in the same order as the input
|
|
1268
|
+
*/
|
|
1269
|
+
getChats(chatIds: InputPeerLike[]): Promise<(Chat | null)[]>;
|
|
1270
|
+
/**
|
|
1271
|
+
* Get the user who will be made the creator of the channel/supergroup if you were to leave it.
|
|
1272
|
+
*
|
|
1273
|
+
* You must be the creator of the channel/supergroup to use this method.
|
|
1274
|
+
*/
|
|
1275
|
+
getCreatorAfterLeave(chatId: InputPeerLike): Promise<User | null>;
|
|
1261
1276
|
/**
|
|
1262
1277
|
* Get full information about a chat.
|
|
1263
1278
|
*
|
|
@@ -1289,6 +1304,15 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1289
1304
|
getNearbyChats(latitude: number, longitude: number): Promise<Chat[]>;
|
|
1290
1305
|
/** Shorthand for {@link getChat} and {@link getUser} depending on the type of the peer */
|
|
1291
1306
|
getPeer(peer: InputPeerLike): Promise<Peer>;
|
|
1307
|
+
/**
|
|
1308
|
+
* Get basic information about multiple peers.
|
|
1309
|
+
*
|
|
1310
|
+
* **Available**: ✅ both users and bots
|
|
1311
|
+
*
|
|
1312
|
+
* @param chatIds Chat identifiers. Can be ID, username or TL object
|
|
1313
|
+
* @returns The list of peers in the same order as the input
|
|
1314
|
+
*/
|
|
1315
|
+
getPeers(chatIds: InputPeerLike[]): Promise<(Peer | null)[]>;
|
|
1292
1316
|
/**
|
|
1293
1317
|
* Get channels that are similar to a given channel
|
|
1294
1318
|
*
|
|
@@ -2447,6 +2471,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
2447
2471
|
* - `num`: Sort by its unique number
|
|
2448
2472
|
*/
|
|
2449
2473
|
sort?: 'price' | 'num';
|
|
2474
|
+
/** Whether to filter for options that can be used in a craft */
|
|
2475
|
+
forCraft?: boolean;
|
|
2450
2476
|
/**
|
|
2451
2477
|
* Hash of the `attributes` field, as returned by the server in the first response
|
|
2452
2478
|
*/
|
|
@@ -5167,11 +5193,10 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
5167
5193
|
* Get information about multiple users.
|
|
5168
5194
|
* You can retrieve up to 200 users at once.
|
|
5169
5195
|
*
|
|
5170
|
-
* Note that order is not guaranteed.
|
|
5171
|
-
*
|
|
5172
5196
|
* **Available**: ✅ both users and bots
|
|
5173
5197
|
*
|
|
5174
5198
|
* @param ids Users' identifiers. Can be ID, username, phone number, `"me"`, `"self"` or TL object
|
|
5199
|
+
* @returns The list of users in the same order as the input
|
|
5175
5200
|
*/
|
|
5176
5201
|
getUsers(ids: MaybeArray<InputPeerLike>): Promise<(User | null)[]>;
|
|
5177
5202
|
/**
|
|
@@ -54,7 +54,7 @@ const _getChatsBatched = queryBatcher.batchedQuery({
|
|
|
54
54
|
fetch: (client, items) => client.call({
|
|
55
55
|
_: "messages.getChats",
|
|
56
56
|
id: items
|
|
57
|
-
}).then((res) => res.chats.filter((it) => it._ === "chat")),
|
|
57
|
+
}).then((res) => res.chats.filter((it) => it._ === "chat" || it._ === "chatForbidden")),
|
|
58
58
|
inputKey: (id) => id,
|
|
59
59
|
outputKey: (item) => item.id,
|
|
60
60
|
maxBatchSize: 50,
|
|
@@ -65,9 +65,7 @@ const _getChannelsBatched = queryBatcher.batchedQuery({
|
|
|
65
65
|
_: "channels.getChannels",
|
|
66
66
|
id: items
|
|
67
67
|
}).then(
|
|
68
|
-
(res) => res.chats.filter(
|
|
69
|
-
(it) => it._ === "channel" || it._ === "channelForbidden"
|
|
70
|
-
)
|
|
68
|
+
(res) => res.chats.filter((it) => it._ === "channel" || it._ === "channelForbidden")
|
|
71
69
|
),
|
|
72
70
|
inputKey: (id) => {
|
|
73
71
|
switch (id._) {
|
|
@@ -4,7 +4,7 @@ import { tl } from '@mtcute/tl';
|
|
|
4
4
|
/** @internal */
|
|
5
5
|
export declare const _getUsersBatched: BatchedQuery<tl.TypeInputUser, tl.TypeUser>;
|
|
6
6
|
/** @internal */
|
|
7
|
-
export declare const _getChatsBatched: BatchedQuery<number, tl.RawChat>;
|
|
7
|
+
export declare const _getChatsBatched: BatchedQuery<number, tl.RawChat | tl.RawChatForbidden>;
|
|
8
8
|
/** @internal */
|
|
9
9
|
export declare const _getChannelsBatched: BatchedQuery<tl.TypeInputChannel, tl.RawChannel | tl.RawChannelForbidden>;
|
|
10
10
|
/** @internal */
|
|
@@ -4,7 +4,7 @@ import { tl } from '@mtcute/tl';
|
|
|
4
4
|
/** @internal */
|
|
5
5
|
export declare const _getUsersBatched: BatchedQuery<tl.TypeInputUser, tl.TypeUser>;
|
|
6
6
|
/** @internal */
|
|
7
|
-
export declare const _getChatsBatched: BatchedQuery<number, tl.RawChat>;
|
|
7
|
+
export declare const _getChatsBatched: BatchedQuery<number, tl.RawChat | tl.RawChatForbidden>;
|
|
8
8
|
/** @internal */
|
|
9
9
|
export declare const _getChannelsBatched: BatchedQuery<tl.TypeInputChannel, tl.RawChannel | tl.RawChannelForbidden>;
|
|
10
10
|
/** @internal */
|
|
@@ -47,7 +47,7 @@ const _getChatsBatched = batchedQuery({
|
|
|
47
47
|
fetch: (client, items) => client.call({
|
|
48
48
|
_: "messages.getChats",
|
|
49
49
|
id: items
|
|
50
|
-
}).then((res) => res.chats.filter((it) => it._ === "chat")),
|
|
50
|
+
}).then((res) => res.chats.filter((it) => it._ === "chat" || it._ === "chatForbidden")),
|
|
51
51
|
inputKey: (id) => id,
|
|
52
52
|
outputKey: (item) => item.id,
|
|
53
53
|
maxBatchSize: 50,
|
|
@@ -58,9 +58,7 @@ const _getChannelsBatched = batchedQuery({
|
|
|
58
58
|
_: "channels.getChannels",
|
|
59
59
|
id: items
|
|
60
60
|
}).then(
|
|
61
|
-
(res) => res.chats.filter(
|
|
62
|
-
(it) => it._ === "channel" || it._ === "channelForbidden"
|
|
63
|
-
)
|
|
61
|
+
(res) => res.chats.filter((it) => it._ === "channel" || it._ === "channelForbidden")
|
|
64
62
|
),
|
|
65
63
|
inputKey: (id) => {
|
|
66
64
|
switch (id._) {
|
|
@@ -0,0 +1,27 @@
|
|
|
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 peerUtils = require("../../utils/peer-utils.cjs");
|
|
9
|
+
const resolvePeerMany = require("../users/resolve-peer-many.cjs");
|
|
10
|
+
const batchedQueries = require("./batched-queries.cjs");
|
|
11
|
+
const errors = require("../../types/errors.cjs");
|
|
12
|
+
const chat = require("../../types/peers/chat.cjs");
|
|
13
|
+
async function getChats(client, chatIds) {
|
|
14
|
+
const inputPeers = await resolvePeerMany.resolvePeerMany(client, chatIds);
|
|
15
|
+
const res = await Promise.all(inputPeers.map((peer) => {
|
|
16
|
+
if (!peer) return null;
|
|
17
|
+
if (peerUtils.isInputPeerChannel(peer)) {
|
|
18
|
+
return batchedQueries._getChannelsBatched(client, peerUtils.toInputChannel(peer));
|
|
19
|
+
} else if (peerUtils.isInputPeerChat(peer)) {
|
|
20
|
+
return batchedQueries._getChatsBatched(client, peer.chatId);
|
|
21
|
+
} else {
|
|
22
|
+
throw new errors.MtInvalidPeerTypeError(peer, "chat or channel");
|
|
23
|
+
}
|
|
24
|
+
}));
|
|
25
|
+
return res.map((it) => it ? new chat.Chat(it) : null);
|
|
26
|
+
}
|
|
27
|
+
exports.getChats = getChats;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputPeerLike, Chat } from '../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Get basic information about multiple chats.
|
|
5
|
+
*
|
|
6
|
+
* @param chatIds Chat identifiers. Can be ID, username or TL object
|
|
7
|
+
* @returns The list of chats in the same order as the input
|
|
8
|
+
*/
|
|
9
|
+
export declare function getChats(client: ITelegramClient, chatIds: InputPeerLike[]): Promise<(Chat | null)[]>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputPeerLike, Chat } from '../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Get basic information about multiple chats.
|
|
5
|
+
*
|
|
6
|
+
* @param chatIds Chat identifiers. Can be ID, username or TL object
|
|
7
|
+
* @returns The list of chats in the same order as the input
|
|
8
|
+
*/
|
|
9
|
+
export declare function getChats(client: ITelegramClient, chatIds: InputPeerLike[]): Promise<(Chat | null)[]>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isInputPeerChannel, toInputChannel, isInputPeerChat } from "../../utils/peer-utils.js";
|
|
2
|
+
import { resolvePeerMany } from "../users/resolve-peer-many.js";
|
|
3
|
+
import { _getChannelsBatched, _getChatsBatched } from "./batched-queries.js";
|
|
4
|
+
import { MtInvalidPeerTypeError } from "../../types/errors.js";
|
|
5
|
+
import { Chat as Chat$2 } from "../../types/peers/chat.js";
|
|
6
|
+
async function getChats(client, chatIds) {
|
|
7
|
+
const inputPeers = await resolvePeerMany(client, chatIds);
|
|
8
|
+
const res = await Promise.all(inputPeers.map((peer) => {
|
|
9
|
+
if (!peer) return null;
|
|
10
|
+
if (isInputPeerChannel(peer)) {
|
|
11
|
+
return _getChannelsBatched(client, toInputChannel(peer));
|
|
12
|
+
} else if (isInputPeerChat(peer)) {
|
|
13
|
+
return _getChatsBatched(client, peer.chatId);
|
|
14
|
+
} else {
|
|
15
|
+
throw new MtInvalidPeerTypeError(peer, "chat or channel");
|
|
16
|
+
}
|
|
17
|
+
}));
|
|
18
|
+
return res.map((it) => it ? new Chat$2(it) : null);
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
getChats
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
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 user = require("../../types/peers/user.cjs");
|
|
9
|
+
const resolvePeer = require("../users/resolve-peer.cjs");
|
|
10
|
+
async function getCreatorAfterLeave(client, chatId) {
|
|
11
|
+
const res = await client.call({
|
|
12
|
+
_: "channels.getFutureCreatorAfterLeave",
|
|
13
|
+
channel: await resolvePeer.resolveChannel(client, chatId)
|
|
14
|
+
});
|
|
15
|
+
if (res._ === "userEmpty") return null;
|
|
16
|
+
return new user.User(res);
|
|
17
|
+
}
|
|
18
|
+
exports.getCreatorAfterLeave = getCreatorAfterLeave;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputPeerLike } from '../../types/peers/peer.js';
|
|
3
|
+
import { User } from '../../types/peers/user.js';
|
|
4
|
+
/**
|
|
5
|
+
* Get the user who will be made the creator of the channel/supergroup if you were to leave it.
|
|
6
|
+
*
|
|
7
|
+
* You must be the creator of the channel/supergroup to use this method.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getCreatorAfterLeave(client: ITelegramClient, chatId: InputPeerLike): Promise<User | null>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputPeerLike } from '../../types/peers/peer.js';
|
|
3
|
+
import { User } from '../../types/peers/user.js';
|
|
4
|
+
/**
|
|
5
|
+
* Get the user who will be made the creator of the channel/supergroup if you were to leave it.
|
|
6
|
+
*
|
|
7
|
+
* You must be the creator of the channel/supergroup to use this method.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getCreatorAfterLeave(client: ITelegramClient, chatId: InputPeerLike): Promise<User | null>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { User as User$2 } from "../../types/peers/user.js";
|
|
2
|
+
import { resolveChannel } from "../users/resolve-peer.js";
|
|
3
|
+
async function getCreatorAfterLeave(client, chatId) {
|
|
4
|
+
const res = await client.call({
|
|
5
|
+
_: "channels.getFutureCreatorAfterLeave",
|
|
6
|
+
channel: await resolveChannel(client, chatId)
|
|
7
|
+
});
|
|
8
|
+
if (res._ === "userEmpty") return null;
|
|
9
|
+
return new User$2(res);
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
getCreatorAfterLeave
|
|
13
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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 resolvePeerMany = require("../users/resolve-peer-many.cjs");
|
|
9
|
+
const batchedQueries = require("./batched-queries.cjs");
|
|
10
|
+
const peer = require("../../types/peers/peer.cjs");
|
|
11
|
+
async function getPeers(client, chatIds) {
|
|
12
|
+
const inputPeers = await resolvePeerMany.resolvePeerMany(client, chatIds);
|
|
13
|
+
const res = await Promise.all(inputPeers.map((peer2) => peer2 ? batchedQueries._getRawPeerBatched(client, peer2) : null));
|
|
14
|
+
return res.map((it) => it ? peer.parsePeer(it) : null);
|
|
15
|
+
}
|
|
16
|
+
exports.getPeers = getPeers;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputPeerLike, Peer } from '../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Get basic information about multiple peers.
|
|
5
|
+
*
|
|
6
|
+
* @param chatIds Chat identifiers. Can be ID, username or TL object
|
|
7
|
+
* @returns The list of peers in the same order as the input
|
|
8
|
+
*/
|
|
9
|
+
export declare function getPeers(client: ITelegramClient, chatIds: InputPeerLike[]): Promise<(Peer | null)[]>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputPeerLike, Peer } from '../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Get basic information about multiple peers.
|
|
5
|
+
*
|
|
6
|
+
* @param chatIds Chat identifiers. Can be ID, username or TL object
|
|
7
|
+
* @returns The list of peers in the same order as the input
|
|
8
|
+
*/
|
|
9
|
+
export declare function getPeers(client: ITelegramClient, chatIds: InputPeerLike[]): Promise<(Peer | null)[]>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { resolvePeerMany } from "../users/resolve-peer-many.js";
|
|
2
|
+
import { _getRawPeerBatched } from "./batched-queries.js";
|
|
3
|
+
import { parsePeer } from "../../types/peers/peer.js";
|
|
4
|
+
async function getPeers(client, chatIds) {
|
|
5
|
+
const inputPeers = await resolvePeerMany(client, chatIds);
|
|
6
|
+
const res = await Promise.all(inputPeers.map((peer) => peer ? _getRawPeerBatched(client, peer) : null));
|
|
7
|
+
return res.map((it) => it ? parsePeer(it) : null);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
getPeers
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,6 +7,8 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
|
|
|
7
7
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
8
|
const typeAssertions = require("../../../utils/type-assertions.cjs");
|
|
9
9
|
require("@mtcute/tl-runtime");
|
|
10
|
+
require("@mtcute/tl/binary/reader.js");
|
|
11
|
+
require("@mtcute/tl/binary/writer.js");
|
|
10
12
|
const resolvePeer = require("../users/resolve-peer.cjs");
|
|
11
13
|
const entities = require("../../types/misc/entities.cjs");
|
|
12
14
|
async function setContactNote(client, userId, note) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { assertTrue } from "../../../utils/type-assertions.js";
|
|
2
2
|
import "@mtcute/tl-runtime";
|
|
3
|
+
import "@mtcute/tl/binary/reader.js";
|
|
4
|
+
import "@mtcute/tl/binary/writer.js";
|
|
3
5
|
import { resolveUser } from "../users/resolve-peer.js";
|
|
4
6
|
import { inputTextToTl } from "../../types/misc/entities.js";
|
|
5
7
|
async function setContactNote(client, userId, note) {
|
|
@@ -18,16 +18,23 @@ const SMALL_FILE_MAX_SIZE = 131072;
|
|
|
18
18
|
const REQUESTS_PER_CONNECTION = 3;
|
|
19
19
|
async function _normalizeFileDownloadLocation(client, input) {
|
|
20
20
|
let location;
|
|
21
|
+
let dcId;
|
|
22
|
+
let fileSize;
|
|
21
23
|
if (input instanceof fileLocation.FileLocation) {
|
|
22
24
|
let locationInner = input.location;
|
|
23
25
|
if (typeof locationInner === "function") {
|
|
24
26
|
locationInner = locationInner();
|
|
25
27
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
if (ArrayBuffer.isView(locationInner)) {
|
|
29
|
+
return {
|
|
30
|
+
location: locationInner,
|
|
31
|
+
dcId: input.dcId,
|
|
32
|
+
fileSize: input.fileSize
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
location = locationInner;
|
|
36
|
+
dcId = input.dcId;
|
|
37
|
+
fileSize = input.fileSize;
|
|
31
38
|
} else if (typeof input === "string") {
|
|
32
39
|
const parsed = fileId.parseFileId(input);
|
|
33
40
|
if (parsed.location._ === "web") {
|
|
@@ -61,7 +68,11 @@ async function _normalizeFileDownloadLocation(client, input) {
|
|
|
61
68
|
};
|
|
62
69
|
}
|
|
63
70
|
}
|
|
64
|
-
return {
|
|
71
|
+
return {
|
|
72
|
+
location,
|
|
73
|
+
dcId,
|
|
74
|
+
fileSize
|
|
75
|
+
};
|
|
65
76
|
}
|
|
66
77
|
async function* downloadAsIterable(client, input, params) {
|
|
67
78
|
const offset = params?.offset ?? 0;
|
|
@@ -11,16 +11,23 @@ const SMALL_FILE_MAX_SIZE = 131072;
|
|
|
11
11
|
const REQUESTS_PER_CONNECTION = 3;
|
|
12
12
|
async function _normalizeFileDownloadLocation(client, input) {
|
|
13
13
|
let location;
|
|
14
|
+
let dcId;
|
|
15
|
+
let fileSize;
|
|
14
16
|
if (input instanceof FileLocation$1) {
|
|
15
17
|
let locationInner = input.location;
|
|
16
18
|
if (typeof locationInner === "function") {
|
|
17
19
|
locationInner = locationInner();
|
|
18
20
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
if (ArrayBuffer.isView(locationInner)) {
|
|
22
|
+
return {
|
|
23
|
+
location: locationInner,
|
|
24
|
+
dcId: input.dcId,
|
|
25
|
+
fileSize: input.fileSize
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
location = locationInner;
|
|
29
|
+
dcId = input.dcId;
|
|
30
|
+
fileSize = input.fileSize;
|
|
24
31
|
} else if (typeof input === "string") {
|
|
25
32
|
const parsed = parseFileId(input);
|
|
26
33
|
if (parsed.location._ === "web") {
|
|
@@ -54,7 +61,11 @@ async function _normalizeFileDownloadLocation(client, input) {
|
|
|
54
61
|
};
|
|
55
62
|
}
|
|
56
63
|
}
|
|
57
|
-
return {
|
|
64
|
+
return {
|
|
65
|
+
location,
|
|
66
|
+
dcId,
|
|
67
|
+
fileSize
|
|
68
|
+
};
|
|
58
69
|
}
|
|
59
70
|
async function* downloadAsIterable(client, input, params) {
|
|
60
71
|
const offset = params?.offset ?? 0;
|
|
@@ -72,7 +72,8 @@ async function getStarGiftResaleOptions(client, params) {
|
|
|
72
72
|
giftId: params.giftId,
|
|
73
73
|
attributes: params.attributes ? _normalizeResaleAttributes(params.attributes) : void 0,
|
|
74
74
|
offset: params.offset ?? "",
|
|
75
|
-
limit: params.limit ?? 100
|
|
75
|
+
limit: params.limit ?? 100,
|
|
76
|
+
forCraft: params.forCraft
|
|
76
77
|
});
|
|
77
78
|
const peers = peersIndex.PeersIndex.from(res);
|
|
78
79
|
const attributes = {
|
|
@@ -32,6 +32,8 @@ export declare function getStarGiftResaleOptions(client: ITelegramClient, params
|
|
|
32
32
|
* - `num`: Sort by its unique number
|
|
33
33
|
*/
|
|
34
34
|
sort?: 'price' | 'num';
|
|
35
|
+
/** Whether to filter for options that can be used in a craft */
|
|
36
|
+
forCraft?: boolean;
|
|
35
37
|
/**
|
|
36
38
|
* Hash of the `attributes` field, as returned by the server in the first response
|
|
37
39
|
*/
|
|
@@ -32,6 +32,8 @@ export declare function getStarGiftResaleOptions(client: ITelegramClient, params
|
|
|
32
32
|
* - `num`: Sort by its unique number
|
|
33
33
|
*/
|
|
34
34
|
sort?: 'price' | 'num';
|
|
35
|
+
/** Whether to filter for options that can be used in a craft */
|
|
36
|
+
forCraft?: boolean;
|
|
35
37
|
/**
|
|
36
38
|
* Hash of the `attributes` field, as returned by the server in the first response
|
|
37
39
|
*/
|
|
@@ -65,7 +65,8 @@ async function getStarGiftResaleOptions(client, params) {
|
|
|
65
65
|
giftId: params.giftId,
|
|
66
66
|
attributes: params.attributes ? _normalizeResaleAttributes(params.attributes) : void 0,
|
|
67
67
|
offset: params.offset ?? "",
|
|
68
|
-
limit: params.limit ?? 100
|
|
68
|
+
limit: params.limit ?? 100,
|
|
69
|
+
forCraft: params.forCraft
|
|
69
70
|
});
|
|
70
71
|
const peers = PeersIndex.from(res);
|
|
71
72
|
const attributes = {
|
|
@@ -5,8 +5,7 @@ import { InputPeerLike, User } from '../../types/index.js';
|
|
|
5
5
|
* Get information about multiple users.
|
|
6
6
|
* You can retrieve up to 200 users at once.
|
|
7
7
|
*
|
|
8
|
-
* Note that order is not guaranteed.
|
|
9
|
-
*
|
|
10
8
|
* @param ids Users' identifiers. Can be ID, username, phone number, `"me"`, `"self"` or TL object
|
|
9
|
+
* @returns The list of users in the same order as the input
|
|
11
10
|
*/
|
|
12
11
|
export declare function getUsers(client: ITelegramClient, ids: MaybeArray<InputPeerLike>): Promise<(User | null)[]>;
|
|
@@ -5,8 +5,7 @@ import { InputPeerLike, User } from '../../types/index.js';
|
|
|
5
5
|
* Get information about multiple users.
|
|
6
6
|
* You can retrieve up to 200 users at once.
|
|
7
7
|
*
|
|
8
|
-
* Note that order is not guaranteed.
|
|
9
|
-
*
|
|
10
8
|
* @param ids Users' identifiers. Can be ID, username, phone number, `"me"`, `"self"` or TL object
|
|
9
|
+
* @returns The list of users in the same order as the input
|
|
11
10
|
*/
|
|
12
11
|
export declare function getUsers(client: ITelegramClient, ids: MaybeArray<InputPeerLike>): Promise<(User | null)[]>;
|