@mtkruto/node 0.50.0 → 0.60.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/esm/3_types.d.ts +1 -0
- package/esm/3_types.d.ts.map +1 -1
- package/esm/3_types.js +1 -0
- package/esm/_dnt.shims.d.ts +5 -1
- package/esm/_dnt.shims.d.ts.map +1 -1
- package/esm/_dnt.shims.js +5 -0
- package/esm/_dnt.test_shims.d.ts.map +1 -1
- package/esm/client/0_params.d.ts +12 -0
- package/esm/client/0_params.d.ts.map +1 -1
- package/esm/client/3_message_manager.d.ts +1 -0
- package/esm/client/3_message_manager.d.ts.map +1 -1
- package/esm/client/3_message_manager.js +51 -50
- package/esm/client/4_forum_manager.d.ts +40 -0
- package/esm/client/4_forum_manager.d.ts.map +1 -0
- package/esm/client/4_forum_manager.js +134 -0
- package/esm/client/5_client.d.ts +67 -2
- package/esm/client/5_client.d.ts.map +1 -1
- package/esm/client/5_client.js +87 -2
- package/esm/types/4_message.d.ts +3 -3
- package/esm/types/4_message.d.ts.map +1 -1
- package/esm/types/4_message.js +16 -8
- package/esm/types/5_topic.d.ts +34 -0
- package/esm/types/5_topic.d.ts.map +1 -0
- package/esm/types/5_topic.js +76 -0
- package/esm/utilities/0_misc.d.ts +0 -19
- package/esm/utilities/0_misc.d.ts.map +1 -1
- package/esm/utilities/0_misc.js +4 -3
- package/package.json +2 -1
- package/script/3_types.d.ts +1 -0
- package/script/3_types.d.ts.map +1 -1
- package/script/3_types.js +1 -0
- package/script/_dnt.shims.d.ts +5 -1
- package/script/_dnt.shims.d.ts.map +1 -1
- package/script/_dnt.shims.js +9 -1
- package/script/_dnt.test_shims.d.ts.map +1 -1
- package/script/client/0_params.d.ts +12 -0
- package/script/client/0_params.d.ts.map +1 -1
- package/script/client/3_message_manager.d.ts +1 -0
- package/script/client/3_message_manager.d.ts.map +1 -1
- package/script/client/3_message_manager.js +51 -50
- package/script/client/4_forum_manager.d.ts +40 -0
- package/script/client/4_forum_manager.d.ts.map +1 -0
- package/script/client/4_forum_manager.js +138 -0
- package/script/client/5_client.d.ts +67 -2
- package/script/client/5_client.d.ts.map +1 -1
- package/script/client/5_client.js +87 -2
- package/script/types/4_message.d.ts +3 -3
- package/script/types/4_message.d.ts.map +1 -1
- package/script/types/4_message.js +16 -8
- package/script/types/5_topic.d.ts +34 -0
- package/script/types/5_topic.d.ts.map +1 -0
- package/script/types/5_topic.js +79 -0
- package/script/utilities/0_misc.d.ts +0 -19
- package/script/utilities/0_misc.d.ts.map +1 -1
- package/script/utilities/0_misc.js +36 -12
|
@@ -157,14 +157,21 @@ async function getReply(message_, chat, getMessage) {
|
|
|
157
157
|
}
|
|
158
158
|
return { replyToMessage: undefined, threadId: undefined, isTopicMessage: false };
|
|
159
159
|
}
|
|
160
|
-
async function constructServiceMessage(message_, chat, getEntity, getMessage) {
|
|
160
|
+
async function constructServiceMessage(message_, chat, getEntity, getMessage, getReply_) {
|
|
161
161
|
const message = {
|
|
162
162
|
out: message_.out ?? false,
|
|
163
163
|
id: message_.id,
|
|
164
|
-
chat
|
|
164
|
+
chat,
|
|
165
165
|
date: (0, _1_utilities_js_1.fromUnixTimestamp)(message_.date),
|
|
166
|
-
isTopicMessage: false,
|
|
166
|
+
isTopicMessage: message_.reply_to && (0, _2_tl_js_1.is)("messageReplyHeader", message_.reply_to) && message_.reply_to.forum_topic ? true : false,
|
|
167
167
|
};
|
|
168
|
+
if ((0, _2_tl_js_1.is)("messageReplyHeader", message_.reply_to) && message_.reply_to.reply_to_msg_id) {
|
|
169
|
+
message.replyToMessageId = message_.reply_to.reply_to_top_id;
|
|
170
|
+
message.replyToMessageId = message_.reply_to.reply_to_msg_id;
|
|
171
|
+
}
|
|
172
|
+
if (getReply_) {
|
|
173
|
+
Object.assign(message, await getReply(message_, chat, getMessage));
|
|
174
|
+
}
|
|
168
175
|
Object.assign(message, await getSender(message_, getEntity));
|
|
169
176
|
if ((0, _2_tl_js_1.is)("messageActionChatAddUser", message_.action) || (0, _2_tl_js_1.is)("messageActionChatJoinedByLink", message_.action) || (0, _2_tl_js_1.is)("messageActionChatJoinedByRequest", message_.action)) {
|
|
170
177
|
const newChatMembers = new Array();
|
|
@@ -254,8 +261,8 @@ async function constructServiceMessage(message_, chat, getEntity, getMessage) {
|
|
|
254
261
|
else if ((0, _2_tl_js_1.is)("messageActionTopicCreate", message_.action)) {
|
|
255
262
|
const forumTopicCreated = {
|
|
256
263
|
name: message_.action.title,
|
|
257
|
-
|
|
258
|
-
|
|
264
|
+
color: message_.action.icon_color,
|
|
265
|
+
cutsomEmojiId: message_.action.icon_emoji_id ? String(message_.action.icon_emoji_id) : undefined,
|
|
259
266
|
};
|
|
260
267
|
return { ...message, forumTopicCreated };
|
|
261
268
|
}
|
|
@@ -267,7 +274,7 @@ async function constructServiceMessage(message_, chat, getEntity, getMessage) {
|
|
|
267
274
|
else if (message_.action.title || message_.action.icon_emoji_id) {
|
|
268
275
|
const forumTopicEdited = {
|
|
269
276
|
name: message_.action.title ?? "",
|
|
270
|
-
|
|
277
|
+
customEmojiId: message_.action.icon_emoji_id ? String(message_.action.icon_emoji_id) : undefined,
|
|
271
278
|
};
|
|
272
279
|
return { ...message, forumTopicEdited };
|
|
273
280
|
}
|
|
@@ -347,7 +354,7 @@ async function constructMessage(message_, getEntity, getMessage, getStickerSetNa
|
|
|
347
354
|
(0, _0_deps_js_1.unreachable)();
|
|
348
355
|
}
|
|
349
356
|
if ((0, _2_tl_js_1.is)("messageService", message_)) {
|
|
350
|
-
return await constructServiceMessage(message_, chat_, getEntity, getMessage);
|
|
357
|
+
return await constructServiceMessage(message_, chat_, getEntity, getMessage, getReply_);
|
|
351
358
|
}
|
|
352
359
|
const message = {
|
|
353
360
|
out: message_.out ?? false,
|
|
@@ -357,7 +364,7 @@ async function constructMessage(message_, getEntity, getMessage, getStickerSetNa
|
|
|
357
364
|
date: (0, _1_utilities_js_1.fromUnixTimestamp)(message_.date),
|
|
358
365
|
views: message_.views,
|
|
359
366
|
forwards: message_.forwards,
|
|
360
|
-
isTopicMessage: message_.reply_to && (0, _2_tl_js_1.is)("messageReplyHeader", message_.reply_to) && message_.reply_to.
|
|
367
|
+
isTopicMessage: message_.reply_to && (0, _2_tl_js_1.is)("messageReplyHeader", message_.reply_to) && message_.reply_to.forum_topic ? true : false,
|
|
361
368
|
hasProtectedContent: message_.noforwards || false,
|
|
362
369
|
senderBoostCount: message_.from_boosts_applied,
|
|
363
370
|
effectId: message_.effect ? String(message_.effect) : undefined,
|
|
@@ -371,6 +378,7 @@ async function constructMessage(message_, getEntity, getMessage, getStickerSetNa
|
|
|
371
378
|
if (message_.reply_to.quote) {
|
|
372
379
|
message.replyQuote = (0, _1_reply_quote_js_1.constructReplyQuote)(message_.reply_to.quote_text, message_.reply_to.quote_offset, message_.reply_to.quote_entities);
|
|
373
380
|
}
|
|
381
|
+
message.threadId = message_.reply_to.reply_to_top_id;
|
|
374
382
|
message.replyToMessageId = message_.reply_to.reply_to_msg_id;
|
|
375
383
|
}
|
|
376
384
|
if (business) {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2025 Roj <https://roj.im/>
|
|
4
|
+
*
|
|
5
|
+
* This file is part of MTKruto.
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU Lesser General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
*/
|
|
20
|
+
import { ChatP } from "./1_chat_p.js";
|
|
21
|
+
import { Message } from "./4_message.js";
|
|
22
|
+
export interface Topic {
|
|
23
|
+
id: number;
|
|
24
|
+
date: Date;
|
|
25
|
+
creator: ChatP;
|
|
26
|
+
general: boolean;
|
|
27
|
+
closed: boolean;
|
|
28
|
+
hidden: boolean;
|
|
29
|
+
name: string;
|
|
30
|
+
color: number;
|
|
31
|
+
customEmojiId?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function constructTopic(message: Message): Topic;
|
|
34
|
+
//# sourceMappingURL=5_topic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"5_topic.d.ts","sourceRoot":"","sources":["../../src/types/5_topic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAqD,MAAM,gBAAgB,CAAC;AAE5F,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,KAAK,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK,CAqCtD"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
4
|
+
* Copyright (C) 2023-2025 Roj <https://roj.im/>
|
|
5
|
+
*
|
|
6
|
+
* This file is part of MTKruto.
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Lesser General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
19
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.constructTopic = constructTopic;
|
|
23
|
+
const _0_deps_js_1 = require("../0_deps.js");
|
|
24
|
+
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
25
|
+
function constructTopic(message) {
|
|
26
|
+
let forumTopicCreated;
|
|
27
|
+
let forumTopicEdited;
|
|
28
|
+
if ("forumTopicCreated" in message) {
|
|
29
|
+
forumTopicCreated = message;
|
|
30
|
+
}
|
|
31
|
+
else if (message.replyToMessage && "forumTopicCreated" in message.replyToMessage) {
|
|
32
|
+
forumTopicCreated = message.replyToMessage;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
(0, _0_deps_js_1.unreachable)();
|
|
36
|
+
}
|
|
37
|
+
if ("forumTopicEdited" in message) {
|
|
38
|
+
forumTopicEdited = message;
|
|
39
|
+
}
|
|
40
|
+
const id = forumTopicCreated.id;
|
|
41
|
+
const date = forumTopicCreated.date;
|
|
42
|
+
const creator = forumTopicCreated.from ? constructChatP(forumTopicCreated.from) : message.senderChat;
|
|
43
|
+
const general = forumTopicCreated.id == 1;
|
|
44
|
+
const closed = false;
|
|
45
|
+
const hidden = false;
|
|
46
|
+
let name = forumTopicCreated.forumTopicCreated.name;
|
|
47
|
+
const color = forumTopicCreated.forumTopicCreated.color;
|
|
48
|
+
let customEmoijId = forumTopicCreated.forumTopicCreated.customEmojiId;
|
|
49
|
+
if (forumTopicEdited) {
|
|
50
|
+
name = forumTopicEdited.forumTopicEdited.name;
|
|
51
|
+
customEmoijId = forumTopicEdited.forumTopicEdited.customEmojiId;
|
|
52
|
+
}
|
|
53
|
+
return (0, _1_utilities_js_1.cleanObject)({
|
|
54
|
+
id,
|
|
55
|
+
date,
|
|
56
|
+
creator: creator,
|
|
57
|
+
general,
|
|
58
|
+
closed,
|
|
59
|
+
hidden,
|
|
60
|
+
name,
|
|
61
|
+
color,
|
|
62
|
+
customEmoijId,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function constructChatP(user) {
|
|
66
|
+
return (0, _1_utilities_js_1.cleanObject)({
|
|
67
|
+
id: user.id,
|
|
68
|
+
type: "private",
|
|
69
|
+
color: user.color,
|
|
70
|
+
firstName: user.firstName,
|
|
71
|
+
lastName: user.lastName,
|
|
72
|
+
username: user.username,
|
|
73
|
+
also: user.also,
|
|
74
|
+
isScam: user.isScam,
|
|
75
|
+
isFake: user.isFake,
|
|
76
|
+
isSupport: user.isSupport,
|
|
77
|
+
isVerified: user.isVerified,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
-
* Copyright (C) 2023-2025 Roj <https://roj.im/>
|
|
4
|
-
*
|
|
5
|
-
* This file is part of MTKruto.
|
|
6
|
-
*
|
|
7
|
-
* This program is free software: you can redistribute it and/or modify
|
|
8
|
-
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
-
* (at your option) any later version.
|
|
11
|
-
*
|
|
12
|
-
* This program is distributed in the hope that it will be useful,
|
|
13
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
* GNU Lesser General Public License for more details.
|
|
16
|
-
*
|
|
17
|
-
* You should have received a copy of the GNU Lesser General Public License
|
|
18
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
-
*/
|
|
20
1
|
export declare function drop(maybePromise: unknown): void;
|
|
21
2
|
export declare function mustPrompt(message: string): string;
|
|
22
3
|
export declare function mustPromptNumber(message: string): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_misc.d.ts","sourceRoot":"","sources":["../../src/utilities/0_misc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"0_misc.d.ts","sourceRoot":"","sources":["../../src/utilities/0_misc.ts"],"names":[],"mappings":"AAwBA,wBAAgB,IAAI,CAAC,YAAY,EAAE,OAAO,QAIzC;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,UAOzC;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,UAO/C;AAED,wBAAgB,eAAe,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAMnG;AAED,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAE9C,eAAO,MAAM,kBAAkB,YAAa,CAAC;AAE7C,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,UAEzC;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,QAE7C;AAED,wBAAuB,qBAAqB,CAAC,MAAM,EAAE,cAAc,sCAWlE"}
|
|
@@ -1,4 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.VECTOR_CONSTRUCTOR = exports.ZERO_CHANNEL_ID = void 0;
|
|
27
|
+
exports.drop = drop;
|
|
28
|
+
exports.mustPrompt = mustPrompt;
|
|
29
|
+
exports.mustPromptNumber = mustPromptNumber;
|
|
30
|
+
exports.mustPromptOneOf = mustPromptOneOf;
|
|
31
|
+
exports.toUnixTimestamp = toUnixTimestamp;
|
|
32
|
+
exports.fromUnixTimestamp = fromUnixTimestamp;
|
|
33
|
+
exports.iterateReadableStream = iterateReadableStream;
|
|
2
34
|
/**
|
|
3
35
|
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
4
36
|
* Copyright (C) 2023-2025 Roj <https://roj.im/>
|
|
@@ -18,15 +50,7 @@
|
|
|
18
50
|
* You should have received a copy of the GNU Lesser General Public License
|
|
19
51
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
52
|
*/
|
|
21
|
-
|
|
22
|
-
exports.VECTOR_CONSTRUCTOR = exports.ZERO_CHANNEL_ID = void 0;
|
|
23
|
-
exports.drop = drop;
|
|
24
|
-
exports.mustPrompt = mustPrompt;
|
|
25
|
-
exports.mustPromptNumber = mustPromptNumber;
|
|
26
|
-
exports.mustPromptOneOf = mustPromptOneOf;
|
|
27
|
-
exports.toUnixTimestamp = toUnixTimestamp;
|
|
28
|
-
exports.fromUnixTimestamp = fromUnixTimestamp;
|
|
29
|
-
exports.iterateReadableStream = iterateReadableStream;
|
|
53
|
+
const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
30
54
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
31
55
|
function drop(maybePromise) {
|
|
32
56
|
if (maybePromise !== undefined && maybePromise != null && typeof maybePromise === "object" && maybePromise instanceof Promise) {
|
|
@@ -34,7 +58,7 @@ function drop(maybePromise) {
|
|
|
34
58
|
}
|
|
35
59
|
}
|
|
36
60
|
function mustPrompt(message) {
|
|
37
|
-
const result = prompt(message);
|
|
61
|
+
const result = dntShim.prompt(message);
|
|
38
62
|
if (result == null) {
|
|
39
63
|
throw (0, _0_deps_js_1.unreachable)();
|
|
40
64
|
}
|
|
@@ -51,9 +75,9 @@ function mustPromptNumber(message) {
|
|
|
51
75
|
return result;
|
|
52
76
|
}
|
|
53
77
|
function mustPromptOneOf(message, choices) {
|
|
54
|
-
let result = prompt(message);
|
|
78
|
+
let result = dntShim.prompt(message);
|
|
55
79
|
while (result == null || !choices.includes(result)) {
|
|
56
|
-
result = prompt(message);
|
|
80
|
+
result = dntShim.prompt(message);
|
|
57
81
|
}
|
|
58
82
|
return result;
|
|
59
83
|
}
|