@mtkruto/node 0.101.2 → 0.102.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 +2 -0
- package/esm/3_types.d.ts.map +1 -1
- package/esm/3_types.js +2 -0
- 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 +32 -5
- package/esm/client/1_client_generic.d.ts.map +1 -1
- package/esm/client/2_account_manager.d.ts +4 -1
- package/esm/client/2_account_manager.d.ts.map +1 -1
- package/esm/client/2_account_manager.js +18 -0
- package/esm/client/2_update_manager.js +7 -7
- package/esm/client/3_message_manager.js +17 -17
- package/esm/client/3_video_chat_manager.js +3 -3
- package/esm/client/4_chat_manager.js +3 -3
- package/esm/client/4_gift_manager.d.ts +3 -2
- package/esm/client/4_gift_manager.d.ts.map +1 -1
- package/esm/client/4_gift_manager.js +8 -7
- package/esm/client/5_client.d.ts +32 -5
- package/esm/client/5_client.d.ts.map +1 -1
- package/esm/client/5_client.js +39 -4
- package/esm/client/5_client_dispatcher.d.ts +32 -5
- package/esm/client/5_client_dispatcher.d.ts.map +1 -1
- package/esm/client/5_client_dispatcher.js +39 -4
- package/esm/types/0_button_style.d.ts +28 -0
- package/esm/types/0_button_style.d.ts.map +1 -0
- package/esm/types/0_button_style.js +36 -0
- package/esm/types/0_code_check_result.d.ts +14 -16
- package/esm/types/0_code_check_result.d.ts.map +1 -1
- package/esm/types/0_gift_component_rarity.d.ts +5 -0
- package/esm/types/0_gift_component_rarity.d.ts.map +1 -1
- package/esm/types/0_link_preview_media_size.d.ts +1 -0
- package/esm/types/0_link_preview_media_size.d.ts.map +1 -1
- package/esm/types/0_mini_app_button_info.d.ts +1 -0
- package/esm/types/0_mini_app_button_info.d.ts.map +1 -1
- package/esm/types/0_slow_mode_duration.d.ts +1 -0
- package/esm/types/0_slow_mode_duration.d.ts.map +1 -1
- package/esm/types/0_switch_inline_query_chosen_chats.d.ts +1 -0
- package/esm/types/0_switch_inline_query_chosen_chats.d.ts.map +1 -1
- package/esm/types/1_bot_command_scope.js +1 -1
- package/esm/types/1_inline_keyboard_button.d.ts +2 -0
- package/esm/types/1_inline_keyboard_button.d.ts.map +1 -1
- package/esm/types/1_inline_keyboard_button.js +30 -19
- package/esm/types/1_input_gift.d.ts +54 -0
- package/esm/types/1_input_gift.d.ts.map +1 -0
- package/esm/types/1_input_gift.js +32 -0
- package/esm/types/1_keyboard_button.d.ts +2 -0
- package/esm/types/1_keyboard_button.d.ts.map +1 -1
- package/esm/types/1_keyboard_button.js +67 -14
- package/esm/types/2_message_entity.js +2 -2
- package/esm/types/7_inline_query_result.js +6 -6
- package/package.json +1 -1
- package/script/3_types.d.ts +2 -0
- package/script/3_types.d.ts.map +1 -1
- package/script/3_types.js +2 -0
- 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 +32 -5
- package/script/client/1_client_generic.d.ts.map +1 -1
- package/script/client/2_account_manager.d.ts +4 -1
- package/script/client/2_account_manager.d.ts.map +1 -1
- package/script/client/2_account_manager.js +18 -0
- package/script/client/2_update_manager.js +7 -7
- package/script/client/3_message_manager.js +17 -17
- package/script/client/3_video_chat_manager.js +3 -3
- package/script/client/4_chat_manager.js +3 -3
- package/script/client/4_gift_manager.d.ts +3 -2
- package/script/client/4_gift_manager.d.ts.map +1 -1
- package/script/client/4_gift_manager.js +7 -6
- package/script/client/5_client.d.ts +32 -5
- package/script/client/5_client.d.ts.map +1 -1
- package/script/client/5_client.js +39 -4
- package/script/client/5_client_dispatcher.d.ts +32 -5
- package/script/client/5_client_dispatcher.d.ts.map +1 -1
- package/script/client/5_client_dispatcher.js +39 -4
- package/script/types/0_button_style.d.ts +28 -0
- package/script/types/0_button_style.d.ts.map +1 -0
- package/script/types/0_button_style.js +40 -0
- package/script/types/0_code_check_result.d.ts +14 -16
- package/script/types/0_code_check_result.d.ts.map +1 -1
- package/script/types/0_gift_component_rarity.d.ts +5 -0
- package/script/types/0_gift_component_rarity.d.ts.map +1 -1
- package/script/types/0_link_preview_media_size.d.ts +1 -0
- package/script/types/0_link_preview_media_size.d.ts.map +1 -1
- package/script/types/0_mini_app_button_info.d.ts +1 -0
- package/script/types/0_mini_app_button_info.d.ts.map +1 -1
- package/script/types/0_slow_mode_duration.d.ts +1 -0
- package/script/types/0_slow_mode_duration.d.ts.map +1 -1
- package/script/types/0_switch_inline_query_chosen_chats.d.ts +1 -0
- package/script/types/0_switch_inline_query_chosen_chats.d.ts.map +1 -1
- package/script/types/1_bot_command_scope.js +1 -1
- package/script/types/1_inline_keyboard_button.d.ts +2 -0
- package/script/types/1_inline_keyboard_button.d.ts.map +1 -1
- package/script/types/1_inline_keyboard_button.js +30 -19
- package/script/types/1_input_gift.d.ts +54 -0
- package/script/types/1_input_gift.d.ts.map +1 -0
- package/script/types/1_input_gift.js +35 -0
- package/script/types/1_keyboard_button.d.ts +2 -0
- package/script/types/1_keyboard_button.d.ts.map +1 -1
- package/script/types/1_keyboard_button.js +67 -14
- package/script/types/2_message_entity.js +2 -2
- package/script/types/7_inline_query_result.js +6 -6
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
4
|
+
* Copyright (C) 2023-2026 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.constructButtonStyle = constructButtonStyle;
|
|
23
|
+
exports.buttonStyleToTlObject = buttonStyleToTlObject;
|
|
24
|
+
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
25
|
+
function constructButtonStyle(buttonStyle) {
|
|
26
|
+
if (buttonStyle === undefined || !buttonStyle.bg_danger && !buttonStyle.bg_primary && !buttonStyle.bg_success && !buttonStyle.icon) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
const buttonStyle_ = {
|
|
30
|
+
background: buttonStyle.bg_danger ? "danger" : buttonStyle.bg_primary ? "primary" : buttonStyle.bg_success ? "success" : undefined,
|
|
31
|
+
customEmojiId: buttonStyle.icon ? String(buttonStyle.icon) : undefined,
|
|
32
|
+
};
|
|
33
|
+
return (0, _1_utilities_js_1.cleanObject)(buttonStyle_);
|
|
34
|
+
}
|
|
35
|
+
function buttonStyleToTlObject(buttonStyle) {
|
|
36
|
+
if (buttonStyle === undefined) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
return { _: "keyboardButtonStyle", bg_danger: buttonStyle.background === "danger" ? true : undefined, bg_primary: buttonStyle.background === "primary" ? true : undefined, bg_success: buttonStyle.background === "success" ? true : undefined, icon: buttonStyle.customEmojiId ? BigInt(buttonStyle.customEmojiId) : undefined };
|
|
40
|
+
}
|
|
@@ -17,21 +17,19 @@
|
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
type: "password_required";
|
|
24
|
-
}
|
|
25
|
-
/** The code entered was incorrect. */
|
|
26
|
-
interface InvalidCode {
|
|
27
|
-
type: "invalid_code";
|
|
28
|
-
}
|
|
29
|
-
/** The code was correct. The user was signed in. */
|
|
30
|
-
interface SignedIn {
|
|
31
|
-
type: "signed_in";
|
|
32
|
-
userId: number;
|
|
33
|
-
}
|
|
20
|
+
/** The code was correct, but an additional password is required to sign in. */
|
|
21
|
+
export interface CodeCheckResultPasswordRequired {
|
|
22
|
+
type: "password_required";
|
|
34
23
|
}
|
|
35
|
-
/**
|
|
36
|
-
export
|
|
24
|
+
/** The code entered was incorrect. */
|
|
25
|
+
export interface CodeCheckResultInvalidCode {
|
|
26
|
+
type: "invalid_code";
|
|
27
|
+
}
|
|
28
|
+
/** The code was correct. The user was signed in. */
|
|
29
|
+
export interface CodeCheckResultSignedIn {
|
|
30
|
+
type: "signed_in";
|
|
31
|
+
userId: number;
|
|
32
|
+
}
|
|
33
|
+
/** The result after checking a sent code. */
|
|
34
|
+
export type CodeCheckResult = CodeCheckResultPasswordRequired | CodeCheckResultInvalidCode | CodeCheckResultSignedIn;
|
|
37
35
|
//# sourceMappingURL=0_code_check_result.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_code_check_result.d.ts","sourceRoot":"","sources":["../../src/types/0_code_check_result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH
|
|
1
|
+
{"version":3,"file":"0_code_check_result.d.ts","sourceRoot":"","sources":["../../src/types/0_code_check_result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,+EAA+E;AAC/E,MAAM,WAAW,+BAA+B;IAC9C,IAAI,EAAE,mBAAmB,CAAC;CAC3B;AAED,sCAAsC;AACtC,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,oDAAoD;AACpD,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,6CAA6C;AAC7C,MAAM,MAAM,eAAe,GAAG,+BAA+B,GAAG,0BAA0B,GAAG,uBAAuB,CAAC"}
|
|
@@ -18,19 +18,24 @@
|
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
20
|
import type { Api } from "../2_tl.js";
|
|
21
|
+
/** @unlisted */
|
|
21
22
|
export interface GiftComponentRarityPerMille {
|
|
22
23
|
type: "perMille";
|
|
23
24
|
perMille: number;
|
|
24
25
|
}
|
|
26
|
+
/** @unlisted */
|
|
25
27
|
export interface GiftComponentRarityUncommon {
|
|
26
28
|
type: "uncommon";
|
|
27
29
|
}
|
|
30
|
+
/** @unlisted */
|
|
28
31
|
export interface GiftComponentRarityRare {
|
|
29
32
|
type: "rare";
|
|
30
33
|
}
|
|
34
|
+
/** @unlisted */
|
|
31
35
|
export interface GiftComponentRarityEpic {
|
|
32
36
|
type: "epic";
|
|
33
37
|
}
|
|
38
|
+
/** @unlisted */
|
|
34
39
|
export interface GiftComponentRarityLegendary {
|
|
35
40
|
type: "legendary";
|
|
36
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_gift_component_rarity.d.ts","sourceRoot":"","sources":["../../src/types/0_gift_component_rarity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,MAAM,mBAAmB,GAAG,2BAA2B,GAAG,2BAA2B,GAAG,uBAAuB,GAAG,uBAAuB,GAAG,4BAA4B,CAAC;AAE/K,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,GAAG,CAAC,uBAAuB,GAAG,mBAAmB,CAsBrG"}
|
|
1
|
+
{"version":3,"file":"0_gift_component_rarity.d.ts","sourceRoot":"","sources":["../../src/types/0_gift_component_rarity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,gBAAgB;AAChB,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,gBAAgB;AAChB,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,gBAAgB;AAChB,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,gBAAgB;AAChB,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,gBAAgB;AAChB,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,MAAM,mBAAmB,GAAG,2BAA2B,GAAG,2BAA2B,GAAG,uBAAuB,GAAG,uBAAuB,GAAG,4BAA4B,CAAC;AAE/K,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,GAAG,CAAC,uBAAuB,GAAG,mBAAmB,CAsBrG"}
|
|
@@ -17,5 +17,6 @@
|
|
|
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
|
+
/** The size of a link preview's media. */
|
|
20
21
|
export type LinkPreviewMediaSize = "small" | "large";
|
|
21
22
|
//# sourceMappingURL=0_link_preview_media_size.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_link_preview_media_size.d.ts","sourceRoot":"","sources":["../../src/types/0_link_preview_media_size.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"0_link_preview_media_size.d.ts","sourceRoot":"","sources":["../../src/types/0_link_preview_media_size.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,0CAA0C;AAC1C,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,OAAO,CAAC"}
|
|
@@ -17,6 +17,7 @@
|
|
|
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
|
+
/** Information on a mini app button. */
|
|
20
21
|
export interface MiniAppButtonInfo {
|
|
21
22
|
/** An HTTPS URL of the mini app to be opened with additional data. */
|
|
22
23
|
url: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_mini_app_button_info.d.ts","sourceRoot":"","sources":["../../src/types/0_mini_app_button_info.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAEzE"}
|
|
1
|
+
{"version":3,"file":"0_mini_app_button_info.d.ts","sourceRoot":"","sources":["../../src/types/0_mini_app_button_info.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,wCAAwC;AACxC,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAEzE"}
|
|
@@ -17,6 +17,7 @@
|
|
|
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
|
+
/** A slow mode duration option. */
|
|
20
21
|
export type SlowModeDuration = "10s" | "30s" | "1m" | "5m" | "15m" | "1h";
|
|
21
22
|
export declare function slowModeDurationToSeconds(duration: SlowModeDuration): number;
|
|
22
23
|
//# sourceMappingURL=0_slow_mode_duration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_slow_mode_duration.d.ts","sourceRoot":"","sources":["../../src/types/0_slow_mode_duration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,MAAM,gBAAgB,GACxB,KAAK,GACL,KAAK,GACL,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,IAAI,CAAC;AAET,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,CAQ5E"}
|
|
1
|
+
{"version":3,"file":"0_slow_mode_duration.d.ts","sourceRoot":"","sources":["../../src/types/0_slow_mode_duration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,mCAAmC;AACnC,MAAM,MAAM,gBAAgB,GACxB,KAAK,GACL,KAAK,GACL,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,IAAI,CAAC;AAET,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,CAQ5E"}
|
|
@@ -17,6 +17,7 @@
|
|
|
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
|
+
/** Configuration for switching to inline mode in specific chat types. */
|
|
20
21
|
export interface SwitchInlineQueryChosenChats {
|
|
21
22
|
/** The query to type into the user's message box once switched to inline. */
|
|
22
23
|
query: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_switch_inline_query_chosen_chats.d.ts","sourceRoot":"","sources":["../../src/types/0_switch_inline_query_chosen_chats.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,WAAW,4BAA4B;IAC3C,6EAA6E;IAC7E,KAAK,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kEAAkE;IAClE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2DAA2D;IAC3D,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
|
|
1
|
+
{"version":3,"file":"0_switch_inline_query_chosen_chats.d.ts","sourceRoot":"","sources":["../../src/types/0_switch_inline_query_chosen_chats.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,yEAAyE;AACzE,MAAM,WAAW,4BAA4B;IAC3C,6EAA6E;IAC7E,KAAK,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kEAAkE;IAClE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2DAA2D;IAC3D,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
|
|
@@ -41,7 +41,7 @@ async function botCommandScopeToTlObject(scope, getInputPeer) {
|
|
|
41
41
|
if (!_2_tl_js_1.Api.is("inputPeerUser", user)) {
|
|
42
42
|
(0, _0_deps_js_1.unreachable)();
|
|
43
43
|
}
|
|
44
|
-
return { _: "botCommandScopePeerUser", peer: await getInputPeer(scope.chatId), user_id:
|
|
44
|
+
return { _: "botCommandScopePeerUser", peer: await getInputPeer(scope.chatId), user_id: { _: "inputUser", user_id: user.user_id, access_hash: user.access_hash } };
|
|
45
45
|
}
|
|
46
46
|
default:
|
|
47
47
|
(0, _0_deps_js_1.unreachable)();
|
|
@@ -19,12 +19,14 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { Api } from "../2_tl.js";
|
|
21
21
|
import type { UsernameResolver } from "./_getters.js";
|
|
22
|
+
import { type ButtonStyle } from "./0_button_style.js";
|
|
22
23
|
import type { LoginUrl } from "./0_login_url.js";
|
|
23
24
|
import { type MiniAppButtonInfo } from "./0_mini_app_button_info.js";
|
|
24
25
|
/** @unlisted */
|
|
25
26
|
export interface _InlineKeyboardButtonBase {
|
|
26
27
|
/** The text of the button. */
|
|
27
28
|
text: string;
|
|
29
|
+
style?: ButtonStyle;
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
30
32
|
* An inline keyboard button that, when pressed, opens the specified URL.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1_inline_keyboard_button.d.ts","sourceRoot":"","sources":["../../src/types/1_inline_keyboard_button.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAA8B,KAAK,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEjG,gBAAgB;AAChB,MAAM,WAAW,yBAAyB;IACxC,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"1_inline_keyboard_button.d.ts","sourceRoot":"","sources":["../../src/types/1_inline_keyboard_button.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,KAAK,WAAW,EAA+C,MAAM,qBAAqB,CAAC;AACpG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAA8B,KAAK,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEjG,gBAAgB;AAChB,MAAM,WAAW,yBAAyB;IACxC,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,yBAAyB;IACxE;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,MAAM,WAAW,4BAA6B,SAAQ,yBAAyB;IAC7E;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,gBAAgB;AAChB,MAAM,WAAW,2BAA4B,SAAQ,yBAAyB;IAC5E;;;OAGG;IACH,OAAO,EAAE,iBAAiB,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,yBAA0B,SAAQ,yBAAyB;IAC1E;;;OAGG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,gCAAiC,SAAQ,yBAAyB;IACjF;;;OAGG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,uCAAwC,SAAQ,yBAAyB;IACxF;;;OAGG;IACH,4BAA4B,EAAE,MAAM,CAAC;CACtC;AAED;;;GAGG;AACH,MAAM,WAAW,sCAAuC,SAAQ,yBAAyB;IACvF,qBAAqB;IACrB,4BAA4B,EAAE;QAC5B,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,aAAa,CAAC,EAAE,OAAO,CAAC;KACzB,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAyB,SAAQ,yBAAyB;IACzE,qBAAqB;IACrB,YAAY,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,yBAAyB;IACxE,qBAAqB;IACrB,GAAG,EAAE,OAAO,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAyB,SAAQ,yBAAyB;IACzE,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,sCAAsC;AACtC,MAAM,MAAM,oBAAoB,GAC5B,uBAAuB,GACvB,4BAA4B,GAC5B,2BAA2B,GAC3B,yBAAyB,GACzB,gCAAgC,GAChC,uCAAuC,GACvC,sCAAsC,GACtC,wBAAwB,GACxB,uBAAuB,GACvB,wBAAwB,CAAC;AAE7B,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,GAAG,CAAC,cAAc,GAAG,oBAAoB,CAiC/F;AAED,wBAAsB,8BAA8B,CAAC,MAAM,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAgDlJ"}
|
|
@@ -25,43 +25,45 @@ const _0_deps_js_1 = require("../0_deps.js");
|
|
|
25
25
|
const _0_errors_js_1 = require("../0_errors.js");
|
|
26
26
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
27
27
|
const _2_tl_js_1 = require("../2_tl.js");
|
|
28
|
+
const _0_button_style_js_1 = require("./0_button_style.js");
|
|
28
29
|
const _0_mini_app_button_info_js_1 = require("./0_mini_app_button_info.js");
|
|
29
30
|
function constructInlineKeyboardButton(button_) {
|
|
31
|
+
const style = (0, _0_button_style_js_1.constructButtonStyle)(button_.style);
|
|
30
32
|
if (_2_tl_js_1.Api.is("keyboardButtonUrl", button_)) {
|
|
31
|
-
return { text: button_.text, url: button_.url };
|
|
33
|
+
return (0, _1_utilities_js_1.cleanObject)({ text: button_.text, url: button_.url, style });
|
|
32
34
|
}
|
|
33
35
|
else if (_2_tl_js_1.Api.is("keyboardButtonCallback", button_)) {
|
|
34
|
-
return { text: button_.text, callbackData: (0, _1_utilities_js_1.decodeText)(button_.data) };
|
|
36
|
+
return (0, _1_utilities_js_1.cleanObject)({ text: button_.text, callbackData: (0, _1_utilities_js_1.decodeText)(button_.data), style });
|
|
35
37
|
}
|
|
36
38
|
else if (_2_tl_js_1.Api.is("keyboardButtonWebView", button_) || _2_tl_js_1.Api.is("keyboardButtonSimpleWebView", button_)) {
|
|
37
|
-
return { text: button_.text, miniApp: (0, _0_mini_app_button_info_js_1.constructMiniAppButtonInfo)(button_.url) };
|
|
39
|
+
return (0, _1_utilities_js_1.cleanObject)({ text: button_.text, miniApp: (0, _0_mini_app_button_info_js_1.constructMiniAppButtonInfo)(button_.url), style });
|
|
38
40
|
}
|
|
39
41
|
else if (_2_tl_js_1.Api.is("keyboardButtonUrlAuth", button_)) {
|
|
40
|
-
return { text: button_.text, loginUrl: { url: button_.url, forwardText: button_.fwd_text } };
|
|
42
|
+
return (0, _1_utilities_js_1.cleanObject)({ text: button_.text, loginUrl: { url: button_.url, forwardText: button_.fwd_text }, style });
|
|
41
43
|
}
|
|
42
44
|
else if (_2_tl_js_1.Api.is("keyboardButtonSwitchInline", button_)) {
|
|
43
45
|
if (button_.same_peer) {
|
|
44
|
-
return { text: button_.text, switchInlineQueryCurrentChat: button_.query };
|
|
46
|
+
return (0, _1_utilities_js_1.cleanObject)({ text: button_.text, switchInlineQueryCurrentChat: button_.query, style });
|
|
45
47
|
}
|
|
46
48
|
else if (button_.peer_types && button_.peer_types.length) {
|
|
47
49
|
const allowUsers = button_.peer_types.some((v) => v._ === "inlineQueryPeerTypeBotPM") || undefined;
|
|
48
50
|
const allowBots = button_.peer_types.some((v) => v._ === "inlineQueryPeerTypeSameBotPM" || v._ === "inlineQueryPeerTypeBotPM") || undefined;
|
|
49
51
|
const allowGroups = button_.peer_types.some((v) => v._ === "inlineQueryPeerTypeChat" || v._ === "inlineQueryPeerTypeMegagroup") || undefined;
|
|
50
52
|
const allowChannels = button_.peer_types.some((v) => v._ === "inlineQueryPeerTypeBroadcast") || undefined;
|
|
51
|
-
return (0, _1_utilities_js_1.cleanObject)({ text: button_.text, switchInlineQueryChosenChats: { query: button_.query, allowUsers, allowBots, allowGroups, allowChannels } });
|
|
53
|
+
return (0, _1_utilities_js_1.cleanObject)({ text: button_.text, switchInlineQueryChosenChats: { query: button_.query, allowUsers, allowBots, allowGroups, allowChannels }, style });
|
|
52
54
|
}
|
|
53
55
|
else {
|
|
54
|
-
return { text: button_.text, switchInlineQuery: button_.query };
|
|
56
|
+
return (0, _1_utilities_js_1.cleanObject)({ text: button_.text, switchInlineQuery: button_.query, style });
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
else if (_2_tl_js_1.Api.is("keyboardButtonBuy", button_)) {
|
|
58
|
-
return { text: button_.text, pay: true };
|
|
60
|
+
return (0, _1_utilities_js_1.cleanObject)({ text: button_.text, pay: true, style });
|
|
59
61
|
}
|
|
60
62
|
else if (_2_tl_js_1.Api.is("keyboardButtonGame", button_)) {
|
|
61
|
-
return { text: button_.text, callbackGame: {} };
|
|
63
|
+
return (0, _1_utilities_js_1.cleanObject)({ text: button_.text, callbackGame: {}, style });
|
|
62
64
|
}
|
|
63
65
|
else if (_2_tl_js_1.Api.is("keyboardButtonCopy", button_)) {
|
|
64
|
-
return { text: button_.text, copy: button_.copy_text };
|
|
66
|
+
return (0, _1_utilities_js_1.cleanObject)({ text: button_.text, copy: button_.copy_text, style });
|
|
65
67
|
}
|
|
66
68
|
else if (_2_tl_js_1.Api.is("keyboardButtonRequestPeer", button_)) {
|
|
67
69
|
(0, _0_deps_js_1.unreachable)();
|
|
@@ -71,23 +73,32 @@ function constructInlineKeyboardButton(button_) {
|
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
async function inlineKeyboardButtonToTlObject(button, usernameResolver) {
|
|
76
|
+
const style = (0, _0_button_style_js_1.buttonStyleToTlObject)(button.style);
|
|
74
77
|
if ("url" in button) {
|
|
75
|
-
return { _: "keyboardButtonUrl", text: button.text, url: button.url };
|
|
78
|
+
return { _: "keyboardButtonUrl", text: button.text, url: button.url, style };
|
|
76
79
|
}
|
|
77
80
|
else if ("callbackData" in button) {
|
|
78
|
-
return { _: "keyboardButtonCallback", text: button.text, data: (0, _1_utilities_js_1.encodeText)(button.callbackData) };
|
|
81
|
+
return { _: "keyboardButtonCallback", text: button.text, data: (0, _1_utilities_js_1.encodeText)(button.callbackData), style };
|
|
79
82
|
}
|
|
80
83
|
else if ("miniApp" in button) {
|
|
81
|
-
return { _: "keyboardButtonWebView", text: button.text, url: button.miniApp.url };
|
|
84
|
+
return { _: "keyboardButtonWebView", text: button.text, url: button.miniApp.url, style };
|
|
82
85
|
}
|
|
83
86
|
else if ("loginUrl" in button) {
|
|
84
|
-
return {
|
|
87
|
+
return {
|
|
88
|
+
_: "inputKeyboardButtonUrlAuth",
|
|
89
|
+
text: button.text,
|
|
90
|
+
url: button.loginUrl.url,
|
|
91
|
+
fwd_text: button.loginUrl.forwardText,
|
|
92
|
+
bot: button.loginUrl.botUsername ? await usernameResolver(button.loginUrl.botUsername) : { _: "inputUserSelf" },
|
|
93
|
+
request_write_access: button.loginUrl.requestWriteAccess || undefined,
|
|
94
|
+
style,
|
|
95
|
+
};
|
|
85
96
|
}
|
|
86
97
|
else if ("switchInlineQuery" in button) {
|
|
87
|
-
return { _: "keyboardButtonSwitchInline", text: button.text, query: button.switchInlineQuery };
|
|
98
|
+
return { _: "keyboardButtonSwitchInline", text: button.text, query: button.switchInlineQuery, style };
|
|
88
99
|
}
|
|
89
100
|
else if ("switchInlineQueryCurrentChat" in button) {
|
|
90
|
-
return { _: "keyboardButtonSwitchInline", text: button.text, query: button.switchInlineQueryCurrentChat, same_peer: true };
|
|
101
|
+
return { _: "keyboardButtonSwitchInline", text: button.text, query: button.switchInlineQueryCurrentChat, same_peer: true, style };
|
|
91
102
|
}
|
|
92
103
|
else if ("switchInlineQueryChosenChats" in button) {
|
|
93
104
|
const peerTypes = new Array();
|
|
@@ -107,13 +118,13 @@ async function inlineKeyboardButtonToTlObject(button, usernameResolver) {
|
|
|
107
118
|
if (allowChannels) {
|
|
108
119
|
peerTypes.push({ _: "inlineQueryPeerTypeBroadcast" });
|
|
109
120
|
}
|
|
110
|
-
return { _: "keyboardButtonSwitchInline", text: button.text, query: button.switchInlineQueryChosenChats.query, peer_types: peerTypes };
|
|
121
|
+
return { _: "keyboardButtonSwitchInline", text: button.text, query: button.switchInlineQueryChosenChats.query, peer_types: peerTypes, style };
|
|
111
122
|
}
|
|
112
123
|
else if ("pay" in button) {
|
|
113
|
-
return { _: "keyboardButtonBuy", text: button.text };
|
|
124
|
+
return { _: "keyboardButtonBuy", text: button.text, style };
|
|
114
125
|
}
|
|
115
126
|
else if ("copy" in button) {
|
|
116
|
-
return { _: "keyboardButtonCopy", text: button.text, copy_text: button.copy };
|
|
127
|
+
return { _: "keyboardButtonCopy", text: button.text, copy_text: button.copy, style };
|
|
117
128
|
}
|
|
118
129
|
else {
|
|
119
130
|
(0, _0_deps_js_1.unreachable)();
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2026 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 type { Api } from "../2_tl.js";
|
|
21
|
+
import type { InputPeerGetter } from "./_getters.js";
|
|
22
|
+
import type { ID } from "./0_id.js";
|
|
23
|
+
/**
|
|
24
|
+
* Reference to a gift by its slug.
|
|
25
|
+
* @unlisted
|
|
26
|
+
*/
|
|
27
|
+
export interface InputGiftSlug {
|
|
28
|
+
/** @discriminator */
|
|
29
|
+
type: "slug";
|
|
30
|
+
slug: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Reference to a gift in a chat by its ID.
|
|
34
|
+
* @unlisted
|
|
35
|
+
*/
|
|
36
|
+
export interface InputGiftChat {
|
|
37
|
+
/** @discriminator */
|
|
38
|
+
type: "chat";
|
|
39
|
+
chatId: ID;
|
|
40
|
+
id: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Reference to a gift in a private chat by its message ID.
|
|
44
|
+
* @unlisted
|
|
45
|
+
*/
|
|
46
|
+
export interface InputGiftUser {
|
|
47
|
+
/** @discriminator */
|
|
48
|
+
type: "user";
|
|
49
|
+
messageId: number;
|
|
50
|
+
}
|
|
51
|
+
/** Reference to a gift. */
|
|
52
|
+
export type InputGift = InputGiftSlug | InputGiftChat | InputGiftUser;
|
|
53
|
+
export declare function inputGiftToTlObject(inputGift: InputGift, getInputPeer: InputPeerGetter): Promise<Api.InputSavedStarGift>;
|
|
54
|
+
//# sourceMappingURL=1_input_gift.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1_input_gift.d.ts","sourceRoot":"","sources":["../../src/types/1_input_gift.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAEpC;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,EAAE,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,2BAA2B;AAC3B,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,aAAa,GAAG,aAAa,CAAC;AAEtE,wBAAsB,mBAAmB,CAAC,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAW9H"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
4
|
+
* Copyright (C) 2023-2026 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.inputGiftToTlObject = inputGiftToTlObject;
|
|
23
|
+
const _0_deps_js_1 = require("../0_deps.js");
|
|
24
|
+
async function inputGiftToTlObject(inputGift, getInputPeer) {
|
|
25
|
+
switch (inputGift.type) {
|
|
26
|
+
case "slug":
|
|
27
|
+
return { _: "inputSavedStarGiftSlug", slug: inputGift.slug };
|
|
28
|
+
case "chat":
|
|
29
|
+
return { _: "inputSavedStarGiftChat", peer: await getInputPeer(inputGift.chatId), saved_id: BigInt(inputGift.id) };
|
|
30
|
+
case "user":
|
|
31
|
+
return { _: "inputSavedStarGiftUser", msg_id: inputGift.messageId };
|
|
32
|
+
default:
|
|
33
|
+
(0, _0_deps_js_1.unreachable)();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
20
|
import { Api } from "../2_tl.js";
|
|
21
|
+
import { type ButtonStyle } from "./0_button_style.js";
|
|
21
22
|
import { type ChatAdministratorRights } from "./0_chat_administrator_rights.js";
|
|
22
23
|
import type { KeyboardButtonPollType } from "./0_keyboard_button_poll_type.js";
|
|
23
24
|
import type { MiniAppButtonInfo } from "./0_mini_app_button_info.js";
|
|
@@ -25,6 +26,7 @@ import type { MiniAppButtonInfo } from "./0_mini_app_button_info.js";
|
|
|
25
26
|
export interface KeyboardButtonText {
|
|
26
27
|
/** @discriminator */
|
|
27
28
|
text: string;
|
|
29
|
+
style?: ButtonStyle;
|
|
28
30
|
}
|
|
29
31
|
/** @unlisted */
|
|
30
32
|
export interface KeyboardButtonRequestUser extends KeyboardButtonText {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1_keyboard_button.d.ts","sourceRoot":"","sources":["../../src/types/1_keyboard_button.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"1_keyboard_button.d.ts","sourceRoot":"","sources":["../../src/types/1_keyboard_button.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,KAAK,WAAW,EAA+C,MAAM,qBAAqB,CAAC;AACpG,OAAO,EAAE,KAAK,uBAAuB,EAAuE,MAAM,kCAAkC,CAAC;AACrJ,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE,gBAAgB;AAChB,MAAM,WAAW,kBAAkB;IACjC,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,gBAAgB;AAChB,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;IACnE,qBAAqB;IACrB,WAAW,EAAE;QACX,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,aAAa,CAAC,EAAE,OAAO,CAAC;KACzB,CAAC;CACH;AAED,gBAAgB;AAChB,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;IACnE,qBAAqB;IACrB,WAAW,EAAE;QACX,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,EAAE,OAAO,CAAC;QACvB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;QAClD,sBAAsB,CAAC,EAAE,uBAAuB,CAAC;QACjD,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB,CAAC;CACH;AAED,gBAAgB;AAChB,MAAM,WAAW,4BAA6B,SAAQ,kBAAkB;IACtE,qBAAqB;IACrB,cAAc,EAAE,IAAI,CAAC;CACtB;AAED,gBAAgB;AAChB,MAAM,WAAW,6BAA8B,SAAQ,kBAAkB;IACvE,qBAAqB;IACrB,eAAe,EAAE,IAAI,CAAC;CACvB;AAED,gBAAgB;AAChB,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;IACnE,qBAAqB;IACrB,WAAW,EAAE,sBAAsB,CAAC;CACrC;AAED,gBAAgB;AAChB,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D,qBAAqB;IACrB,OAAO,EAAE,iBAAiB,CAAC;CAC5B;AAED,qCAAqC;AACrC,MAAM,MAAM,cAAc,GACtB,kBAAkB,GAClB,yBAAyB,GACzB,yBAAyB,GACzB,4BAA4B,GAC5B,6BAA6B,GAC7B,yBAAyB,GACzB,qBAAqB,CAAC;AAE1B,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,GAAG,CAAC,cAAc,GAAG,cAAc,CAgFnF;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,cAAc,GAAG,GAAG,CAAC,cAAc,CA4DnF"}
|
|
@@ -22,22 +22,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
22
|
exports.constructKeyboardButton = constructKeyboardButton;
|
|
23
23
|
exports.keyboardButtonToTlObject = keyboardButtonToTlObject;
|
|
24
24
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
25
|
+
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
25
26
|
const _2_tl_js_1 = require("../2_tl.js");
|
|
27
|
+
const _0_button_style_js_1 = require("./0_button_style.js");
|
|
26
28
|
const _0_chat_administrator_rights_js_1 = require("./0_chat_administrator_rights.js");
|
|
27
29
|
function constructKeyboardButton(button_) {
|
|
30
|
+
const style = (0, _0_button_style_js_1.constructButtonStyle)(button_.style);
|
|
28
31
|
if (_2_tl_js_1.Api.is("keyboardButton", button_)) {
|
|
29
|
-
return { text: button_.text };
|
|
32
|
+
return (0, _1_utilities_js_1.cleanObject)({ text: button_.text, style });
|
|
30
33
|
}
|
|
31
34
|
else if (_2_tl_js_1.Api.is("keyboardButtonRequestPeer", button_)) {
|
|
32
35
|
if (_2_tl_js_1.Api.is("requestPeerTypeUser", button_.peer_type)) {
|
|
33
|
-
return {
|
|
36
|
+
return (0, _1_utilities_js_1.cleanObject)({
|
|
34
37
|
text: button_.text,
|
|
35
38
|
requestUser: {
|
|
36
39
|
requestId: button_.button_id,
|
|
37
40
|
userIsBot: button_.peer_type.bot || false,
|
|
38
41
|
userIsPremium: button_.peer_type.premium || false,
|
|
39
42
|
},
|
|
40
|
-
|
|
43
|
+
style,
|
|
44
|
+
});
|
|
41
45
|
}
|
|
42
46
|
else if (_2_tl_js_1.Api.is("requestPeerTypeChat", button_.peer_type)) {
|
|
43
47
|
const button = {
|
|
@@ -57,6 +61,9 @@ function constructKeyboardButton(button_) {
|
|
|
57
61
|
if (button_.peer_type.user_admin_rights) {
|
|
58
62
|
button.requestChat.userAdministratorRights = (0, _0_chat_administrator_rights_js_1.constructChatAdministratorRights)(button_.peer_type.user_admin_rights);
|
|
59
63
|
}
|
|
64
|
+
if (style) {
|
|
65
|
+
button.style = style;
|
|
66
|
+
}
|
|
60
67
|
return button;
|
|
61
68
|
}
|
|
62
69
|
else if (_2_tl_js_1.Api.is("requestPeerTypeBroadcast", button_.peer_type)) {
|
|
@@ -75,6 +82,9 @@ function constructKeyboardButton(button_) {
|
|
|
75
82
|
if (button_.peer_type.user_admin_rights) {
|
|
76
83
|
button.requestChat.userAdministratorRights = (0, _0_chat_administrator_rights_js_1.constructChatAdministratorRights)(button_.peer_type.user_admin_rights);
|
|
77
84
|
}
|
|
85
|
+
if (style) {
|
|
86
|
+
button.style = style;
|
|
87
|
+
}
|
|
78
88
|
return button;
|
|
79
89
|
}
|
|
80
90
|
else {
|
|
@@ -82,50 +92,93 @@ function constructKeyboardButton(button_) {
|
|
|
82
92
|
}
|
|
83
93
|
}
|
|
84
94
|
else if (_2_tl_js_1.Api.is("keyboardButtonRequestPhone", button_)) {
|
|
85
|
-
return { text: button_.text, requestContact: true };
|
|
95
|
+
return (0, _1_utilities_js_1.cleanObject)({ text: button_.text, requestContact: true, style });
|
|
86
96
|
}
|
|
87
97
|
else if (_2_tl_js_1.Api.is("keyboardButtonRequestGeoLocation", button_)) {
|
|
88
|
-
return { text: button_.text, requestLocation: true };
|
|
98
|
+
return (0, _1_utilities_js_1.cleanObject)({ text: button_.text, requestLocation: true, style });
|
|
89
99
|
}
|
|
90
100
|
else if (_2_tl_js_1.Api.is("keyboardButtonRequestPoll", button_)) {
|
|
91
101
|
const button = { text: button_.text, requestPoll: {} };
|
|
92
102
|
if (button_.quiz) {
|
|
93
103
|
button.requestPoll.type = "quiz";
|
|
94
104
|
}
|
|
105
|
+
if (style) {
|
|
106
|
+
button.style = style;
|
|
107
|
+
}
|
|
95
108
|
return button;
|
|
96
109
|
}
|
|
97
110
|
else if (_2_tl_js_1.Api.is("keyboardButtonWebView", button_) || _2_tl_js_1.Api.is("keyboardButtonSimpleWebView", button_)) {
|
|
98
|
-
return { text: button_.text, miniApp: { url: button_.url } };
|
|
111
|
+
return (0, _1_utilities_js_1.cleanObject)({ text: button_.text, miniApp: { url: button_.url }, style });
|
|
99
112
|
}
|
|
100
113
|
else {
|
|
101
114
|
(0, _0_deps_js_1.unreachable)();
|
|
102
115
|
}
|
|
103
116
|
}
|
|
104
117
|
function keyboardButtonToTlObject(button) {
|
|
118
|
+
const style = (0, _0_button_style_js_1.buttonStyleToTlObject)(button.style);
|
|
105
119
|
if ("requestUser" in button) {
|
|
106
|
-
return {
|
|
120
|
+
return {
|
|
121
|
+
_: "keyboardButtonRequestPeer",
|
|
122
|
+
text: button.text,
|
|
123
|
+
button_id: button.requestUser.requestId,
|
|
124
|
+
peer_type: { _: "requestPeerTypeUser", bot: button.requestUser.userIsBot, premium: button.requestUser.userIsPremium },
|
|
125
|
+
max_quantity: 1,
|
|
126
|
+
style,
|
|
127
|
+
};
|
|
107
128
|
}
|
|
108
129
|
else if ("requestChat" in button) {
|
|
109
130
|
if (!button.requestChat.chatIsChannel) { // GUESS
|
|
110
|
-
return {
|
|
131
|
+
return {
|
|
132
|
+
_: "keyboardButtonRequestPeer",
|
|
133
|
+
text: button.text,
|
|
134
|
+
button_id: button.requestChat.requestId,
|
|
135
|
+
peer_type: { _: "requestPeerTypeChat", forum: button.requestChat.chatIsForum, has_username: button.requestChat.chatHasUsername, creator: button.requestChat.chatIsCreated || undefined, bot_participant: button.requestChat.botIsMember || undefined, bot_admin_rights: button.requestChat.botAdministratorRights ? (0, _0_chat_administrator_rights_js_1.chatAdministratorRightsToTlObject)(button.requestChat.botAdministratorRights) : undefined, user_admin_rights: button.requestChat.userAdministratorRights ? (0, _0_chat_administrator_rights_js_1.chatAdministratorRightsToTlObject)(button.requestChat.userAdministratorRights) : undefined },
|
|
136
|
+
max_quantity: 1,
|
|
137
|
+
style,
|
|
138
|
+
};
|
|
111
139
|
}
|
|
112
140
|
else {
|
|
113
|
-
return {
|
|
141
|
+
return {
|
|
142
|
+
_: "keyboardButtonRequestPeer",
|
|
143
|
+
text: button.text,
|
|
144
|
+
button_id: button.requestChat.requestId,
|
|
145
|
+
peer_type: { _: "requestPeerTypeBroadcast", has_username: button.requestChat.chatHasUsername, creator: button.requestChat.chatIsCreated || undefined, bot_admin_rights: button.requestChat.botAdministratorRights ? (0, _0_chat_administrator_rights_js_1.chatAdministratorRightsToTlObject)(button.requestChat.botAdministratorRights) : undefined, user_admin_rights: button.requestChat.userAdministratorRights ? (0, _0_chat_administrator_rights_js_1.chatAdministratorRightsToTlObject)(button.requestChat.userAdministratorRights) : undefined },
|
|
146
|
+
max_quantity: 1,
|
|
147
|
+
style,
|
|
148
|
+
};
|
|
114
149
|
}
|
|
115
150
|
}
|
|
116
151
|
else if ("requestContact" in button) {
|
|
117
|
-
return {
|
|
152
|
+
return {
|
|
153
|
+
_: "keyboardButtonRequestPhone",
|
|
154
|
+
text: button.text,
|
|
155
|
+
style,
|
|
156
|
+
};
|
|
118
157
|
}
|
|
119
158
|
else if ("requestLocation" in button) {
|
|
120
|
-
return {
|
|
159
|
+
return {
|
|
160
|
+
_: "keyboardButtonRequestGeoLocation",
|
|
161
|
+
text: button.text,
|
|
162
|
+
style,
|
|
163
|
+
};
|
|
121
164
|
}
|
|
122
165
|
else if ("requestPoll" in button) {
|
|
123
|
-
return {
|
|
166
|
+
return {
|
|
167
|
+
_: "keyboardButtonRequestPoll",
|
|
168
|
+
text: button.text,
|
|
169
|
+
quiz: button.requestPoll.type === "quiz",
|
|
170
|
+
style,
|
|
171
|
+
};
|
|
124
172
|
}
|
|
125
173
|
else if ("miniApp" in button) {
|
|
126
|
-
return {
|
|
174
|
+
return {
|
|
175
|
+
_: "keyboardButtonWebView",
|
|
176
|
+
text: button.text,
|
|
177
|
+
url: button.miniApp.url,
|
|
178
|
+
style,
|
|
179
|
+
};
|
|
127
180
|
}
|
|
128
181
|
else {
|
|
129
|
-
return { _: "keyboardButton", text: button.text };
|
|
182
|
+
return { _: "keyboardButton", text: button.text, style };
|
|
130
183
|
}
|
|
131
184
|
}
|
|
@@ -118,7 +118,7 @@ function messageEntityToTlObject(entity, getPeer) {
|
|
|
118
118
|
if (!peer) {
|
|
119
119
|
(0, _0_deps_js_1.unreachable)();
|
|
120
120
|
}
|
|
121
|
-
return { _: "inputMessageEntityMentionName", offset, length, user_id:
|
|
121
|
+
return { _: "inputMessageEntityMentionName", offset, length, user_id: { _: "inputUser", user_id: BigInt(peer[0].id), access_hash: peer[1] } };
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
}
|
|
@@ -132,7 +132,7 @@ function messageEntityToTlObject(entity, getPeer) {
|
|
|
132
132
|
if (!peer) {
|
|
133
133
|
(0, _0_deps_js_1.unreachable)();
|
|
134
134
|
}
|
|
135
|
-
return { _: "inputMessageEntityMentionName", offset, length, user_id:
|
|
135
|
+
return { _: "inputMessageEntityMentionName", offset, length, user_id: { _: "inputUser", user_id: BigInt(peer[0].id), access_hash: peer[1] } };
|
|
136
136
|
}
|
|
137
137
|
case "cashtag":
|
|
138
138
|
return { _: "messageEntityCashtag", offset, length };
|