@mtcute/core 0.29.7 → 0.30.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/highlevel/client.d.cts +4 -6
- package/highlevel/client.d.ts +4 -6
- package/highlevel/methods/chats/join-chat.cjs +38 -16
- package/highlevel/methods/chats/join-chat.d.cts +20 -6
- package/highlevel/methods/chats/join-chat.d.ts +20 -6
- package/highlevel/methods/chats/join-chat.js +38 -16
- package/highlevel/methods/chats/save-draft.d.cts +4 -1
- package/highlevel/methods/chats/save-draft.d.ts +4 -1
- package/highlevel/methods.d.cts +2 -0
- package/highlevel/methods.d.ts +2 -0
- package/highlevel/storage/service/peers.cjs +1 -0
- package/highlevel/storage/service/peers.js +1 -0
- package/highlevel/types/files/utils.d.cts +1 -1
- package/highlevel/types/files/utils.d.ts +1 -1
- package/highlevel/types/messages/index.d.cts +1 -0
- package/highlevel/types/messages/index.d.ts +1 -0
- package/highlevel/types/messages/message.cjs +5 -0
- package/highlevel/types/messages/message.d.cts +3 -0
- package/highlevel/types/messages/message.d.ts +3 -0
- package/highlevel/types/messages/message.js +5 -0
- package/highlevel/types/messages/rich-message.cjs +50 -0
- package/highlevel/types/messages/rich-message.d.cts +18 -0
- package/highlevel/types/messages/rich-message.d.ts +18 -0
- package/highlevel/types/messages/rich-message.js +45 -0
- package/highlevel/types/peers/full-chat.cjs +6 -0
- package/highlevel/types/peers/full-chat.d.cts +2 -0
- package/highlevel/types/peers/full-chat.d.ts +2 -0
- package/highlevel/types/peers/full-chat.js +6 -0
- package/highlevel/types/peers/user.cjs +4 -0
- package/highlevel/types/peers/user.d.cts +2 -0
- package/highlevel/types/peers/user.d.ts +2 -0
- package/highlevel/types/peers/user.js +4 -0
- package/highlevel/types/updates/user-typing-update.cjs +2 -0
- package/highlevel/types/updates/user-typing-update.js +2 -0
- package/highlevel/updates/manager.cjs +191 -0
- package/highlevel/updates/manager.js +191 -0
- package/highlevel/utils/inspectable.cjs +1 -0
- package/highlevel/utils/inspectable.d.cts +1 -0
- package/highlevel/utils/inspectable.d.ts +1 -0
- package/highlevel/utils/inspectable.js +1 -0
- package/index.cjs +2 -0
- package/index.js +2 -0
- package/network/flood-control.cjs +149 -0
- package/network/flood-control.d.cts +79 -0
- package/network/flood-control.d.ts +79 -0
- package/network/flood-control.js +144 -0
- package/network/flood-control.test.d.cts +1 -0
- package/network/flood-control.test.d.ts +1 -0
- package/network/mtproto-session.cjs +1 -21
- package/network/mtproto-session.d.cts +1 -5
- package/network/mtproto-session.d.ts +1 -5
- package/network/mtproto-session.js +2 -22
- package/network/multi-session-connection.cjs +26 -16
- package/network/multi-session-connection.d.cts +1 -1
- package/network/multi-session-connection.d.ts +1 -1
- package/network/multi-session-connection.js +26 -16
- package/network/multi-session-connection.test.d.cts +1 -0
- package/network/multi-session-connection.test.d.ts +1 -0
- package/network/network-manager.cjs +3 -2
- package/network/network-manager.d.cts +12 -0
- package/network/network-manager.d.ts +12 -0
- package/network/network-manager.js +3 -2
- package/network/persistent-connection.cjs +25 -1
- package/network/persistent-connection.d.cts +5 -0
- package/network/persistent-connection.d.ts +5 -0
- package/network/persistent-connection.js +25 -1
- package/network/session-connection.cjs +5 -10
- package/network/session-connection.d.cts +0 -2
- package/network/session-connection.d.ts +0 -2
- package/network/session-connection.js +5 -10
- package/package.json +1 -1
- package/tl/api-schema.json +1 -1
- package/tl/binary/reader.cjs +176 -26
- package/tl/binary/reader.js +176 -26
- package/tl/binary/writer.cjs +439 -20
- package/tl/binary/writer.js +439 -20
- package/tl/compat/reader.cjs +23 -0
- package/tl/compat/reader.js +23 -0
- package/tl/index.d.cts +414 -14
- package/tl/index.d.ts +414 -14
- package/tl/inner-tl.cjs +20 -8
- package/tl/inner-tl.js +20 -8
- package/utils/binary/compat.cjs +79 -0
- package/utils/binary/compat.js +79 -0
- package/utils/index.d.cts +1 -0
- package/utils/index.d.ts +1 -0
- package/utils/long-utils.cjs +10 -0
- package/utils/long-utils.js +10 -0
- package/utils.cjs +7 -0
- package/utils.js +8 -1
package/highlevel/client.d.cts
CHANGED
|
@@ -6,6 +6,8 @@ import { BaseTelegramClientOptions } from './base.js';
|
|
|
6
6
|
import { ITelegramClient } from './client.types.js';
|
|
7
7
|
import { LogOutResult } from './methods/auth/log-out.js';
|
|
8
8
|
import { CreateGroupResult } from './methods/chats/create-group.js';
|
|
9
|
+
import { JoinChatResult } from './methods/chats/join-chat.js';
|
|
10
|
+
import { DraftMessageInput } from './methods/chats/save-draft.js';
|
|
9
11
|
import { GetForumTopicsOffset, getForumTopics } from './methods/forums/get-forum-topics.js';
|
|
10
12
|
import { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/gifts/get-resale-star-gifts.js';
|
|
11
13
|
import { StarGiftUpgradeOptions } from './methods/gifts/get-star-gift-upgrade-options.js';
|
|
@@ -1399,17 +1401,13 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1399
1401
|
/**
|
|
1400
1402
|
* Join a channel or supergroup
|
|
1401
1403
|
*
|
|
1402
|
-
* When using with invite links, this method may throw RPC error
|
|
1403
|
-
* `INVITE_REQUEST_SENT`, which means that you need to wait for admin approval.
|
|
1404
|
-
* You will get into the chat once they do so.
|
|
1405
|
-
*
|
|
1406
1404
|
* **Available**: 👤 users only
|
|
1407
1405
|
*
|
|
1408
1406
|
* @param chatId
|
|
1409
1407
|
* Chat identifier. Either an invite link (`t.me/joinchat/*`), a username (`@username`)
|
|
1410
1408
|
* or ID of the linked supergroup or channel.
|
|
1411
1409
|
*/
|
|
1412
|
-
joinChat(chatId: InputPeerLike): Promise<
|
|
1410
|
+
joinChat(chatId: InputPeerLike): Promise<JoinChatResult>;
|
|
1413
1411
|
/**
|
|
1414
1412
|
* Kick a user from a chat.
|
|
1415
1413
|
*
|
|
@@ -1517,7 +1515,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1517
1515
|
* @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
|
|
1518
1516
|
* @param draft Draft message, or `null` to delete.
|
|
1519
1517
|
*/
|
|
1520
|
-
saveDraft(chatId: InputPeerLike, draft: null |
|
|
1518
|
+
saveDraft(chatId: InputPeerLike, draft: null | DraftMessageInput): Promise<void>;
|
|
1521
1519
|
/**
|
|
1522
1520
|
* Set peer color and optionally background pattern
|
|
1523
1521
|
* **Available**: 👤 users only
|
package/highlevel/client.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import { BaseTelegramClientOptions } from './base.js';
|
|
|
6
6
|
import { ITelegramClient } from './client.types.js';
|
|
7
7
|
import { LogOutResult } from './methods/auth/log-out.js';
|
|
8
8
|
import { CreateGroupResult } from './methods/chats/create-group.js';
|
|
9
|
+
import { JoinChatResult } from './methods/chats/join-chat.js';
|
|
10
|
+
import { DraftMessageInput } from './methods/chats/save-draft.js';
|
|
9
11
|
import { GetForumTopicsOffset, getForumTopics } from './methods/forums/get-forum-topics.js';
|
|
10
12
|
import { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/gifts/get-resale-star-gifts.js';
|
|
11
13
|
import { StarGiftUpgradeOptions } from './methods/gifts/get-star-gift-upgrade-options.js';
|
|
@@ -1399,17 +1401,13 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1399
1401
|
/**
|
|
1400
1402
|
* Join a channel or supergroup
|
|
1401
1403
|
*
|
|
1402
|
-
* When using with invite links, this method may throw RPC error
|
|
1403
|
-
* `INVITE_REQUEST_SENT`, which means that you need to wait for admin approval.
|
|
1404
|
-
* You will get into the chat once they do so.
|
|
1405
|
-
*
|
|
1406
1404
|
* **Available**: 👤 users only
|
|
1407
1405
|
*
|
|
1408
1406
|
* @param chatId
|
|
1409
1407
|
* Chat identifier. Either an invite link (`t.me/joinchat/*`), a username (`@username`)
|
|
1410
1408
|
* or ID of the linked supergroup or channel.
|
|
1411
1409
|
*/
|
|
1412
|
-
joinChat(chatId: InputPeerLike): Promise<
|
|
1410
|
+
joinChat(chatId: InputPeerLike): Promise<JoinChatResult>;
|
|
1413
1411
|
/**
|
|
1414
1412
|
* Kick a user from a chat.
|
|
1415
1413
|
*
|
|
@@ -1517,7 +1515,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1517
1515
|
* @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
|
|
1518
1516
|
* @param draft Draft message, or `null` to delete.
|
|
1519
1517
|
*/
|
|
1520
|
-
saveDraft(chatId: InputPeerLike, draft: null |
|
|
1518
|
+
saveDraft(chatId: InputPeerLike, draft: null | DraftMessageInput): Promise<void>;
|
|
1521
1519
|
/**
|
|
1522
1520
|
* Set peer color and optionally background pattern
|
|
1523
1521
|
* **Available**: 👤 users only
|
|
@@ -8,26 +8,48 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
8
8
|
const utils = require("../../updates/utils.cjs");
|
|
9
9
|
const peerUtils = require("../../utils/peer-utils.cjs");
|
|
10
10
|
const resolvePeer = require("../users/resolve-peer.cjs");
|
|
11
|
+
const innerTl = require("../../../tl/inner-tl.cjs");
|
|
12
|
+
const peersIndex = require("../../types/peers/peers-index.cjs");
|
|
13
|
+
const user = require("../../types/peers/user.cjs");
|
|
11
14
|
const chat = require("../../types/peers/chat.cjs");
|
|
12
15
|
async function joinChat(client, chatId) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
let res;
|
|
17
|
+
try {
|
|
18
|
+
if (typeof chatId === "string") {
|
|
19
|
+
const m = chatId.match(peerUtils.INVITE_LINK_REGEX);
|
|
20
|
+
if (m) {
|
|
21
|
+
res = await client.call({
|
|
22
|
+
_: "messages.importChatInvite",
|
|
23
|
+
hash: m[1]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!res) {
|
|
28
|
+
res = await client.call({
|
|
29
|
+
_: "channels.joinChannel",
|
|
30
|
+
channel: await resolvePeer.resolveChannel(client, chatId)
|
|
19
31
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
32
|
+
}
|
|
33
|
+
} catch (e) {
|
|
34
|
+
if (innerTl.RpcError.is(e, "INVITE_REQUEST_SENT")) {
|
|
35
|
+
return { status: "request_sent" };
|
|
36
|
+
} else {
|
|
37
|
+
throw e;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
switch (res._) {
|
|
41
|
+
case "messages.chatInviteJoinResultOk":
|
|
42
|
+
utils.assertIsUpdatesGroup("joinChat", res.updates);
|
|
43
|
+
client.handleClientUpdate(res.updates);
|
|
44
|
+
return { status: "ok", chat: new chat.Chat(res.updates.chats[0]) };
|
|
45
|
+
case "messages.chatInviteJoinResultWebView": {
|
|
46
|
+
const peers = peersIndex.PeersIndex.from(res);
|
|
47
|
+
return {
|
|
48
|
+
status: "webview",
|
|
49
|
+
bot: new user.User(peers.user(res.botId)),
|
|
50
|
+
webview: res.webview
|
|
51
|
+
};
|
|
23
52
|
}
|
|
24
53
|
}
|
|
25
|
-
const res = await client.call({
|
|
26
|
-
_: "channels.joinChannel",
|
|
27
|
-
channel: await resolvePeer.resolveChannel(client, chatId)
|
|
28
|
-
});
|
|
29
|
-
utils.assertIsUpdatesGroup("channels.joinChannel", res);
|
|
30
|
-
client.handleClientUpdate(res);
|
|
31
|
-
return new chat.Chat(res.chats[0]);
|
|
32
54
|
}
|
|
33
55
|
exports.joinChat = joinChat;
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
-
import { InputPeerLike, Chat } from '../../types/index.js';
|
|
2
|
+
import { InputPeerLike, Chat, User } from '../../types/index.js';
|
|
3
|
+
import { tl } from '../../../tl/index.js';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* Result of {@link joinChat}
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
* `
|
|
8
|
-
*
|
|
7
|
+
* - `status: 'ok'` - the chat was joined successfully
|
|
8
|
+
* - `status: 'request_sent'` - a join request was sent and needs to be approved by the chat admin
|
|
9
|
+
* - `status: 'webview'` - a guard bot requested you to open a webview before joining the chat
|
|
10
|
+
*/
|
|
11
|
+
export type JoinChatResult = {
|
|
12
|
+
status: 'ok';
|
|
13
|
+
chat: Chat;
|
|
14
|
+
} | {
|
|
15
|
+
status: 'request_sent';
|
|
16
|
+
} | {
|
|
17
|
+
status: 'webview';
|
|
18
|
+
bot: User;
|
|
19
|
+
webview: tl.TypeWebViewResult;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Join a channel or supergroup
|
|
9
23
|
*
|
|
10
24
|
* @param chatId
|
|
11
25
|
* Chat identifier. Either an invite link (`t.me/joinchat/*`), a username (`@username`)
|
|
12
26
|
* or ID of the linked supergroup or channel.
|
|
13
27
|
*/
|
|
14
|
-
export declare function joinChat(client: ITelegramClient, chatId: InputPeerLike): Promise<
|
|
28
|
+
export declare function joinChat(client: ITelegramClient, chatId: InputPeerLike): Promise<JoinChatResult>;
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
-
import { InputPeerLike, Chat } from '../../types/index.js';
|
|
2
|
+
import { InputPeerLike, Chat, User } from '../../types/index.js';
|
|
3
|
+
import { tl } from '../../../tl/index.js';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* Result of {@link joinChat}
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
* `
|
|
8
|
-
*
|
|
7
|
+
* - `status: 'ok'` - the chat was joined successfully
|
|
8
|
+
* - `status: 'request_sent'` - a join request was sent and needs to be approved by the chat admin
|
|
9
|
+
* - `status: 'webview'` - a guard bot requested you to open a webview before joining the chat
|
|
10
|
+
*/
|
|
11
|
+
export type JoinChatResult = {
|
|
12
|
+
status: 'ok';
|
|
13
|
+
chat: Chat;
|
|
14
|
+
} | {
|
|
15
|
+
status: 'request_sent';
|
|
16
|
+
} | {
|
|
17
|
+
status: 'webview';
|
|
18
|
+
bot: User;
|
|
19
|
+
webview: tl.TypeWebViewResult;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Join a channel or supergroup
|
|
9
23
|
*
|
|
10
24
|
* @param chatId
|
|
11
25
|
* Chat identifier. Either an invite link (`t.me/joinchat/*`), a username (`@username`)
|
|
12
26
|
* or ID of the linked supergroup or channel.
|
|
13
27
|
*/
|
|
14
|
-
export declare function joinChat(client: ITelegramClient, chatId: InputPeerLike): Promise<
|
|
28
|
+
export declare function joinChat(client: ITelegramClient, chatId: InputPeerLike): Promise<JoinChatResult>;
|
|
@@ -1,27 +1,49 @@
|
|
|
1
1
|
import { assertIsUpdatesGroup } from "../../updates/utils.js";
|
|
2
2
|
import { INVITE_LINK_REGEX } from "../../utils/peer-utils.js";
|
|
3
3
|
import { resolveChannel } from "../users/resolve-peer.js";
|
|
4
|
+
import { RpcError } from "../../../tl/inner-tl.js";
|
|
5
|
+
import { PeersIndex } from "../../types/peers/peers-index.js";
|
|
6
|
+
import { User as User$2 } from "../../types/peers/user.js";
|
|
4
7
|
import { Chat as Chat$2 } from "../../types/peers/chat.js";
|
|
5
8
|
async function joinChat(client, chatId) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
let res;
|
|
10
|
+
try {
|
|
11
|
+
if (typeof chatId === "string") {
|
|
12
|
+
const m = chatId.match(INVITE_LINK_REGEX);
|
|
13
|
+
if (m) {
|
|
14
|
+
res = await client.call({
|
|
15
|
+
_: "messages.importChatInvite",
|
|
16
|
+
hash: m[1]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (!res) {
|
|
21
|
+
res = await client.call({
|
|
22
|
+
_: "channels.joinChannel",
|
|
23
|
+
channel: await resolveChannel(client, chatId)
|
|
12
24
|
});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
25
|
+
}
|
|
26
|
+
} catch (e) {
|
|
27
|
+
if (RpcError.is(e, "INVITE_REQUEST_SENT")) {
|
|
28
|
+
return { status: "request_sent" };
|
|
29
|
+
} else {
|
|
30
|
+
throw e;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
switch (res._) {
|
|
34
|
+
case "messages.chatInviteJoinResultOk":
|
|
35
|
+
assertIsUpdatesGroup("joinChat", res.updates);
|
|
36
|
+
client.handleClientUpdate(res.updates);
|
|
37
|
+
return { status: "ok", chat: new Chat$2(res.updates.chats[0]) };
|
|
38
|
+
case "messages.chatInviteJoinResultWebView": {
|
|
39
|
+
const peers = PeersIndex.from(res);
|
|
40
|
+
return {
|
|
41
|
+
status: "webview",
|
|
42
|
+
bot: new User$2(peers.user(res.botId)),
|
|
43
|
+
webview: res.webview
|
|
44
|
+
};
|
|
16
45
|
}
|
|
17
46
|
}
|
|
18
|
-
const res = await client.call({
|
|
19
|
-
_: "channels.joinChannel",
|
|
20
|
-
channel: await resolveChannel(client, chatId)
|
|
21
|
-
});
|
|
22
|
-
assertIsUpdatesGroup("channels.joinChannel", res);
|
|
23
|
-
client.handleClientUpdate(res);
|
|
24
|
-
return new Chat$2(res.chats[0]);
|
|
25
47
|
}
|
|
26
48
|
export {
|
|
27
49
|
joinChat
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { tl } from '../../../tl/index.js';
|
|
2
2
|
import { ITelegramClient } from '../../client.types.js';
|
|
3
3
|
import { InputPeerLike } from '../../types/index.js';
|
|
4
|
+
export type DraftMessageInput = Omit<tl.RawDraftMessage, '_' | 'date' | 'richMessage'> & {
|
|
5
|
+
richMessage?: tl.TypeInputRichMessage;
|
|
6
|
+
};
|
|
4
7
|
/**
|
|
5
8
|
* Save or delete a draft message associated with some chat
|
|
6
9
|
*
|
|
7
10
|
* @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
|
|
8
11
|
* @param draft Draft message, or `null` to delete.
|
|
9
12
|
*/
|
|
10
|
-
export declare function saveDraft(client: ITelegramClient, chatId: InputPeerLike, draft: null |
|
|
13
|
+
export declare function saveDraft(client: ITelegramClient, chatId: InputPeerLike, draft: null | DraftMessageInput): Promise<void>;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { tl } from '../../../tl/index.js';
|
|
2
2
|
import { ITelegramClient } from '../../client.types.js';
|
|
3
3
|
import { InputPeerLike } from '../../types/index.js';
|
|
4
|
+
export type DraftMessageInput = Omit<tl.RawDraftMessage, '_' | 'date' | 'richMessage'> & {
|
|
5
|
+
richMessage?: tl.TypeInputRichMessage;
|
|
6
|
+
};
|
|
4
7
|
/**
|
|
5
8
|
* Save or delete a draft message associated with some chat
|
|
6
9
|
*
|
|
7
10
|
* @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
|
|
8
11
|
* @param draft Draft message, or `null` to delete.
|
|
9
12
|
*/
|
|
10
|
-
export declare function saveDraft(client: ITelegramClient, chatId: InputPeerLike, draft: null |
|
|
13
|
+
export declare function saveDraft(client: ITelegramClient, chatId: InputPeerLike, draft: null | DraftMessageInput): Promise<void>;
|
package/highlevel/methods.d.cts
CHANGED
|
@@ -64,6 +64,7 @@ export { getUser } from './methods/chats/get-user.js';
|
|
|
64
64
|
export { iterChatEventLog } from './methods/chats/iter-chat-event-log.js';
|
|
65
65
|
export { iterChatMembers } from './methods/chats/iter-chat-members.js';
|
|
66
66
|
export { joinChat } from './methods/chats/join-chat.js';
|
|
67
|
+
export type { JoinChatResult } from './methods/chats/join-chat.js';
|
|
67
68
|
export { kickChatMember } from './methods/chats/kick-chat-member.js';
|
|
68
69
|
export { leaveChat } from './methods/chats/leave-chat.js';
|
|
69
70
|
export { markChatUnread } from './methods/chats/mark-chat-unread.js';
|
|
@@ -72,6 +73,7 @@ export { closeChat } from './methods/chats/open-chat.js';
|
|
|
72
73
|
export { reorderUsernames } from './methods/chats/reorder-usernames.js';
|
|
73
74
|
export { restrictChatMember } from './methods/chats/restrict-chat-member.js';
|
|
74
75
|
export { saveDraft } from './methods/chats/save-draft.js';
|
|
76
|
+
export type { DraftMessageInput } from './methods/chats/save-draft.js';
|
|
75
77
|
export { setChatColor } from './methods/chats/set-chat-color.js';
|
|
76
78
|
export { setChatDefaultPermissions } from './methods/chats/set-chat-default-permissions.js';
|
|
77
79
|
export { setChatDescription } from './methods/chats/set-chat-description.js';
|
package/highlevel/methods.d.ts
CHANGED
|
@@ -64,6 +64,7 @@ export { getUser } from './methods/chats/get-user.js';
|
|
|
64
64
|
export { iterChatEventLog } from './methods/chats/iter-chat-event-log.js';
|
|
65
65
|
export { iterChatMembers } from './methods/chats/iter-chat-members.js';
|
|
66
66
|
export { joinChat } from './methods/chats/join-chat.js';
|
|
67
|
+
export type { JoinChatResult } from './methods/chats/join-chat.js';
|
|
67
68
|
export { kickChatMember } from './methods/chats/kick-chat-member.js';
|
|
68
69
|
export { leaveChat } from './methods/chats/leave-chat.js';
|
|
69
70
|
export { markChatUnread } from './methods/chats/mark-chat-unread.js';
|
|
@@ -72,6 +73,7 @@ export { closeChat } from './methods/chats/open-chat.js';
|
|
|
72
73
|
export { reorderUsernames } from './methods/chats/reorder-usernames.js';
|
|
73
74
|
export { restrictChatMember } from './methods/chats/restrict-chat-member.js';
|
|
74
75
|
export { saveDraft } from './methods/chats/save-draft.js';
|
|
76
|
+
export type { DraftMessageInput } from './methods/chats/save-draft.js';
|
|
75
77
|
export { setChatColor } from './methods/chats/set-chat-color.js';
|
|
76
78
|
export { setChatDefaultPermissions } from './methods/chats/set-chat-default-permissions.js';
|
|
77
79
|
export { setChatDescription } from './methods/chats/set-chat-description.js';
|
|
@@ -181,6 +181,7 @@ class PeersService extends base.BaseService {
|
|
|
181
181
|
storiesUnavailable: peer.storiesUnavailable,
|
|
182
182
|
contactRequirePremium: peer.contactRequirePremium,
|
|
183
183
|
botBusiness: peer.botBusiness,
|
|
184
|
+
botGuard: peer.botGuard,
|
|
184
185
|
botHasMainApp: peer.botHasMainApp,
|
|
185
186
|
botCanManageBots: peer.botCanManageBots,
|
|
186
187
|
botGuestchat: peer.botGuestchat,
|
|
@@ -174,6 +174,7 @@ class PeersService extends BaseService {
|
|
|
174
174
|
storiesUnavailable: peer.storiesUnavailable,
|
|
175
175
|
contactRequirePremium: peer.contactRequirePremium,
|
|
176
176
|
botBusiness: peer.botBusiness,
|
|
177
|
+
botGuard: peer.botGuard,
|
|
177
178
|
botHasMainApp: peer.botHasMainApp,
|
|
178
179
|
botCanManageBots: peer.botCanManageBots,
|
|
179
180
|
botGuestchat: peer.botGuestchat,
|
|
@@ -18,7 +18,7 @@ import { UploadedFile } from './uploaded-file.js';
|
|
|
18
18
|
* - `Readable` (Node.js/Bun readable stream)
|
|
19
19
|
* - `Response` (from `window.fetch`)
|
|
20
20
|
*/
|
|
21
|
-
export type UploadFileLike = URL | Uint8Array | File | Blob | string | IReadable | AnyToNever<import('node:fs').ReadStream> | AnyToNever<ReadableStream<Uint8Array>> | AnyToNever<NodeJS.ReadableStream> | AnyToNever<Response>;
|
|
21
|
+
export type UploadFileLike = URL | Uint8Array | File | Blob | string | IReadable | AnyToNever<import('node:fs').ReadStream> | AnyToNever<ReadableStream<Uint8Array>> | AnyToNever<NodeJS.ReadableStream> | AnyToNever<Response> | AnyToNever<Deno.FsFile>;
|
|
22
22
|
/**
|
|
23
23
|
* Describes types that can be used as an input
|
|
24
24
|
* to any methods that send media (like {@link TelegramClient.sendPhoto})
|
|
@@ -18,7 +18,7 @@ import { UploadedFile } from './uploaded-file.js';
|
|
|
18
18
|
* - `Readable` (Node.js/Bun readable stream)
|
|
19
19
|
* - `Response` (from `window.fetch`)
|
|
20
20
|
*/
|
|
21
|
-
export type UploadFileLike = URL | Uint8Array | File | Blob | string | IReadable | AnyToNever<import('node:fs').ReadStream> | AnyToNever<ReadableStream<Uint8Array>> | AnyToNever<NodeJS.ReadableStream> | AnyToNever<Response>;
|
|
21
|
+
export type UploadFileLike = URL | Uint8Array | File | Blob | string | IReadable | AnyToNever<import('node:fs').ReadStream> | AnyToNever<ReadableStream<Uint8Array>> | AnyToNever<NodeJS.ReadableStream> | AnyToNever<Response> | AnyToNever<Deno.FsFile>;
|
|
22
22
|
/**
|
|
23
23
|
* Describes types that can be used as an input
|
|
24
24
|
* to any methods that send media (like {@link TelegramClient.sendPhoto})
|
|
@@ -11,5 +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-message.js';
|
|
14
15
|
export * from './search-filters.js';
|
|
15
16
|
export * from './suggested-post.js';
|
|
@@ -11,5 +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-message.js';
|
|
14
15
|
export * from './search-filters.js';
|
|
15
16
|
export * from './suggested-post.js';
|
|
@@ -20,6 +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
24
|
const suggestedPost = require("./suggested-post.cjs");
|
|
24
25
|
const inspectable = require("../../utils/inspectable.cjs");
|
|
25
26
|
const factories = require("../bots/keyboards/factories.cjs");
|
|
@@ -342,6 +343,10 @@ class Message {
|
|
|
342
343
|
}
|
|
343
344
|
return messageMedia._messageMediaFromTl(this._peers, this.raw.media);
|
|
344
345
|
}
|
|
346
|
+
/** If this message is a rich message, its contents. Mutually exclusive with {@link media} and {@link text} */
|
|
347
|
+
get richMessage() {
|
|
348
|
+
return this.raw._ === "message" && this.raw.richMessage !== void 0 ? new richMessage.RichMessage(this.raw.richMessage) : null;
|
|
349
|
+
}
|
|
345
350
|
/**
|
|
346
351
|
* Whether this is a premium media
|
|
347
352
|
* (e.g. >2gb file or fullscreen sticker)
|
|
@@ -12,6 +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
16
|
import { SuggestedPostInfo } from './suggested-post.js';
|
|
16
17
|
/**
|
|
17
18
|
* A Telegram message.
|
|
@@ -216,6 +217,8 @@ export declare class Message {
|
|
|
216
217
|
* For unsupported media types, use `.raw.media` directly.
|
|
217
218
|
*/
|
|
218
219
|
get media(): MessageMedia;
|
|
220
|
+
/** If this message is a rich message, its contents. Mutually exclusive with {@link media} and {@link text} */
|
|
221
|
+
get richMessage(): RichMessage | null;
|
|
219
222
|
/**
|
|
220
223
|
* Whether this is a premium media
|
|
221
224
|
* (e.g. >2gb file or fullscreen sticker)
|
|
@@ -12,6 +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
16
|
import { SuggestedPostInfo } from './suggested-post.js';
|
|
16
17
|
/**
|
|
17
18
|
* A Telegram message.
|
|
@@ -216,6 +217,8 @@ export declare class Message {
|
|
|
216
217
|
* For unsupported media types, use `.raw.media` directly.
|
|
217
218
|
*/
|
|
218
219
|
get media(): MessageMedia;
|
|
220
|
+
/** If this message is a rich message, its contents. Mutually exclusive with {@link media} and {@link text} */
|
|
221
|
+
get richMessage(): RichMessage | null;
|
|
219
222
|
/**
|
|
220
223
|
* Whether this is a premium media
|
|
221
224
|
* (e.g. >2gb file or fullscreen sticker)
|
|
@@ -13,6 +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
17
|
import { SuggestedPostInfo as SuggestedPostInfo$1 } from "./suggested-post.js";
|
|
17
18
|
import { makeInspectable } from "../../utils/inspectable.js";
|
|
18
19
|
import { _rowsTo2d } from "../bots/keyboards/factories.js";
|
|
@@ -335,6 +336,10 @@ class Message {
|
|
|
335
336
|
}
|
|
336
337
|
return _messageMediaFromTl(this._peers, this.raw.media);
|
|
337
338
|
}
|
|
339
|
+
/** If this message is a rich message, its contents. Mutually exclusive with {@link media} and {@link text} */
|
|
340
|
+
get richMessage() {
|
|
341
|
+
return this.raw._ === "message" && this.raw.richMessage !== void 0 ? new RichMessage$2(this.raw.richMessage) : null;
|
|
342
|
+
}
|
|
338
343
|
/**
|
|
339
344
|
* Whether this is a premium media
|
|
340
345
|
* (e.g. >2gb file or fullscreen sticker)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
|
|
2
|
+
globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
|
|
3
|
+
console.warn("[@mtcute/core] CommonJS bundles are deprecated. They will be removed completely in one of the upcoming releases. No support is provided for CommonJS users. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
|
|
4
|
+
console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
|
|
5
|
+
}
|
|
6
|
+
"use strict";
|
|
7
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
+
const longUtils = require("../../../utils/long-utils.cjs");
|
|
9
|
+
const inspectable = require("../../utils/inspectable.cjs");
|
|
10
|
+
const memoize = require("../../utils/memoize.cjs");
|
|
11
|
+
const documentUtils = require("../media/document-utils.cjs");
|
|
12
|
+
const photo = require("../media/photo.cjs");
|
|
13
|
+
class RichMessage {
|
|
14
|
+
constructor(raw) {
|
|
15
|
+
this.raw = raw;
|
|
16
|
+
}
|
|
17
|
+
/** Whether this message is RTL */
|
|
18
|
+
get isRtl() {
|
|
19
|
+
return this.raw.rtl;
|
|
20
|
+
}
|
|
21
|
+
/** Whether this message is partial */
|
|
22
|
+
get isPart() {
|
|
23
|
+
return this.raw.part;
|
|
24
|
+
}
|
|
25
|
+
/** Photos in this message */
|
|
26
|
+
get photos() {
|
|
27
|
+
const map = new longUtils.LongMap();
|
|
28
|
+
for (const photo$1 of this.raw.photos) {
|
|
29
|
+
if (photo$1._ === "photoEmpty") continue;
|
|
30
|
+
map.set(photo$1.id, new photo.Photo(photo$1));
|
|
31
|
+
}
|
|
32
|
+
return map;
|
|
33
|
+
}
|
|
34
|
+
/** Documents (usually videos) in this message */
|
|
35
|
+
get documents() {
|
|
36
|
+
const map = new longUtils.LongMap();
|
|
37
|
+
for (const photo2 of this.raw.documents) {
|
|
38
|
+
if (photo2._ === "documentEmpty") continue;
|
|
39
|
+
map.set(photo2.id, documentUtils.parseDocument(photo2));
|
|
40
|
+
}
|
|
41
|
+
return map;
|
|
42
|
+
}
|
|
43
|
+
/** Blocks in this message */
|
|
44
|
+
get blocks() {
|
|
45
|
+
return this.raw.blocks;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const RichMessage$1 = /* @__PURE__ */ inspectable.makeInspectable(RichMessage);
|
|
49
|
+
const RichMessage$2 = /* @__PURE__ */ memoize.memoizeGetters(RichMessage$1, ["documents", "blocks"]);
|
|
50
|
+
exports.RichMessage = RichMessage$2;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { tl } from '../../../tl/index.js';
|
|
2
|
+
import { ParsedDocument } from '../media/document-utils.js';
|
|
3
|
+
import { LongMap } from '../../../utils/long-utils.js';
|
|
4
|
+
import { Photo } from '../media/photo.js';
|
|
5
|
+
export declare class RichMessage {
|
|
6
|
+
readonly raw: tl.TypeRichMessage;
|
|
7
|
+
constructor(raw: tl.TypeRichMessage);
|
|
8
|
+
/** Whether this message is RTL */
|
|
9
|
+
get isRtl(): boolean;
|
|
10
|
+
/** Whether this message is partial */
|
|
11
|
+
get isPart(): boolean;
|
|
12
|
+
/** Photos in this message */
|
|
13
|
+
get photos(): LongMap<Photo>;
|
|
14
|
+
/** Documents (usually videos) in this message */
|
|
15
|
+
get documents(): LongMap<ParsedDocument>;
|
|
16
|
+
/** Blocks in this message */
|
|
17
|
+
get blocks(): tl.TypePageBlock[];
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { tl } from '../../../tl/index.js';
|
|
2
|
+
import { ParsedDocument } from '../media/document-utils.js';
|
|
3
|
+
import { LongMap } from '../../../utils/long-utils.js';
|
|
4
|
+
import { Photo } from '../media/photo.js';
|
|
5
|
+
export declare class RichMessage {
|
|
6
|
+
readonly raw: tl.TypeRichMessage;
|
|
7
|
+
constructor(raw: tl.TypeRichMessage);
|
|
8
|
+
/** Whether this message is RTL */
|
|
9
|
+
get isRtl(): boolean;
|
|
10
|
+
/** Whether this message is partial */
|
|
11
|
+
get isPart(): boolean;
|
|
12
|
+
/** Photos in this message */
|
|
13
|
+
get photos(): LongMap<Photo>;
|
|
14
|
+
/** Documents (usually videos) in this message */
|
|
15
|
+
get documents(): LongMap<ParsedDocument>;
|
|
16
|
+
/** Blocks in this message */
|
|
17
|
+
get blocks(): tl.TypePageBlock[];
|
|
18
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { LongMap } from "../../../utils/long-utils.js";
|
|
2
|
+
import { makeInspectable } from "../../utils/inspectable.js";
|
|
3
|
+
import { memoizeGetters } from "../../utils/memoize.js";
|
|
4
|
+
import { parseDocument } from "../media/document-utils.js";
|
|
5
|
+
import { Photo as Photo$2 } from "../media/photo.js";
|
|
6
|
+
class RichMessage {
|
|
7
|
+
constructor(raw) {
|
|
8
|
+
this.raw = raw;
|
|
9
|
+
}
|
|
10
|
+
/** Whether this message is RTL */
|
|
11
|
+
get isRtl() {
|
|
12
|
+
return this.raw.rtl;
|
|
13
|
+
}
|
|
14
|
+
/** Whether this message is partial */
|
|
15
|
+
get isPart() {
|
|
16
|
+
return this.raw.part;
|
|
17
|
+
}
|
|
18
|
+
/** Photos in this message */
|
|
19
|
+
get photos() {
|
|
20
|
+
const map = new LongMap();
|
|
21
|
+
for (const photo of this.raw.photos) {
|
|
22
|
+
if (photo._ === "photoEmpty") continue;
|
|
23
|
+
map.set(photo.id, new Photo$2(photo));
|
|
24
|
+
}
|
|
25
|
+
return map;
|
|
26
|
+
}
|
|
27
|
+
/** Documents (usually videos) in this message */
|
|
28
|
+
get documents() {
|
|
29
|
+
const map = new LongMap();
|
|
30
|
+
for (const photo of this.raw.documents) {
|
|
31
|
+
if (photo._ === "documentEmpty") continue;
|
|
32
|
+
map.set(photo.id, parseDocument(photo));
|
|
33
|
+
}
|
|
34
|
+
return map;
|
|
35
|
+
}
|
|
36
|
+
/** Blocks in this message */
|
|
37
|
+
get blocks() {
|
|
38
|
+
return this.raw.blocks;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const RichMessage$1 = /* @__PURE__ */ makeInspectable(RichMessage);
|
|
42
|
+
const RichMessage$2 = /* @__PURE__ */ memoizeGetters(RichMessage$1, ["documents", "blocks"]);
|
|
43
|
+
export {
|
|
44
|
+
RichMessage$2 as RichMessage
|
|
45
|
+
};
|
|
@@ -217,6 +217,11 @@ class FullChat extends chat.Chat {
|
|
|
217
217
|
get botInfo() {
|
|
218
218
|
return this.full._ === "channelFull" ? this.full.botInfo.map((it) => new botInfo.BotInfo(it)) : [];
|
|
219
219
|
}
|
|
220
|
+
/** Bot that approves join requests in this chat, if any */
|
|
221
|
+
get guardBot() {
|
|
222
|
+
if (this.full._ !== "channelFull" || !this.full.guardBotId) return null;
|
|
223
|
+
return new user.User(this.peers.user(this.full.guardBotId));
|
|
224
|
+
}
|
|
220
225
|
/**
|
|
221
226
|
* For supergroups, ID of the basic group from which this supergroup was upgraded,
|
|
222
227
|
* and the identifier of the last message from the original group.
|
|
@@ -321,6 +326,7 @@ const FullChat$1 = /* @__PURE__ */ memoize.memoizeGetters(FullChat, [
|
|
|
321
326
|
"stickerSet",
|
|
322
327
|
"emojiSet",
|
|
323
328
|
"botInfo",
|
|
329
|
+
"guardBot",
|
|
324
330
|
"linkedChat",
|
|
325
331
|
"recentRequesters",
|
|
326
332
|
"stories",
|
|
@@ -117,6 +117,8 @@ export declare class FullChat extends Chat {
|
|
|
117
117
|
get notificationsSettings(): tl.TypePeerNotifySettings | null;
|
|
118
118
|
/** Information about bots in this chat */
|
|
119
119
|
get botInfo(): BotInfo[];
|
|
120
|
+
/** Bot that approves join requests in this chat, if any */
|
|
121
|
+
get guardBot(): User | null;
|
|
120
122
|
/**
|
|
121
123
|
* For supergroups, ID of the basic group from which this supergroup was upgraded,
|
|
122
124
|
* and the identifier of the last message from the original group.
|