@mtkruto/node 0.1.142 → 0.1.144
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/esm/3_types.d.ts +1 -0
- package/esm/3_types.js +1 -0
- package/esm/4_constants.d.ts +1 -1
- package/esm/4_constants.js +1 -1
- package/esm/client/0_message.js +9 -9
- package/esm/client/0_types.d.ts +1 -0
- package/esm/client/1_bot_info_manager.d.ts +30 -0
- package/esm/client/1_bot_info_manager.js +66 -0
- package/esm/client/1_file_manager.js +1 -1
- package/esm/client/1_network_statistics_manager.d.ts +19 -0
- package/esm/client/1_network_statistics_manager.js +48 -0
- package/esm/client/2_client_plain.js +4 -4
- package/esm/client/2_message_manager.d.ts +11 -2
- package/esm/client/2_message_manager.js +170 -1
- package/esm/client/3_callback_query_manager.js +1 -1
- package/esm/client/3_inline_query_manager.js +2 -1
- package/esm/client/4_client.d.ts +21 -12
- package/esm/client/4_client.js +134 -311
- package/esm/storage/0_storage.js +1 -1
- package/esm/tl/0_tl_raw_reader.js +3 -2
- package/esm/tl/0_tl_raw_writer.js +3 -3
- package/esm/transport/0_obfuscation.js +2 -2
- package/esm/transport/1_transport_abridged.js +1 -1
- package/esm/transport/1_transport_intermediate.js +1 -1
- package/esm/types/0__file_id.js +2 -2
- package/esm/types/0_chat_member_rights.d.ts +3 -0
- package/esm/types/0_chat_member_rights.js +45 -1
- package/esm/types/2_chat_member.d.ts +46 -0
- package/esm/types/2_chat_member.js +89 -0
- package/package.json +1 -1
- package/script/3_types.d.ts +1 -0
- package/script/3_types.js +1 -0
- package/script/4_constants.d.ts +1 -1
- package/script/4_constants.js +1 -1
- package/script/client/0_message.js +9 -9
- package/script/client/0_types.d.ts +1 -0
- package/script/client/1_bot_info_manager.d.ts +30 -0
- package/script/client/1_bot_info_manager.js +70 -0
- package/script/client/1_file_manager.js +1 -1
- package/script/client/1_network_statistics_manager.d.ts +19 -0
- package/script/client/1_network_statistics_manager.js +52 -0
- package/script/client/2_client_plain.js +4 -4
- package/script/client/2_message_manager.d.ts +11 -2
- package/script/client/2_message_manager.js +169 -0
- package/script/client/3_callback_query_manager.js +1 -1
- package/script/client/3_inline_query_manager.js +2 -1
- package/script/client/4_client.d.ts +21 -12
- package/script/client/4_client.js +131 -308
- package/script/storage/0_storage.js +1 -1
- package/script/tl/0_tl_raw_reader.js +3 -2
- package/script/tl/0_tl_raw_writer.js +3 -3
- package/script/transport/0_obfuscation.js +2 -2
- package/script/transport/1_transport_abridged.js +1 -1
- package/script/transport/1_transport_intermediate.js +1 -1
- package/script/types/0__file_id.js +2 -2
- package/script/types/0_chat_member_rights.d.ts +3 -0
- package/script/types/0_chat_member_rights.js +48 -0
- package/script/types/2_chat_member.d.ts +46 -0
- package/script/types/2_chat_member.js +93 -0
package/esm/3_types.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ export * from "./types/1_sticker.js";
|
|
|
47
47
|
export * from "./types/1_user.js";
|
|
48
48
|
export * from "./types/1_video_note.js";
|
|
49
49
|
export * from "./types/1_video.js";
|
|
50
|
+
export * from "./types/2_chat_member.js";
|
|
50
51
|
export * from "./types/2_chosen_inline_result.js";
|
|
51
52
|
export * from "./types/2_game.js";
|
|
52
53
|
export * from "./types/2_inline_keyboard_button.js";
|
package/esm/3_types.js
CHANGED
|
@@ -47,6 +47,7 @@ export * from "./types/1_sticker.js";
|
|
|
47
47
|
export * from "./types/1_user.js";
|
|
48
48
|
export * from "./types/1_video_note.js";
|
|
49
49
|
export * from "./types/1_video.js";
|
|
50
|
+
export * from "./types/2_chat_member.js";
|
|
50
51
|
export * from "./types/2_chosen_inline_result.js";
|
|
51
52
|
export * from "./types/2_game.js";
|
|
52
53
|
export * from "./types/2_inline_keyboard_button.js";
|
package/esm/4_constants.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type PublicKeys = readonly [bigint, [bigint, bigint]][];
|
|
|
4
4
|
export declare const PUBLIC_KEYS: PublicKeys;
|
|
5
5
|
export declare const INITIAL_DC: DC;
|
|
6
6
|
export declare const LAYER = 169;
|
|
7
|
-
export declare const APP_VERSION = "MTKruto 0.1.
|
|
7
|
+
export declare const APP_VERSION = "MTKruto 0.1.144";
|
|
8
8
|
export declare const DEVICE_MODEL: string;
|
|
9
9
|
export declare const LANG_CODE: string;
|
|
10
10
|
export declare const LANG_PACK = "";
|
package/esm/4_constants.js
CHANGED
|
@@ -53,7 +53,7 @@ export const PUBLIC_KEYS = Object.freeze([
|
|
|
53
53
|
]);
|
|
54
54
|
export const INITIAL_DC = "2";
|
|
55
55
|
export const LAYER = 169;
|
|
56
|
-
export const APP_VERSION = "MTKruto 0.1.
|
|
56
|
+
export const APP_VERSION = "MTKruto 0.1.144";
|
|
57
57
|
// @ts-ignore: lib
|
|
58
58
|
export const DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
|
|
59
59
|
export const LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
package/esm/client/0_message.js
CHANGED
|
@@ -39,11 +39,11 @@ export async function encryptMessage(message, authKey, authKeyId, salt, sessionI
|
|
|
39
39
|
payloadWriter.write(encoded);
|
|
40
40
|
payloadWriter.write(new Uint8Array(mod(-(payloadWriter.buffer.length + 12), 16) + 12));
|
|
41
41
|
const payload = payloadWriter.buffer;
|
|
42
|
-
const messageKey = (await sha256(concat(authKey.
|
|
43
|
-
const a = await sha256(concat(messageKey, authKey.
|
|
44
|
-
const b = await sha256(concat(authKey.
|
|
45
|
-
const aesKey = concat(a.
|
|
46
|
-
const aesIV = concat(b.
|
|
42
|
+
const messageKey = (await sha256(concat(authKey.subarray(88, 120), payload))).subarray(8, 24);
|
|
43
|
+
const a = await sha256(concat(messageKey, authKey.subarray(0, 36)));
|
|
44
|
+
const b = await sha256(concat(authKey.subarray(40, 76), messageKey));
|
|
45
|
+
const aesKey = concat(a.subarray(0, 8), b.subarray(8, 24), a.subarray(24, 32));
|
|
46
|
+
const aesIV = concat(b.subarray(0, 8), a.subarray(8, 24), b.subarray(24, 32));
|
|
47
47
|
const messageWriter = new TLWriter();
|
|
48
48
|
messageWriter.writeInt64(authKeyId);
|
|
49
49
|
messageWriter.write(messageKey);
|
|
@@ -55,10 +55,10 @@ export async function decryptMessage(buffer, authKey, authKeyId, _sessionId) {
|
|
|
55
55
|
assertEquals(reader.readInt64(false), authKeyId);
|
|
56
56
|
const messageKey_ = reader.readInt128();
|
|
57
57
|
const messageKey = bufferFromBigInt(messageKey_, 16, true, true);
|
|
58
|
-
const a = await sha256(concat(messageKey, authKey.
|
|
59
|
-
const b = await sha256(concat(authKey.
|
|
60
|
-
const aesKey = concat(a.
|
|
61
|
-
const aesIv = concat(b.
|
|
58
|
+
const a = await sha256(concat(messageKey, authKey.subarray(8, 44)));
|
|
59
|
+
const b = await sha256(concat(authKey.subarray(48, 84), messageKey));
|
|
60
|
+
const aesKey = concat(a.subarray(0, 8), b.subarray(8, 24), a.subarray(24, 32));
|
|
61
|
+
const aesIv = concat(b.subarray(0, 8), a.subarray(8, 24), b.subarray(24, 32));
|
|
62
62
|
const plaintext = ige256Decrypt(reader.buffer, aesKey, aesIv);
|
|
63
63
|
assertEquals(plaintext.buffer.byteLength % 4, 0);
|
|
64
64
|
let plainReader = new TLReader(plaintext);
|
package/esm/client/0_types.d.ts
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BotCommand } from "../3_types.js";
|
|
2
|
+
import { GetMyCommandsParams, SetMyCommandsParams } from "./0_params.js";
|
|
3
|
+
import { C } from "./0_types.js";
|
|
4
|
+
export declare class BotInfoManager {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(c: C);
|
|
7
|
+
setMyDescription(params?: {
|
|
8
|
+
description?: string;
|
|
9
|
+
languageCode?: string;
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
setMyName(params?: {
|
|
12
|
+
name?: string;
|
|
13
|
+
languageCode?: string;
|
|
14
|
+
}): Promise<void>;
|
|
15
|
+
setMyShortDescription(params?: {
|
|
16
|
+
shortDescription?: string;
|
|
17
|
+
languageCode?: string;
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
getMyDescription(params?: {
|
|
20
|
+
languageCode?: string;
|
|
21
|
+
}): Promise<string>;
|
|
22
|
+
getMyName(params?: {
|
|
23
|
+
languageCode?: string;
|
|
24
|
+
}): Promise<string>;
|
|
25
|
+
getMyShortDescription(params?: {
|
|
26
|
+
languageCode?: string;
|
|
27
|
+
}): Promise<string>;
|
|
28
|
+
getMyCommands(params?: GetMyCommandsParams): Promise<BotCommand[]>;
|
|
29
|
+
setMyCommands(commands: BotCommand[], params?: SetMyCommandsParams): Promise<void>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _BotInfoManager_instances, _BotInfoManager_c, _BotInfoManager_setMyInfo, _BotInfoManager_getMyInfo;
|
|
13
|
+
import { types } from "../2_tl.js";
|
|
14
|
+
import { botCommandScopeToTlObject } from "../3_types.js";
|
|
15
|
+
export class BotInfoManager {
|
|
16
|
+
constructor(c) {
|
|
17
|
+
_BotInfoManager_instances.add(this);
|
|
18
|
+
_BotInfoManager_c.set(this, void 0);
|
|
19
|
+
__classPrivateFieldSet(this, _BotInfoManager_c, c, "f");
|
|
20
|
+
}
|
|
21
|
+
async setMyDescription(params) {
|
|
22
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("setMyDescription");
|
|
23
|
+
await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_setMyInfo).call(this, { description: params?.description, lang_code: params?.languageCode ?? "" });
|
|
24
|
+
}
|
|
25
|
+
async setMyName(params) {
|
|
26
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("setMyName");
|
|
27
|
+
await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_setMyInfo).call(this, { name: params?.name, lang_code: params?.languageCode ?? "" });
|
|
28
|
+
}
|
|
29
|
+
async setMyShortDescription(params) {
|
|
30
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("setMyShortDescription");
|
|
31
|
+
await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_setMyInfo).call(this, { about: params?.shortDescription, lang_code: params?.languageCode ?? "" });
|
|
32
|
+
}
|
|
33
|
+
async getMyDescription(params) {
|
|
34
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("getMyDescription");
|
|
35
|
+
return await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_getMyInfo).call(this, params?.languageCode).then((v) => v.description);
|
|
36
|
+
}
|
|
37
|
+
async getMyName(params) {
|
|
38
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("getMyName");
|
|
39
|
+
return await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_getMyInfo).call(this, params?.languageCode).then((v) => v.description);
|
|
40
|
+
}
|
|
41
|
+
async getMyShortDescription(params) {
|
|
42
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("getMyShortDescription");
|
|
43
|
+
return await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_getMyInfo).call(this, params?.languageCode).then((v) => v.about);
|
|
44
|
+
}
|
|
45
|
+
async getMyCommands(params) {
|
|
46
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("getMyCommands");
|
|
47
|
+
const commands_ = await __classPrivateFieldGet(this, _BotInfoManager_c, "f").api.bots.getBotCommands({
|
|
48
|
+
lang_code: params?.languageCode ?? "",
|
|
49
|
+
scope: await botCommandScopeToTlObject(params?.scope ?? { type: "default" }, __classPrivateFieldGet(this, _BotInfoManager_c, "f").getInputPeer),
|
|
50
|
+
});
|
|
51
|
+
return commands_.map((v) => ({ command: v.command, description: v.description }));
|
|
52
|
+
}
|
|
53
|
+
async setMyCommands(commands, params) {
|
|
54
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("setMyCommands");
|
|
55
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").api.bots.setBotCommands({
|
|
56
|
+
commands: commands.map((v) => new types.BotCommand(v)),
|
|
57
|
+
lang_code: params?.languageCode ?? "",
|
|
58
|
+
scope: await botCommandScopeToTlObject(params?.scope ?? { type: "default" }, __classPrivateFieldGet(this, _BotInfoManager_c, "f").getInputPeer),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
_BotInfoManager_c = new WeakMap(), _BotInfoManager_instances = new WeakSet(), _BotInfoManager_setMyInfo = async function _BotInfoManager_setMyInfo(info) {
|
|
63
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").api.bots.setBotInfo({ bot: new types.InputUserSelf(), ...info });
|
|
64
|
+
}, _BotInfoManager_getMyInfo = function _BotInfoManager_getMyInfo(languageCode) {
|
|
65
|
+
return __classPrivateFieldGet(this, _BotInfoManager_c, "f").api.bots.getBotInfo({ bot: new types.InputUserSelf(), lang_code: languageCode ?? "" });
|
|
66
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { C } from "./0_types.js";
|
|
2
|
+
export declare class NetworkStatisticsManager {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(c: C);
|
|
5
|
+
getNetworkStatistics(): Promise<{
|
|
6
|
+
messages: {
|
|
7
|
+
sent: number;
|
|
8
|
+
received: number;
|
|
9
|
+
};
|
|
10
|
+
cdn: {
|
|
11
|
+
sent: number;
|
|
12
|
+
received: number;
|
|
13
|
+
};
|
|
14
|
+
}>;
|
|
15
|
+
getTransportReadWriteCallback(): {
|
|
16
|
+
read: (count: number) => Promise<void>;
|
|
17
|
+
write: (count: number) => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _NetworkStatisticsManager_c;
|
|
13
|
+
export class NetworkStatisticsManager {
|
|
14
|
+
constructor(c) {
|
|
15
|
+
_NetworkStatisticsManager_c.set(this, void 0);
|
|
16
|
+
__classPrivateFieldSet(this, _NetworkStatisticsManager_c, c, "f");
|
|
17
|
+
}
|
|
18
|
+
async getNetworkStatistics() {
|
|
19
|
+
const [messagesRead, messagesWrite, cdnRead, cdnWrite] = await Promise.all([
|
|
20
|
+
__classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").storage.get(["netstat_messages_read"]),
|
|
21
|
+
__classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").storage.get(["netstat_messages_write"]),
|
|
22
|
+
__classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").storage.get(["netstat_cdn_read"]),
|
|
23
|
+
__classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").storage.get(["netstat_cdn_write"]),
|
|
24
|
+
]);
|
|
25
|
+
const messages = {
|
|
26
|
+
sent: Number(messagesWrite || 0),
|
|
27
|
+
received: Number(messagesRead || 0),
|
|
28
|
+
};
|
|
29
|
+
const cdn = {
|
|
30
|
+
sent: Number(cdnWrite || 0),
|
|
31
|
+
received: Number(cdnRead || 0),
|
|
32
|
+
};
|
|
33
|
+
return { messages, cdn };
|
|
34
|
+
}
|
|
35
|
+
getTransportReadWriteCallback() {
|
|
36
|
+
return {
|
|
37
|
+
read: async (count) => {
|
|
38
|
+
const key = __classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").cdn ? "netstat_cdn_read" : "netstat_messages_read";
|
|
39
|
+
await __classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").storage.incr([key], count);
|
|
40
|
+
},
|
|
41
|
+
write: async (count) => {
|
|
42
|
+
const key = __classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").cdn ? "netstat_cdn_write" : "netstat_messages_write";
|
|
43
|
+
await __classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").storage.incr([key], count);
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
_NetworkStatisticsManager_c = new WeakMap();
|
|
@@ -106,8 +106,8 @@ export class ClientPlain extends ClientAbstract {
|
|
|
106
106
|
d("got server_DH_params_ok");
|
|
107
107
|
const newNonce_ = bufferFromBigInt(newNonce, 32, true, true);
|
|
108
108
|
const serverNonce_ = bufferFromBigInt(serverNonce, 16, true, true);
|
|
109
|
-
const tmpAesKey = concat(await sha1(concat(newNonce_, serverNonce_)), (await sha1(concat(serverNonce_, newNonce_))).
|
|
110
|
-
const tmpAesIv = concat((await sha1(concat(serverNonce_, newNonce_))).
|
|
109
|
+
const tmpAesKey = concat(await sha1(concat(newNonce_, serverNonce_)), (await sha1(concat(serverNonce_, newNonce_))).subarray(0, 0 + 12));
|
|
110
|
+
const tmpAesIv = concat((await sha1(concat(serverNonce_, newNonce_))).subarray(12, 12 + 8), await sha1(concat(newNonce_, newNonce_)), newNonce_.subarray(0, 0 + 4));
|
|
111
111
|
const answerWithHash = ige256Decrypt(dhParams.encrypted_answer, tmpAesKey, tmpAesIv);
|
|
112
112
|
const dhInnerData = new TLReader(answerWithHash.slice(20)).readObject();
|
|
113
113
|
assertInstanceOf(dhInnerData, types.Server_DH_inner_data);
|
|
@@ -130,8 +130,8 @@ export class ClientPlain extends ClientAbstract {
|
|
|
130
130
|
const dhGenOk = await this.invoke(new functions.set_client_DH_params({ nonce, server_nonce: serverNonce, encrypted_data: encryptedData }));
|
|
131
131
|
assertInstanceOf(dhGenOk, types.Dh_gen_ok);
|
|
132
132
|
d("got dh_gen_ok");
|
|
133
|
-
const serverNonceSlice = serverNonce_.
|
|
134
|
-
const salt = newNonce_.
|
|
133
|
+
const serverNonceSlice = serverNonce_.subarray(0, 8);
|
|
134
|
+
const salt = newNonce_.subarray(0, 0 + 8).map((v, i) => v ^ serverNonceSlice[i]);
|
|
135
135
|
const authKey_ = modExp(gA, b, dhPrime);
|
|
136
136
|
const authKey = bufferFromBigInt(authKey_, 256, false, false);
|
|
137
137
|
d("auth key created");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { enums, types } from "../2_tl.js";
|
|
2
|
-
import { FileSource, ID, Message, MessageEntity, ParseMode, Reaction, Update, UsernameResolver } from "../3_types.js";
|
|
3
|
-
import { DeleteMessagesParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetHistoryParams, PinMessageParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams } from "./0_params.js";
|
|
2
|
+
import { ChatAction, ChatMember, FileSource, ID, Message, MessageEntity, ParseMode, Reaction, Update, UsernameResolver } from "../3_types.js";
|
|
3
|
+
import { BanChatMemberParams, DeleteMessagesParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetHistoryParams, PinMessageParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams } from "./0_params.js";
|
|
4
4
|
import { AddReactionParams, SetReactionsParams } from "./0_params.js";
|
|
5
5
|
import { C as C_ } from "./0_types.js";
|
|
6
6
|
import { FileManager } from "./1_file_manager.js";
|
|
@@ -48,5 +48,14 @@ export declare class MessageManager {
|
|
|
48
48
|
removeReaction(chatId: number, messageId: number, reaction: Reaction): Promise<void>;
|
|
49
49
|
static canHandleUpdate(update: enums.Update): update is types.UpdateNewMessage | types.UpdateNewChannelMessage | types.UpdateEditMessage | types.UpdateEditChannelMessage | types.UpdateDeleteMessages | types.UpdateDeleteChannelMessages;
|
|
50
50
|
handleUpdate(update: types.UpdateNewMessage | types.UpdateNewChannelMessage | types.UpdateEditMessage | types.UpdateEditChannelMessage | types.UpdateDeleteMessages | types.UpdateDeleteChannelMessages): Promise<Update | null>;
|
|
51
|
+
sendChatAction(chatId: ID, action: ChatAction, params?: {
|
|
52
|
+
messageThreadId?: number;
|
|
53
|
+
}): Promise<void>;
|
|
54
|
+
deleteChatPhoto(chatId: number): Promise<void>;
|
|
55
|
+
setChatPhoto(chatId: number, photo: FileSource, params?: SetChatPhotoParams): Promise<void>;
|
|
56
|
+
banChatMember(chatId: ID, memberId: ID, params?: BanChatMemberParams): Promise<void>;
|
|
57
|
+
unbanChatMember(chatId: ID, memberId: ID): Promise<void>;
|
|
58
|
+
setChatMemberRights(chatId: ID, memberId: ID, params?: SetChatMemberRightsParams): Promise<void>;
|
|
59
|
+
getChatAdministrators(chatId: ID): Promise<ChatMember[]>;
|
|
51
60
|
}
|
|
52
61
|
export {};
|
|
@@ -13,7 +13,7 @@ var _MessageManager_instances, _MessageManager_c, _MessageManager_updatesToMessa
|
|
|
13
13
|
import { contentType, debug } from "../0_deps.js";
|
|
14
14
|
import { getRandomId, toUnixTimestamp, UNREACHABLE } from "../1_utilities.js";
|
|
15
15
|
import { as, getChannelChatId, peerToChatId, types } from "../2_tl.js";
|
|
16
|
-
import { assertMessageType, constructMessage as constructMessage_, FileID, FileType, messageEntityToTlObject, reactionEqual, reactionToTlObject, replyMarkupToTlObject } from "../3_types.js";
|
|
16
|
+
import { assertMessageType, chatMemberRightsToTlObject, constructChatMember, constructMessage as constructMessage_, FileID, FileType, messageEntityToTlObject, reactionEqual, reactionToTlObject, replyMarkupToTlObject } from "../3_types.js";
|
|
17
17
|
import { STICKER_SET_NAME_TTL } from "../4_constants.js";
|
|
18
18
|
import { parseHtml } from "./0_html.js";
|
|
19
19
|
import { getFileContents, isHttpUrl } from "./0_utilities.js";
|
|
@@ -587,6 +587,175 @@ export class MessageManager {
|
|
|
587
587
|
}
|
|
588
588
|
return null;
|
|
589
589
|
}
|
|
590
|
+
async sendChatAction(chatId, action, params) {
|
|
591
|
+
let action_;
|
|
592
|
+
switch (action) {
|
|
593
|
+
case "type":
|
|
594
|
+
action_ = new types.SendMessageTypingAction();
|
|
595
|
+
break;
|
|
596
|
+
case "uploadPhoto":
|
|
597
|
+
action_ = new types.SendMessageUploadPhotoAction({ progress: 0 });
|
|
598
|
+
break;
|
|
599
|
+
case "recordVideo":
|
|
600
|
+
action_ = new types.SendMessageRecordVideoAction();
|
|
601
|
+
break;
|
|
602
|
+
case "uploadVideo":
|
|
603
|
+
action_ = new types.SendMessageRecordVideoAction();
|
|
604
|
+
break;
|
|
605
|
+
case "recordVoice":
|
|
606
|
+
action_ = new types.SendMessageRecordAudioAction();
|
|
607
|
+
break;
|
|
608
|
+
case "uploadAudio":
|
|
609
|
+
action_ = new types.SendMessageUploadAudioAction({ progress: 0 });
|
|
610
|
+
break;
|
|
611
|
+
case "uploadDocument":
|
|
612
|
+
action_ = new types.SendMessageUploadDocumentAction({ progress: 0 });
|
|
613
|
+
break;
|
|
614
|
+
case "chooseSticker":
|
|
615
|
+
action_ = new types.SendMessageChooseStickerAction();
|
|
616
|
+
break;
|
|
617
|
+
case "findLocation":
|
|
618
|
+
action_ = new types.SendMessageGeoLocationAction();
|
|
619
|
+
break;
|
|
620
|
+
case "recordVideoNote":
|
|
621
|
+
action_ = new types.SendMessageRecordRoundAction();
|
|
622
|
+
break;
|
|
623
|
+
case "uploadVideoNote":
|
|
624
|
+
action_ = new types.SendMessageUploadRoundAction({ progress: 0 });
|
|
625
|
+
break;
|
|
626
|
+
default:
|
|
627
|
+
throw new Error("Invalid chat action: " + action);
|
|
628
|
+
}
|
|
629
|
+
await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.setTyping({ peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), action: action_, top_msg_id: params?.messageThreadId });
|
|
630
|
+
}
|
|
631
|
+
async deleteChatPhoto(chatId) {
|
|
632
|
+
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
633
|
+
if (!(peer instanceof types.InputPeerChannel) && !(peer instanceof types.InputPeerChat)) {
|
|
634
|
+
UNREACHABLE();
|
|
635
|
+
}
|
|
636
|
+
if (peer instanceof types.InputPeerChannel) {
|
|
637
|
+
await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.editPhoto({ channel: new types.InputChannel(peer), photo: new types.InputChatPhotoEmpty() });
|
|
638
|
+
}
|
|
639
|
+
else if (peer instanceof types.InputPeerChat) {
|
|
640
|
+
await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.editChatPhoto({ chat_id: peer.chat_id, photo: new types.InputChatPhotoEmpty() });
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
async setChatPhoto(chatId, photo, params) {
|
|
644
|
+
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
645
|
+
if (!(peer instanceof types.InputPeerChannel) && !(peer instanceof types.InputPeerChat)) {
|
|
646
|
+
UNREACHABLE();
|
|
647
|
+
}
|
|
648
|
+
const [contents, fileName] = await getFileContents(photo);
|
|
649
|
+
const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(contents, { fileName: params?.fileName ?? fileName, chunkSize: params?.chunkSize, signal: params?.signal });
|
|
650
|
+
const photo_ = new types.InputChatUploadedPhoto({ file });
|
|
651
|
+
if (peer instanceof types.InputPeerChannel) {
|
|
652
|
+
await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.editPhoto({ channel: new types.InputChannel(peer), photo: photo_ });
|
|
653
|
+
}
|
|
654
|
+
else if (peer instanceof types.InputPeerChat) {
|
|
655
|
+
await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.editChatPhoto({ chat_id: peer.chat_id, photo: photo_ });
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
async banChatMember(chatId, memberId, params) {
|
|
659
|
+
const chat = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
660
|
+
if (!(chat instanceof types.InputPeerChannel) && !(chat instanceof types.InputPeerChat)) {
|
|
661
|
+
throw new Error("Invalid chat ID");
|
|
662
|
+
}
|
|
663
|
+
const member = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(memberId);
|
|
664
|
+
if (chat instanceof types.InputPeerChannel) {
|
|
665
|
+
if (params?.deleteMessages) {
|
|
666
|
+
try {
|
|
667
|
+
await this.deleteChatMemberMessages(chatId, memberId);
|
|
668
|
+
}
|
|
669
|
+
catch {
|
|
670
|
+
//
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.editBanned({
|
|
674
|
+
channel: new types.InputChannel(chat),
|
|
675
|
+
participant: member,
|
|
676
|
+
banned_rights: new types.ChatBannedRights({
|
|
677
|
+
until_date: params?.untilDate ? toUnixTimestamp(params.untilDate) : 0,
|
|
678
|
+
view_messages: true,
|
|
679
|
+
send_messages: true,
|
|
680
|
+
send_media: true,
|
|
681
|
+
send_stickers: true,
|
|
682
|
+
send_gifs: true,
|
|
683
|
+
send_games: true,
|
|
684
|
+
send_inline: true,
|
|
685
|
+
embed_links: true,
|
|
686
|
+
}),
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
else if (chat instanceof types.InputPeerChat) {
|
|
690
|
+
if (!(member instanceof types.InputPeerUser)) {
|
|
691
|
+
throw new Error("Invalid user ID");
|
|
692
|
+
}
|
|
693
|
+
await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.deleteChatUser({
|
|
694
|
+
chat_id: chat.chat_id,
|
|
695
|
+
user_id: new types.InputUser(member),
|
|
696
|
+
revoke_history: params?.deleteMessages ? true : undefined,
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
async unbanChatMember(chatId, memberId) {
|
|
701
|
+
const chat = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
702
|
+
if (!(chat instanceof types.InputPeerChannel)) {
|
|
703
|
+
throw new Error("Invalid chat ID");
|
|
704
|
+
}
|
|
705
|
+
const member = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(memberId);
|
|
706
|
+
await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.editBanned({
|
|
707
|
+
channel: new types.InputChannel(chat),
|
|
708
|
+
participant: member,
|
|
709
|
+
banned_rights: new types.ChatBannedRights({ until_date: 0 }),
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
async setChatMemberRights(chatId, memberId, params) {
|
|
713
|
+
const chat = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
714
|
+
if (!(chat instanceof types.InputPeerChannel)) {
|
|
715
|
+
throw new Error("Invalid chat ID");
|
|
716
|
+
}
|
|
717
|
+
const member = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(memberId);
|
|
718
|
+
await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.editBanned({
|
|
719
|
+
channel: new types.InputChannel(chat),
|
|
720
|
+
participant: member,
|
|
721
|
+
banned_rights: chatMemberRightsToTlObject(params?.rights, params?.untilDate),
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
async getChatAdministrators(chatId) {
|
|
725
|
+
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
726
|
+
if (peer instanceof types.InputPeerChannel) {
|
|
727
|
+
const channel = new types.InputChannel(peer);
|
|
728
|
+
const participants = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.getParticipants({
|
|
729
|
+
channel,
|
|
730
|
+
filter: new types.ChannelParticipantsAdmins(),
|
|
731
|
+
offset: 0,
|
|
732
|
+
limit: 100,
|
|
733
|
+
hash: 0n,
|
|
734
|
+
});
|
|
735
|
+
if (participants instanceof types.channels.ChannelParticipantsNotModified) {
|
|
736
|
+
UNREACHABLE();
|
|
737
|
+
}
|
|
738
|
+
const chatMembers = new Array();
|
|
739
|
+
for (const p of participants.participants) {
|
|
740
|
+
chatMembers.push(await constructChatMember(p, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity));
|
|
741
|
+
}
|
|
742
|
+
return chatMembers;
|
|
743
|
+
}
|
|
744
|
+
else if (peer instanceof types.InputPeerChat) {
|
|
745
|
+
const fullChat = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.getFullChat(peer); // TODO: full chat cache
|
|
746
|
+
if (!(fullChat.full_chat instanceof types.ChatFull) || !(fullChat.full_chat.participants instanceof types.ChatParticipants)) {
|
|
747
|
+
UNREACHABLE();
|
|
748
|
+
}
|
|
749
|
+
const chatMembers = new Array();
|
|
750
|
+
for (const p of fullChat.full_chat.participants.participants) {
|
|
751
|
+
chatMembers.push(await constructChatMember(p, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity));
|
|
752
|
+
}
|
|
753
|
+
return chatMembers;
|
|
754
|
+
}
|
|
755
|
+
else {
|
|
756
|
+
UNREACHABLE();
|
|
757
|
+
}
|
|
758
|
+
}
|
|
590
759
|
}
|
|
591
760
|
_MessageManager_c = new WeakMap(), _MessageManager_instances = new WeakSet(), _MessageManager_updatesToMessages = async function _MessageManager_updatesToMessages(chatId, updates) {
|
|
592
761
|
const messages = new Array();
|
|
@@ -30,7 +30,7 @@ export class CallbackQueryManager {
|
|
|
30
30
|
return update instanceof types.UpdateBotCallbackQuery || update instanceof types.UpdateInlineBotCallbackQuery;
|
|
31
31
|
}
|
|
32
32
|
async handleUpdate(update) {
|
|
33
|
-
return { callbackQuery: await constructCallbackQuery(update, __classPrivateFieldGet(this, _CallbackQueryManager_c, "f").getEntity, __classPrivateFieldGet(this, _CallbackQueryManager_c, "f").messageManager.getMessageWithReply.bind(this)) };
|
|
33
|
+
return { callbackQuery: await constructCallbackQuery(update, __classPrivateFieldGet(this, _CallbackQueryManager_c, "f").getEntity, __classPrivateFieldGet(this, _CallbackQueryManager_c, "f").messageManager.getMessageWithReply.bind(__classPrivateFieldGet(this, _CallbackQueryManager_c, "f").messageManager)) };
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
_CallbackQueryManager_c = new WeakMap();
|
|
@@ -19,9 +19,10 @@ export class InlineQueryManager {
|
|
|
19
19
|
__classPrivateFieldSet(this, _InlineQueryManager_c, c, "f");
|
|
20
20
|
}
|
|
21
21
|
async answerInlineQuery(id, results, params) {
|
|
22
|
+
await __classPrivateFieldGet(this, _InlineQueryManager_c, "f").storage.assertBot("answerInlineQuery");
|
|
22
23
|
await __classPrivateFieldGet(this, _InlineQueryManager_c, "f").api.messages.setInlineBotResults({
|
|
23
24
|
query_id: BigInt(id),
|
|
24
|
-
results: await Promise.all(results.map((v) => inlineQueryResultToTlObject(v, __classPrivateFieldGet(this, _InlineQueryManager_c, "f").messageManager.parseText.bind(this), __classPrivateFieldGet(this, _InlineQueryManager_c, "f").messageManager.usernameResolver.bind(this)))),
|
|
25
|
+
results: await Promise.all(results.map((v) => inlineQueryResultToTlObject(v, __classPrivateFieldGet(this, _InlineQueryManager_c, "f").messageManager.parseText.bind(__classPrivateFieldGet(this, _InlineQueryManager_c, "f").messageManager), __classPrivateFieldGet(this, _InlineQueryManager_c, "f").messageManager.usernameResolver.bind(__classPrivateFieldGet(this, _InlineQueryManager_c, "f").messageManager)))),
|
|
25
26
|
cache_time: params?.cacheTime ?? 300,
|
|
26
27
|
private: params?.isPersonal ? true : undefined,
|
|
27
28
|
switch_webview: params?.button && params.button.webApp ? new types.InlineBotWebView({ text: params.button.text, url: params.button.webApp.url }) : undefined,
|
package/esm/client/4_client.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { MaybePromise } from "../1_utilities.js";
|
|
|
2
2
|
import { functions, types } from "../2_tl.js";
|
|
3
3
|
import { Storage } from "../3_storage.js";
|
|
4
4
|
import { DC } from "../3_transport.js";
|
|
5
|
-
import { BotCommand, Chat, ChatAction, ChatP, Document, FileSource, ID, InlineQueryResult, Message, MessageAnimation, MessageAudio, MessageContact, MessageDice, MessageDocument, MessageLocation, MessagePhoto, MessagePoll, MessageText, MessageVenue, MessageVideo, MessageVideoNote, MessageVoice, NetworkStatistics, ParseMode, Reaction, Update, UpdateIntersection, User } from "../3_types.js";
|
|
5
|
+
import { BotCommand, Chat, ChatAction, ChatMember, ChatP, Document, FileSource, ID, InlineQueryResult, Message, MessageAnimation, MessageAudio, MessageContact, MessageDice, MessageDocument, MessageLocation, MessagePhoto, MessagePoll, MessageText, MessageVenue, MessageVideo, MessageVideoNote, MessageVoice, NetworkStatistics, ParseMode, Reaction, Update, UpdateIntersection, User } from "../3_types.js";
|
|
6
6
|
import { Migrate } from "../4_errors.js";
|
|
7
7
|
import { ClientAbstract } from "./0_client_abstract.js";
|
|
8
8
|
import { FilterQuery, WithFilter } from "./0_filters.js";
|
|
@@ -74,6 +74,8 @@ export interface Context {
|
|
|
74
74
|
kickSender: () => Promise<void>;
|
|
75
75
|
/** Set the rights of the received message. */
|
|
76
76
|
setSenderRights: (params?: SetChatMemberRightsParams) => Promise<void>;
|
|
77
|
+
/** Get the administrators of the chat which the message was received from. */
|
|
78
|
+
getChatAdministrators: () => Promise<ChatMember[]>;
|
|
77
79
|
/** Change the reactions made to the received message. */
|
|
78
80
|
react: (reactions: Reaction[], params?: SetReactionsParams) => Promise<void>;
|
|
79
81
|
/** Send a chat action to the chat which the message was received from. */
|
|
@@ -84,9 +86,9 @@ export interface Context {
|
|
|
84
86
|
editMessageText: (messageId: number, text: string, params?: EditMessageParams) => Promise<MessageText>;
|
|
85
87
|
/** Edit the reply markup of a message in the chat which the message was received from. */
|
|
86
88
|
editMessageReplyMarkup: (messageId: number, params?: EditMessageReplyMarkupParams) => Promise<Message>;
|
|
87
|
-
/** Answer the received callback query. */
|
|
89
|
+
/** Answer the received callback query. Bot-only. */
|
|
88
90
|
answerCallbackQuery: (params?: AnswerCallbackQueryParams) => Promise<void>;
|
|
89
|
-
/** Answer the received inline query. */
|
|
91
|
+
/** Answer the received inline query. Bot-only */
|
|
90
92
|
answerInlineQuery: (results: InlineQueryResult[], params?: AnswerInlineQueryParams) => Promise<void>;
|
|
91
93
|
/** Retrieve a single message of the chat which the message was received from. */
|
|
92
94
|
getMessage: (messageId: number) => Promise<Message | null>;
|
|
@@ -236,6 +238,15 @@ export declare class Client<C extends Context = Context> extends ClientAbstract
|
|
|
236
238
|
private [getEntity];
|
|
237
239
|
private [getEntity];
|
|
238
240
|
private [getEntity];
|
|
241
|
+
use(...middleware: Middleware<UpdateIntersection<C>>[]): Composer<UpdateIntersection<C>>;
|
|
242
|
+
branch(predicate: (ctx: UpdateIntersection<C>) => MaybePromise<boolean>, trueHandler_: Middleware<UpdateIntersection<C>>, falseHandler_: Middleware<UpdateIntersection<C>>): Composer<UpdateIntersection<C>>;
|
|
243
|
+
filter<D extends C>(predicate: (ctx: UpdateIntersection<C>) => ctx is D, ...middleware: Middleware<D>[]): Composer<D>;
|
|
244
|
+
filter(predicate: (ctx: UpdateIntersection<C>) => MaybePromise<boolean>, ...middleware: Middleware<UpdateIntersection<C>>[]): Composer<C>;
|
|
245
|
+
on<Q extends FilterQuery>(filter: Q, ...middleawre: Middleware<WithFilter<C, Q>>[]): Composer<UpdateIntersection<WithFilter<C, Q>>>;
|
|
246
|
+
command(commands: string | RegExp | (string | RegExp)[] | {
|
|
247
|
+
names: string | RegExp | (string | RegExp)[];
|
|
248
|
+
prefixes: string | string[];
|
|
249
|
+
}, ...middleawre: Middleware<WithFilter<C, "message:text">>[]): Composer<UpdateIntersection<WithFilter<C, "message:text">>>;
|
|
239
250
|
/**
|
|
240
251
|
* Send a text message.
|
|
241
252
|
*
|
|
@@ -327,15 +338,6 @@ export declare class Client<C extends Context = Context> extends ClientAbstract
|
|
|
327
338
|
* @method
|
|
328
339
|
*/
|
|
329
340
|
getMe(): Promise<User>;
|
|
330
|
-
use(...middleware: Middleware<UpdateIntersection<C>>[]): Composer<UpdateIntersection<C>>;
|
|
331
|
-
branch(predicate: (ctx: UpdateIntersection<C>) => MaybePromise<boolean>, trueHandler_: Middleware<UpdateIntersection<C>>, falseHandler_: Middleware<UpdateIntersection<C>>): Composer<UpdateIntersection<C>>;
|
|
332
|
-
filter<D extends C>(predicate: (ctx: UpdateIntersection<C>) => ctx is D, ...middleware: Middleware<D>[]): Composer<D>;
|
|
333
|
-
filter(predicate: (ctx: UpdateIntersection<C>) => MaybePromise<boolean>, ...middleware: Middleware<UpdateIntersection<C>>[]): Composer<C>;
|
|
334
|
-
on<Q extends FilterQuery>(filter: Q, ...middleawre: Middleware<WithFilter<C, Q>>[]): Composer<UpdateIntersection<WithFilter<C, Q>>>;
|
|
335
|
-
command(commands: string | RegExp | (string | RegExp)[] | {
|
|
336
|
-
names: string | RegExp | (string | RegExp)[];
|
|
337
|
-
prefixes: string | string[];
|
|
338
|
-
}, ...middleawre: Middleware<WithFilter<C, "message:text">>[]): Composer<UpdateIntersection<WithFilter<C, "message:text">>>;
|
|
339
341
|
/**
|
|
340
342
|
* Answer a callback query. Bot-only.
|
|
341
343
|
*
|
|
@@ -694,5 +696,12 @@ export declare class Client<C extends Context = Context> extends ClientAbstract
|
|
|
694
696
|
* @param memberId The identifier of a member.
|
|
695
697
|
*/
|
|
696
698
|
setChatMemberRights(chatId: ID, memberId: ID, params?: SetChatMemberRightsParams): Promise<void>;
|
|
699
|
+
/**
|
|
700
|
+
* Get the administrators of a chat.
|
|
701
|
+
*
|
|
702
|
+
* @method
|
|
703
|
+
* @param chatId The identifier of the chat.
|
|
704
|
+
*/
|
|
705
|
+
getChatAdministrators(chatId: ID): Promise<ChatMember[]>;
|
|
697
706
|
}
|
|
698
707
|
export {};
|