@mtkruto/node 0.1.141 → 0.1.143
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/4_constants.d.ts +1 -1
- package/esm/4_constants.js +1 -1
- package/esm/5_client.d.ts +1 -0
- package/esm/5_client.js +1 -0
- package/esm/client/0_types.d.ts +2 -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_network_statistics_manager.d.ts +19 -0
- package/esm/client/1_network_statistics_manager.js +48 -0
- package/esm/client/1_reaction_manager.d.ts +9 -0
- package/esm/client/1_reaction_manager.js +84 -0
- package/esm/client/2_message_manager.d.ts +22 -2
- package/esm/client/2_message_manager.js +282 -28
- package/esm/client/3_callback_query_manager.d.ts +16 -0
- package/esm/client/3_callback_query_manager.js +36 -0
- package/esm/client/3_chat_list_manager.d.ts +5 -9
- package/esm/client/3_chat_list_manager.js +190 -103
- package/esm/client/3_inline_query_manager.d.ts +16 -0
- package/esm/client/3_inline_query_manager.js +49 -0
- package/esm/client/4_client.d.ts +12 -12
- package/esm/client/4_client.js +162 -538
- package/esm/client/5_session_string.d.ts +3 -0
- package/esm/client/5_session_string.js +22 -0
- package/esm/connection/1_connection_web_socket.js +1 -1
- package/package.json +1 -1
- package/script/4_constants.d.ts +1 -1
- package/script/4_constants.js +1 -1
- package/script/5_client.d.ts +1 -0
- package/script/5_client.js +1 -0
- package/script/client/0_types.d.ts +2 -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_network_statistics_manager.d.ts +19 -0
- package/script/client/1_network_statistics_manager.js +52 -0
- package/script/client/1_reaction_manager.d.ts +9 -0
- package/script/client/1_reaction_manager.js +88 -0
- package/script/client/2_message_manager.d.ts +22 -2
- package/script/client/2_message_manager.js +281 -27
- package/script/client/3_callback_query_manager.d.ts +16 -0
- package/script/client/3_callback_query_manager.js +40 -0
- package/script/client/3_chat_list_manager.d.ts +5 -9
- package/script/client/3_chat_list_manager.js +187 -100
- package/script/client/3_inline_query_manager.d.ts +16 -0
- package/script/client/3_inline_query_manager.js +53 -0
- package/script/client/4_client.d.ts +12 -12
- package/script/client/4_client.js +158 -534
- package/script/client/5_session_string.d.ts +3 -0
- package/script/client/5_session_string.js +27 -0
- package/script/connection/1_connection_web_socket.js +1 -1
- package/esm/client/3_reaction_manager.d.ts +0 -16
- package/esm/client/3_reaction_manager.js +0 -61
- package/script/client/3_reaction_manager.d.ts +0 -16
- package/script/client/3_reaction_manager.js +0 -65
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { base64DecodeUrlSafe, base64EncodeUrlSafe, rleDecode, rleEncode } from "../1_utilities.js";
|
|
2
|
+
import { TLReader, TLWriter } from "../2_tl.js";
|
|
3
|
+
export async function exportSessionString(client) {
|
|
4
|
+
const [dc, authKey] = await Promise.all([client.storage.getDc(), client.storage.getAuthKey()]);
|
|
5
|
+
if (dc == null || authKey == null) {
|
|
6
|
+
throw new Error("Client not authorized");
|
|
7
|
+
}
|
|
8
|
+
const writer = new TLWriter();
|
|
9
|
+
writer.writeString(dc);
|
|
10
|
+
writer.writeBytes(authKey);
|
|
11
|
+
const data = rleEncode(writer.buffer);
|
|
12
|
+
return base64EncodeUrlSafe(data);
|
|
13
|
+
}
|
|
14
|
+
export async function importSessionString(client, string) {
|
|
15
|
+
const data = rleDecode(base64DecodeUrlSafe(string));
|
|
16
|
+
const reader = new TLReader(data);
|
|
17
|
+
const dc = reader.readString();
|
|
18
|
+
const authKey = reader.readBytes();
|
|
19
|
+
await client.storage.initialize();
|
|
20
|
+
await client.storage.setDc(dc);
|
|
21
|
+
await client.storage.setAuthKey(authKey);
|
|
22
|
+
}
|
|
@@ -50,7 +50,7 @@ export class ConnectionWebSocket extends ConnectionUnframed {
|
|
|
50
50
|
try {
|
|
51
51
|
while (__classPrivateFieldGet(this, _ConnectionWebSocket_webSocket, "f").readyState != dntShim.WebSocket.OPEN) {
|
|
52
52
|
if (__classPrivateFieldGet(this, _ConnectionWebSocket_webSocket, "f").readyState == dntShim.WebSocket.CLOSED) {
|
|
53
|
-
if (__classPrivateFieldGet(this, _ConnectionWebSocket_connectionError, "f")
|
|
53
|
+
if (__classPrivateFieldGet(this, _ConnectionWebSocket_connectionError, "f") && "message" in __classPrivateFieldGet(this, _ConnectionWebSocket_connectionError, "f")) {
|
|
54
54
|
throw new Error(__classPrivateFieldGet(this, _ConnectionWebSocket_connectionError, "f").message);
|
|
55
55
|
}
|
|
56
56
|
else {
|
package/package.json
CHANGED
package/script/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.143";
|
|
8
8
|
export declare const DEVICE_MODEL: string;
|
|
9
9
|
export declare const LANG_CODE: string;
|
|
10
10
|
export declare const LANG_PACK = "";
|
package/script/4_constants.js
CHANGED
|
@@ -79,7 +79,7 @@ exports.PUBLIC_KEYS = Object.freeze([
|
|
|
79
79
|
]);
|
|
80
80
|
exports.INITIAL_DC = "2";
|
|
81
81
|
exports.LAYER = 169;
|
|
82
|
-
exports.APP_VERSION = "MTKruto 0.1.
|
|
82
|
+
exports.APP_VERSION = "MTKruto 0.1.143";
|
|
83
83
|
// @ts-ignore: lib
|
|
84
84
|
exports.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;
|
|
85
85
|
exports.LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
package/script/5_client.d.ts
CHANGED
package/script/5_client.js
CHANGED
|
@@ -18,3 +18,4 @@ __exportStar(require("./client/0_params.js"), exports);
|
|
|
18
18
|
__exportStar(require("./client/2_client_plain.js"), exports);
|
|
19
19
|
__exportStar(require("./client/4_client.js"), exports);
|
|
20
20
|
__exportStar(require("./client/5_composer.js"), exports);
|
|
21
|
+
__exportStar(require("./client/5_session_string.js"), exports);
|
|
@@ -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,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
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");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
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");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _BotInfoManager_instances, _BotInfoManager_c, _BotInfoManager_setMyInfo, _BotInfoManager_getMyInfo;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.BotInfoManager = void 0;
|
|
16
|
+
const _2_tl_js_1 = require("../2_tl.js");
|
|
17
|
+
const _3_types_js_1 = require("../3_types.js");
|
|
18
|
+
class BotInfoManager {
|
|
19
|
+
constructor(c) {
|
|
20
|
+
_BotInfoManager_instances.add(this);
|
|
21
|
+
_BotInfoManager_c.set(this, void 0);
|
|
22
|
+
__classPrivateFieldSet(this, _BotInfoManager_c, c, "f");
|
|
23
|
+
}
|
|
24
|
+
async setMyDescription(params) {
|
|
25
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("setMyDescription");
|
|
26
|
+
await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_setMyInfo).call(this, { description: params?.description, lang_code: params?.languageCode ?? "" });
|
|
27
|
+
}
|
|
28
|
+
async setMyName(params) {
|
|
29
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("setMyName");
|
|
30
|
+
await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_setMyInfo).call(this, { name: params?.name, lang_code: params?.languageCode ?? "" });
|
|
31
|
+
}
|
|
32
|
+
async setMyShortDescription(params) {
|
|
33
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("setMyShortDescription");
|
|
34
|
+
await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_setMyInfo).call(this, { about: params?.shortDescription, lang_code: params?.languageCode ?? "" });
|
|
35
|
+
}
|
|
36
|
+
async getMyDescription(params) {
|
|
37
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("getMyDescription");
|
|
38
|
+
return await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_getMyInfo).call(this, params?.languageCode).then((v) => v.description);
|
|
39
|
+
}
|
|
40
|
+
async getMyName(params) {
|
|
41
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("getMyName");
|
|
42
|
+
return await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_getMyInfo).call(this, params?.languageCode).then((v) => v.description);
|
|
43
|
+
}
|
|
44
|
+
async getMyShortDescription(params) {
|
|
45
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("getMyShortDescription");
|
|
46
|
+
return await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_getMyInfo).call(this, params?.languageCode).then((v) => v.about);
|
|
47
|
+
}
|
|
48
|
+
async getMyCommands(params) {
|
|
49
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("getMyCommands");
|
|
50
|
+
const commands_ = await __classPrivateFieldGet(this, _BotInfoManager_c, "f").api.bots.getBotCommands({
|
|
51
|
+
lang_code: params?.languageCode ?? "",
|
|
52
|
+
scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, __classPrivateFieldGet(this, _BotInfoManager_c, "f").getInputPeer),
|
|
53
|
+
});
|
|
54
|
+
return commands_.map((v) => ({ command: v.command, description: v.description }));
|
|
55
|
+
}
|
|
56
|
+
async setMyCommands(commands, params) {
|
|
57
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("setMyCommands");
|
|
58
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").api.bots.setBotCommands({
|
|
59
|
+
commands: commands.map((v) => new _2_tl_js_1.types.BotCommand(v)),
|
|
60
|
+
lang_code: params?.languageCode ?? "",
|
|
61
|
+
scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, __classPrivateFieldGet(this, _BotInfoManager_c, "f").getInputPeer),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.BotInfoManager = BotInfoManager;
|
|
66
|
+
_BotInfoManager_c = new WeakMap(), _BotInfoManager_instances = new WeakSet(), _BotInfoManager_setMyInfo = async function _BotInfoManager_setMyInfo(info) {
|
|
67
|
+
await __classPrivateFieldGet(this, _BotInfoManager_c, "f").api.bots.setBotInfo({ bot: new _2_tl_js_1.types.InputUserSelf(), ...info });
|
|
68
|
+
}, _BotInfoManager_getMyInfo = function _BotInfoManager_getMyInfo(languageCode) {
|
|
69
|
+
return __classPrivateFieldGet(this, _BotInfoManager_c, "f").api.bots.getBotInfo({ bot: new _2_tl_js_1.types.InputUserSelf(), lang_code: languageCode ?? "" });
|
|
70
|
+
};
|
|
@@ -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,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
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");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
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");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _NetworkStatisticsManager_c;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.NetworkStatisticsManager = void 0;
|
|
16
|
+
class NetworkStatisticsManager {
|
|
17
|
+
constructor(c) {
|
|
18
|
+
_NetworkStatisticsManager_c.set(this, void 0);
|
|
19
|
+
__classPrivateFieldSet(this, _NetworkStatisticsManager_c, c, "f");
|
|
20
|
+
}
|
|
21
|
+
async getNetworkStatistics() {
|
|
22
|
+
const [messagesRead, messagesWrite, cdnRead, cdnWrite] = await Promise.all([
|
|
23
|
+
__classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").storage.get(["netstat_messages_read"]),
|
|
24
|
+
__classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").storage.get(["netstat_messages_write"]),
|
|
25
|
+
__classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").storage.get(["netstat_cdn_read"]),
|
|
26
|
+
__classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").storage.get(["netstat_cdn_write"]),
|
|
27
|
+
]);
|
|
28
|
+
const messages = {
|
|
29
|
+
sent: Number(messagesWrite || 0),
|
|
30
|
+
received: Number(messagesRead || 0),
|
|
31
|
+
};
|
|
32
|
+
const cdn = {
|
|
33
|
+
sent: Number(cdnWrite || 0),
|
|
34
|
+
received: Number(cdnRead || 0),
|
|
35
|
+
};
|
|
36
|
+
return { messages, cdn };
|
|
37
|
+
}
|
|
38
|
+
getTransportReadWriteCallback() {
|
|
39
|
+
return {
|
|
40
|
+
read: async (count) => {
|
|
41
|
+
const key = __classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").cdn ? "netstat_cdn_read" : "netstat_messages_read";
|
|
42
|
+
await __classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").storage.incr([key], count);
|
|
43
|
+
},
|
|
44
|
+
write: async (count) => {
|
|
45
|
+
const key = __classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").cdn ? "netstat_cdn_write" : "netstat_messages_write";
|
|
46
|
+
await __classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").storage.incr([key], count);
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.NetworkStatisticsManager = NetworkStatisticsManager;
|
|
52
|
+
_NetworkStatisticsManager_c = new WeakMap();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { enums, types } from "../2_tl.js";
|
|
2
|
+
import { Update } from "../3_types.js";
|
|
3
|
+
import { C } from "./0_types.js";
|
|
4
|
+
export declare class ReactionManager {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(c: C);
|
|
7
|
+
static canHandleUpdate(update: enums.Update): update is types.UpdateBotMessageReactions | types.UpdateBotMessageReaction | types.UpdateMessageReactions | types.UpdateChannelMessageViews | types.UpdateChannelMessageForwards;
|
|
8
|
+
handleUpdate(update: types.UpdateBotMessageReactions | types.UpdateBotMessageReaction | types.UpdateMessageReactions | types.UpdateChannelMessageViews | types.UpdateChannelMessageForwards): Promise<Update | null>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
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");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
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");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _ReactionManager_c;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ReactionManager = void 0;
|
|
16
|
+
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
17
|
+
const _2_tl_js_1 = require("../2_tl.js");
|
|
18
|
+
const _3_types_js_1 = require("../3_types.js");
|
|
19
|
+
class ReactionManager {
|
|
20
|
+
constructor(c) {
|
|
21
|
+
_ReactionManager_c.set(this, void 0);
|
|
22
|
+
__classPrivateFieldSet(this, _ReactionManager_c, c, "f");
|
|
23
|
+
}
|
|
24
|
+
static canHandleUpdate(update) {
|
|
25
|
+
return update instanceof _2_tl_js_1.types.UpdateBotMessageReactions || update instanceof _2_tl_js_1.types.UpdateBotMessageReaction || update instanceof _2_tl_js_1.types.UpdateMessageReactions || update instanceof _2_tl_js_1.types.UpdateChannelMessageViews || update instanceof _2_tl_js_1.types.UpdateChannelMessageForwards;
|
|
26
|
+
}
|
|
27
|
+
async handleUpdate(update) {
|
|
28
|
+
if (update instanceof _2_tl_js_1.types.UpdateBotMessageReactions) {
|
|
29
|
+
const messageReactionCount = await (0, _3_types_js_1.constructMessageReactionCount)(update, __classPrivateFieldGet(this, _ReactionManager_c, "f").getEntity);
|
|
30
|
+
if (messageReactionCount) {
|
|
31
|
+
return { messageReactionCount };
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else if (update instanceof _2_tl_js_1.types.UpdateBotMessageReaction) {
|
|
38
|
+
const messageReactions = await (0, _3_types_js_1.constructMessageReactions)(update, __classPrivateFieldGet(this, _ReactionManager_c, "f").getEntity);
|
|
39
|
+
if (messageReactions) {
|
|
40
|
+
return { messageReactions };
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else if (update instanceof _2_tl_js_1.types.UpdateMessageReactions) {
|
|
47
|
+
const chatId = (0, _2_tl_js_1.peerToChatId)(update.peer);
|
|
48
|
+
const message = await __classPrivateFieldGet(this, _ReactionManager_c, "f").storage.getMessage(chatId, update.msg_id);
|
|
49
|
+
if (message instanceof _2_tl_js_1.types.Message) {
|
|
50
|
+
message.reactions = update.reactions;
|
|
51
|
+
await __classPrivateFieldGet(this, _ReactionManager_c, "f").storage.setMessage(chatId, update.msg_id, message);
|
|
52
|
+
const views = message.views ?? 0;
|
|
53
|
+
const forwards = message.forwards ?? 0;
|
|
54
|
+
const recentReactions = update.reactions.recent_reactions ?? [];
|
|
55
|
+
const reactions = update.reactions.results.map((v) => (0, _3_types_js_1.constructMessageReaction)(v, recentReactions));
|
|
56
|
+
return ({ messageInteractions: { chatId, messageId: update.msg_id, reactions, views, forwards } });
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if (update instanceof _2_tl_js_1.types.UpdateChannelMessageViews || update instanceof _2_tl_js_1.types.UpdateChannelMessageForwards) {
|
|
63
|
+
const chatId = (0, _2_tl_js_1.peerToChatId)(new _2_tl_js_1.types.PeerChannel(update));
|
|
64
|
+
const message = await __classPrivateFieldGet(this, _ReactionManager_c, "f").storage.getMessage(chatId, update.id);
|
|
65
|
+
if (message instanceof _2_tl_js_1.types.Message) {
|
|
66
|
+
if ("views" in update) {
|
|
67
|
+
message.views = update.views;
|
|
68
|
+
}
|
|
69
|
+
if ("forwards" in update) {
|
|
70
|
+
message.forwards = update.forwards;
|
|
71
|
+
}
|
|
72
|
+
const views = message.views ?? 0;
|
|
73
|
+
const forwards = message.forwards ?? 0;
|
|
74
|
+
const recentReactions = message.reactions?.recent_reactions ?? [];
|
|
75
|
+
const reactions = message.reactions?.results.map((v) => (0, _3_types_js_1.constructMessageReaction)(v, recentReactions)) ?? [];
|
|
76
|
+
return { messageInteractions: { chatId, messageId: update.id, reactions, views, forwards } };
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.ReactionManager = ReactionManager;
|
|
88
|
+
_ReactionManager_c = new WeakMap();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { enums, types } from "../2_tl.js";
|
|
2
|
-
import { FileSource, ID, Message } 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, 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
|
+
import { AddReactionParams, SetReactionsParams } from "./0_params.js";
|
|
4
5
|
import { C as C_ } from "./0_types.js";
|
|
5
6
|
import { FileManager } from "./1_file_manager.js";
|
|
6
7
|
interface C extends C_ {
|
|
@@ -12,10 +13,15 @@ export declare class MessageManager {
|
|
|
12
13
|
getMessages(chatId: ID, messageIds: number[]): Promise<Message[]>;
|
|
13
14
|
getMessageWithReply(chatId: ID, messageId: number): Promise<Message>;
|
|
14
15
|
getMessage(chatId: ID, messageId: number): Promise<Message>;
|
|
16
|
+
parseText(text: string, params?: {
|
|
17
|
+
parseMode?: ParseMode;
|
|
18
|
+
entities?: MessageEntity[];
|
|
19
|
+
}): readonly [string, (import("../tl/2_types.js").MessageEntityMention_ | import("../tl/2_types.js").MessageEntityHashtag_ | import("../tl/2_types.js").MessageEntityBotCommand_ | import("../tl/2_types.js").MessageEntityUrl_ | import("../tl/2_types.js").MessageEntityEmail_ | import("../tl/2_types.js").MessageEntityBold_ | import("../tl/2_types.js").MessageEntityItalic_ | import("../tl/2_types.js").MessageEntityCode_ | import("../tl/2_types.js").MessageEntityPre_ | import("../tl/2_types.js").MessageEntityTextUrl_ | import("../tl/2_types.js").MessageEntityMentionName_ | import("../tl/2_types.js").MessageEntityPhone_ | import("../tl/2_types.js").MessageEntityCashtag_ | import("../tl/2_types.js").MessageEntityUnderline_ | import("../tl/2_types.js").MessageEntityStrike_ | import("../tl/2_types.js").MessageEntityBankCard_ | import("../tl/2_types.js").MessageEntitySpoiler_ | import("../tl/2_types.js").MessageEntityCustomEmoji_ | import("../tl/2_types.js").MessageEntityBlockquote_)[] | undefined];
|
|
15
20
|
getStickerSetName(inputStickerSet: types.InputStickerSetID, hash?: number): Promise<string>;
|
|
16
21
|
constructMessage(message_: enums.Message, r?: boolean): Promise<Message>;
|
|
17
22
|
forwardMessages(from: ID, to: ID, messageIds: number[], params?: ForwardMessagesParams): Promise<Message[]>;
|
|
18
23
|
getHistory(chatId: ID, params?: GetHistoryParams): Promise<Message[]>;
|
|
24
|
+
usernameResolver: UsernameResolver;
|
|
19
25
|
sendMessage(chatId: ID, text: string, params?: SendMessageParams): Promise<import("../3_types.js").MessageText>;
|
|
20
26
|
sendVenue(chatId: ID, latitude: number, longitude: number, title: string, address: string, params?: SendVenueParams): Promise<import("../3_types.js").MessageVenue>;
|
|
21
27
|
sendContact(chatId: ID, firstName: string, number: string, params?: SendContactParams): Promise<import("../3_types.js").MessageContact>;
|
|
@@ -36,5 +42,19 @@ export declare class MessageManager {
|
|
|
36
42
|
pinMessage(chatId: ID, messageId: number, params?: PinMessageParams): Promise<void>;
|
|
37
43
|
unpinMessage(chatId: ID, messageId: number): Promise<void>;
|
|
38
44
|
unpinMessages(chatId: ID): Promise<void>;
|
|
45
|
+
setAvailableReactions(chatId: ID, availableReactions: "none" | "all" | Reaction[]): Promise<void>;
|
|
46
|
+
setReactions(chatId: number, messageId: number, reactions: Reaction[], params?: SetReactionsParams): Promise<void>;
|
|
47
|
+
addReaction(chatId: number, messageId: number, reaction: Reaction, params?: AddReactionParams): Promise<void>;
|
|
48
|
+
removeReaction(chatId: number, messageId: number, reaction: Reaction): Promise<void>;
|
|
49
|
+
static canHandleUpdate(update: enums.Update): update is types.UpdateNewMessage | types.UpdateNewChannelMessage | types.UpdateEditMessage | types.UpdateEditChannelMessage | types.UpdateDeleteMessages | types.UpdateDeleteChannelMessages;
|
|
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>;
|
|
39
59
|
}
|
|
40
60
|
export {};
|