@mtkruto/node 0.114.0 → 0.116.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 +7 -1
- package/esm/3_types.d.ts.map +1 -1
- package/esm/3_types.js +7 -1
- package/esm/client/0_params.d.ts +4 -0
- package/esm/client/0_params.d.ts.map +1 -1
- package/esm/client/1_client_generic.d.ts +51 -30
- package/esm/client/1_client_generic.d.ts.map +1 -1
- package/esm/client/2_account_manager.d.ts +13 -4
- package/esm/client/2_account_manager.d.ts.map +1 -1
- package/esm/client/2_account_manager.js +44 -7
- package/esm/client/2_bot_info_manager.d.ts +9 -2
- package/esm/client/2_bot_info_manager.d.ts.map +1 -1
- package/esm/client/2_bot_info_manager.js +14 -0
- package/esm/client/2_context.d.ts +332 -280
- package/esm/client/2_context.d.ts.map +1 -1
- package/esm/client/2_context.js +608 -517
- package/esm/client/3_filters.d.ts +1 -1
- package/esm/client/3_filters.d.ts.map +1 -1
- package/esm/client/3_message_manager.d.ts +2 -8
- package/esm/client/3_message_manager.d.ts.map +1 -1
- package/esm/client/3_message_manager.js +6 -44
- package/esm/client/4_checklist_manager.d.ts +38 -0
- package/esm/client/4_checklist_manager.d.ts.map +1 -0
- package/esm/client/4_checklist_manager.js +68 -0
- package/esm/client/4_gift_manager.d.ts +1 -0
- package/esm/client/4_gift_manager.d.ts.map +1 -1
- package/esm/client/4_gift_manager.js +6 -0
- package/esm/client/5_client.d.ts +51 -30
- package/esm/client/5_client.d.ts.map +1 -1
- package/esm/client/5_client.js +84 -44
- package/esm/client/5_client_dispatcher.d.ts +51 -30
- package/esm/client/5_client_dispatcher.d.ts.map +1 -1
- package/esm/client/5_client_dispatcher.js +68 -38
- package/esm/types/0_emoji_status.d.ts +45 -0
- package/esm/types/0_emoji_status.d.ts.map +1 -0
- package/esm/types/0_emoji_status.js +33 -0
- package/esm/types/0_input_emoji_status.d.ts +33 -0
- package/esm/types/0_input_emoji_status.d.ts.map +1 -0
- package/esm/types/0_user_status.d.ts +64 -0
- package/esm/types/0_user_status.d.ts.map +1 -0
- package/esm/types/0_user_status.js +35 -0
- package/esm/types/{0_working_hour_interval.d.ts → 0_working_hours_interval.d.ts} +2 -2
- package/esm/types/0_working_hours_interval.d.ts.map +1 -0
- package/esm/types/0_working_hours_interval.js +20 -0
- package/esm/types/1_bot_commands.d.ts +30 -0
- package/esm/types/1_bot_commands.d.ts.map +1 -0
- package/esm/types/1_bot_commands.js +20 -0
- package/esm/types/1_chat_p.d.ts +6 -0
- package/esm/types/1_chat_p.d.ts.map +1 -1
- package/esm/types/1_chat_p.js +4 -0
- package/esm/types/1_working_hours.d.ts +2 -2
- package/esm/types/1_working_hours.d.ts.map +1 -1
- package/esm/types/2_user.d.ts +6 -0
- package/esm/types/2_user.d.ts.map +1 -1
- package/esm/types/2_user.js +5 -0
- package/esm/types/3_reply_quote.d.ts +1 -1
- package/esm/types/3_reply_quote.d.ts.map +1 -1
- package/esm/types/4_gift.d.ts +1 -1
- package/esm/types/4_gift.d.ts.map +1 -1
- package/esm/types/5_claimed_gift.d.ts +1 -1
- package/esm/types/5_claimed_gift.js +1 -1
- package/esm/types/5_gift_non_upgraded_information.d.ts +47 -0
- package/esm/types/5_gift_non_upgraded_information.d.ts.map +1 -0
- package/esm/types/5_gift_non_upgraded_information.js +69 -0
- package/esm/types/5_gift_upgraded_information.d.ts +41 -0
- package/esm/types/5_gift_upgraded_information.d.ts.map +1 -0
- package/esm/types/5_gift_upgraded_information.js +58 -0
- package/esm/types/6_message.d.ts +21 -1
- package/esm/types/6_message.d.ts.map +1 -1
- package/esm/types/6_message.js +12 -0
- package/esm/types/8_update.d.ts +60 -2
- package/esm/types/8_update.d.ts.map +1 -1
- package/package.json +1 -1
- package/script/3_types.d.ts +7 -1
- package/script/3_types.d.ts.map +1 -1
- package/script/3_types.js +7 -1
- package/script/client/0_params.d.ts +4 -0
- package/script/client/0_params.d.ts.map +1 -1
- package/script/client/1_client_generic.d.ts +51 -30
- package/script/client/1_client_generic.d.ts.map +1 -1
- package/script/client/2_account_manager.d.ts +13 -4
- package/script/client/2_account_manager.d.ts.map +1 -1
- package/script/client/2_account_manager.js +43 -6
- package/script/client/2_bot_info_manager.d.ts +9 -2
- package/script/client/2_bot_info_manager.d.ts.map +1 -1
- package/script/client/2_bot_info_manager.js +14 -0
- package/script/client/2_context.d.ts +332 -280
- package/script/client/2_context.d.ts.map +1 -1
- package/script/client/2_context.js +608 -517
- package/script/client/3_filters.d.ts +1 -1
- package/script/client/3_filters.d.ts.map +1 -1
- package/script/client/3_message_manager.d.ts +2 -8
- package/script/client/3_message_manager.d.ts.map +1 -1
- package/script/client/3_message_manager.js +6 -44
- package/script/client/4_checklist_manager.d.ts +38 -0
- package/script/client/4_checklist_manager.d.ts.map +1 -0
- package/script/client/4_checklist_manager.js +72 -0
- package/script/client/4_gift_manager.d.ts +1 -0
- package/script/client/4_gift_manager.d.ts.map +1 -1
- package/script/client/4_gift_manager.js +6 -0
- package/script/client/5_client.d.ts +51 -30
- package/script/client/5_client.d.ts.map +1 -1
- package/script/client/5_client.js +84 -44
- package/script/client/5_client_dispatcher.d.ts +51 -30
- package/script/client/5_client_dispatcher.d.ts.map +1 -1
- package/script/client/5_client_dispatcher.js +68 -38
- package/script/types/0_emoji_status.d.ts +45 -0
- package/script/types/0_emoji_status.d.ts.map +1 -0
- package/script/types/0_emoji_status.js +36 -0
- package/script/types/0_input_emoji_status.d.ts +33 -0
- package/script/types/0_input_emoji_status.d.ts.map +1 -0
- package/script/types/0_user_status.d.ts +64 -0
- package/script/types/0_user_status.d.ts.map +1 -0
- package/script/types/0_user_status.js +38 -0
- package/script/types/{0_working_hour_interval.d.ts → 0_working_hours_interval.d.ts} +2 -2
- package/script/types/0_working_hours_interval.d.ts.map +1 -0
- package/script/types/0_working_hours_interval.js +21 -0
- package/script/types/1_bot_commands.d.ts +30 -0
- package/script/types/1_bot_commands.d.ts.map +1 -0
- package/script/types/1_bot_commands.js +21 -0
- package/script/types/1_chat_p.d.ts +6 -0
- package/script/types/1_chat_p.d.ts.map +1 -1
- package/script/types/1_chat_p.js +4 -0
- package/script/types/1_working_hours.d.ts +2 -2
- package/script/types/1_working_hours.d.ts.map +1 -1
- package/script/types/2_user.d.ts +6 -0
- package/script/types/2_user.d.ts.map +1 -1
- package/script/types/2_user.js +5 -0
- package/script/types/3_reply_quote.d.ts +1 -1
- package/script/types/3_reply_quote.d.ts.map +1 -1
- package/script/types/4_gift.d.ts +1 -1
- package/script/types/4_gift.d.ts.map +1 -1
- package/script/types/5_claimed_gift.d.ts +1 -1
- package/script/types/5_claimed_gift.js +1 -1
- package/script/types/5_gift_non_upgraded_information.d.ts +47 -0
- package/script/types/5_gift_non_upgraded_information.d.ts.map +1 -0
- package/script/types/5_gift_non_upgraded_information.js +72 -0
- package/script/types/5_gift_upgraded_information.d.ts +41 -0
- package/script/types/5_gift_upgraded_information.d.ts.map +1 -0
- package/script/types/5_gift_upgraded_information.js +61 -0
- package/script/types/6_message.d.ts +21 -1
- package/script/types/6_message.d.ts.map +1 -1
- package/script/types/6_message.js +12 -0
- package/script/types/8_update.d.ts +60 -2
- package/script/types/8_update.d.ts.map +1 -1
- package/esm/types/0_working_hour_interval.d.ts.map +0 -1
- package/script/types/0_working_hour_interval.d.ts.map +0 -1
- /package/esm/types/{0_working_hour_interval.js → 0_input_emoji_status.js} +0 -0
- /package/script/types/{0_working_hour_interval.js → 0_input_emoji_status.js} +0 -0
|
@@ -21,14 +21,20 @@ import { unreachable } from "../0_deps.js";
|
|
|
21
21
|
import { InputError } from "../0_errors.js";
|
|
22
22
|
import { Api } from "../2_tl.js";
|
|
23
23
|
import { PasswordHashInvalid, PhoneCodeInvalid, SessionPasswordNeeded } from "../3_errors.js";
|
|
24
|
-
import { birthdayToTlObject, constructInactiveChat, constructUser, workingHoursToTlObject } from "../3_types.js";
|
|
24
|
+
import { birthdayToTlObject, constructEmojiStatus, constructInactiveChat, constructUser, workingHoursToTlObject } from "../3_types.js";
|
|
25
25
|
import { checkPassword } from "./0_password.js";
|
|
26
26
|
import { canBeInputChannel, canBeInputUser, toInputChannel, toInputUser } from "./0_utilities.js";
|
|
27
|
+
const accountManagerUpdates = [
|
|
28
|
+
"updateUserEmojiStatus",
|
|
29
|
+
];
|
|
27
30
|
export class AccountManager {
|
|
28
31
|
#c;
|
|
29
32
|
constructor(c) {
|
|
30
33
|
this.#c = c;
|
|
31
34
|
}
|
|
35
|
+
canHandleUpdate(update) {
|
|
36
|
+
return Api.isOneOf(accountManagerUpdates, update);
|
|
37
|
+
}
|
|
32
38
|
async #toggleUsername(id, username, active) {
|
|
33
39
|
const peer = await this.#c.getInputPeer(id);
|
|
34
40
|
if (Api.is("inputPeerSelf", peer)) {
|
|
@@ -105,21 +111,42 @@ export class AccountManager {
|
|
|
105
111
|
this.#c.storage.assertUser("setOnline");
|
|
106
112
|
await this.#c.invoke({ _: "account.updateStatus", offline: !online });
|
|
107
113
|
}
|
|
108
|
-
async setEmojiStatus(
|
|
114
|
+
async setEmojiStatus(emojiStatus, params) {
|
|
109
115
|
this.#c.storage.assertUser("setEmojiStatus");
|
|
110
|
-
|
|
116
|
+
let emoji_status;
|
|
111
117
|
const until = params?.until;
|
|
112
|
-
|
|
118
|
+
if (emojiStatus.type === "customEmoji") {
|
|
119
|
+
const document_id = BigInt(emojiStatus.customEmojiId);
|
|
120
|
+
emoji_status = { _: "emojiStatus", document_id, until };
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
emoji_status = { _: "inputEmojiStatusCollectible", collectible_id: BigInt(emojiStatus.giftId), until };
|
|
124
|
+
}
|
|
113
125
|
await this.#c.invoke({ _: "account.updateEmojiStatus", emoji_status });
|
|
114
126
|
}
|
|
115
|
-
async
|
|
127
|
+
async removeEmojiStatus() {
|
|
128
|
+
this.#c.storage.assertUser("removeEmojiStatus");
|
|
129
|
+
await this.#c.invoke({ _: "account.updateEmojiStatus", emoji_status: { _: "emojiStatusEmpty" } });
|
|
130
|
+
}
|
|
131
|
+
async setUserEmojiStatus(userId, emojiStatus, params) {
|
|
116
132
|
this.#c.storage.assertBot("setUserEmojiStatus");
|
|
117
133
|
const user_id = await this.#c.getInputUser(userId);
|
|
118
|
-
const document_id = BigInt(id);
|
|
119
134
|
const until = params?.until;
|
|
120
|
-
|
|
135
|
+
let emoji_status;
|
|
136
|
+
if (emojiStatus.type === "customEmoji") {
|
|
137
|
+
const document_id = BigInt(emojiStatus.customEmojiId);
|
|
138
|
+
emoji_status = { _: "emojiStatus", document_id, until };
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
emoji_status = { _: "inputEmojiStatusCollectible", collectible_id: BigInt(emojiStatus.giftId), until };
|
|
142
|
+
}
|
|
121
143
|
await this.#c.invoke({ _: "bots.updateUserEmojiStatus", user_id, emoji_status });
|
|
122
144
|
}
|
|
145
|
+
async removeUserEmojiStatus(userId) {
|
|
146
|
+
this.#c.storage.assertBot("removeUserEmojiStatus");
|
|
147
|
+
const user_id = await this.#c.getInputUser(userId);
|
|
148
|
+
await this.#c.invoke({ _: "bots.updateUserEmojiStatus", user_id, emoji_status: { _: "emojiStatusEmpty" } });
|
|
149
|
+
}
|
|
123
150
|
async setBotCanSetEmojiStatus(botId, canSetEmojiStatus) {
|
|
124
151
|
this.#c.storage.assertUser("setBotCanSetEmojiStatus");
|
|
125
152
|
const bot = await this.#c.getInputUser(botId);
|
|
@@ -361,4 +388,14 @@ export class AccountManager {
|
|
|
361
388
|
this.#c.storage.assertUser("resumeBusinessBotConnection");
|
|
362
389
|
await this.#setIsBusinessBotConnectionPaused(chatId, false);
|
|
363
390
|
}
|
|
391
|
+
handleUpdate(update) {
|
|
392
|
+
const userId = Number(update.user_id);
|
|
393
|
+
if (Api.is("emojiStatusEmpty", update.emoji_status)) {
|
|
394
|
+
return { emojiStatusRemoved: true, userId };
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
const emojiStatus = constructEmojiStatus(update.emoji_status);
|
|
398
|
+
return { emojiStatus, userId };
|
|
399
|
+
}
|
|
400
|
+
}
|
|
364
401
|
}
|
|
@@ -17,12 +17,17 @@
|
|
|
17
17
|
* You should have received a copy of the GNU Lesser General Public License
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
|
-
import {
|
|
20
|
+
import { Api } from "../2_tl.js";
|
|
21
|
+
import { type BotCommand, type Update } from "../3_types.js";
|
|
21
22
|
import type { GetMyCommandsParams, SetMyCommandsParams } from "./0_params.js";
|
|
23
|
+
import type { UpdateProcessor } from "./0_update_processor.js";
|
|
22
24
|
import type { C } from "./1_types.js";
|
|
23
|
-
|
|
25
|
+
declare const botInfoManagerUpdates: readonly ["updateBotCommands"];
|
|
26
|
+
type BotInfoManagerUpdate = Api.Types[(typeof botInfoManagerUpdates)[number]];
|
|
27
|
+
export declare class BotInfoManager implements UpdateProcessor<BotInfoManagerUpdate, false> {
|
|
24
28
|
#private;
|
|
25
29
|
constructor(c: C);
|
|
30
|
+
canHandleUpdate(update: Api.Update): update is BotInfoManagerUpdate;
|
|
26
31
|
setMyDescription(params?: {
|
|
27
32
|
description?: string;
|
|
28
33
|
languageCode?: string;
|
|
@@ -46,5 +51,7 @@ export declare class BotInfoManager {
|
|
|
46
51
|
}): Promise<string>;
|
|
47
52
|
getMyCommands(params?: GetMyCommandsParams): Promise<BotCommand[]>;
|
|
48
53
|
setMyCommands(commands: BotCommand[], params?: SetMyCommandsParams): Promise<void>;
|
|
54
|
+
handleUpdate(update: BotInfoManagerUpdate): Update;
|
|
49
55
|
}
|
|
56
|
+
export {};
|
|
50
57
|
//# sourceMappingURL=2_bot_info_manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"2_bot_info_manager.d.ts","sourceRoot":"","sources":["../../src/client/2_bot_info_manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"2_bot_info_manager.d.ts","s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AE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAK9D,qBAAqB,CAAC,MAAM,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAK1E,aAAa,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAUlE,aAAa,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,MAAM,CAAC,EAAE,mBAAmB;IAUxE,YAAY,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM;CAMnD"}
|
|
@@ -17,12 +17,20 @@
|
|
|
17
17
|
* You should have received a copy of the GNU Lesser General Public License
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
|
+
import { Api } from "../2_tl.js";
|
|
20
21
|
import { botCommandScopeToTlObject } from "../3_types.js";
|
|
22
|
+
import { peerToChatId } from "../tl/2_telegram.js";
|
|
23
|
+
const botInfoManagerUpdates = [
|
|
24
|
+
"updateBotCommands",
|
|
25
|
+
];
|
|
21
26
|
export class BotInfoManager {
|
|
22
27
|
#c;
|
|
23
28
|
constructor(c) {
|
|
24
29
|
this.#c = c;
|
|
25
30
|
}
|
|
31
|
+
canHandleUpdate(update) {
|
|
32
|
+
return Api.isOneOf(botInfoManagerUpdates, update);
|
|
33
|
+
}
|
|
26
34
|
async #setMyInfo(info) {
|
|
27
35
|
await this.#c.invoke({ _: "bots.setBotInfo", ...info });
|
|
28
36
|
}
|
|
@@ -71,4 +79,10 @@ export class BotInfoManager {
|
|
|
71
79
|
scope: await botCommandScopeToTlObject(params?.scope ?? { type: "default" }, this.#c.getInputPeer),
|
|
72
80
|
});
|
|
73
81
|
}
|
|
82
|
+
handleUpdate(update) {
|
|
83
|
+
const botId = Number(update.bot_id);
|
|
84
|
+
const chatId = peerToChatId(update.peer);
|
|
85
|
+
const commands = update.commands;
|
|
86
|
+
return { botCommands: { botId, chatId, commands } };
|
|
87
|
+
}
|
|
74
88
|
}
|