@mtkruto/node 0.101.1 → 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.
Files changed (101) hide show
  1. package/esm/3_types.d.ts +2 -0
  2. package/esm/3_types.d.ts.map +1 -1
  3. package/esm/3_types.js +2 -0
  4. package/esm/client/0_params.d.ts +4 -0
  5. package/esm/client/0_params.d.ts.map +1 -1
  6. package/esm/client/1_client_generic.d.ts +32 -5
  7. package/esm/client/1_client_generic.d.ts.map +1 -1
  8. package/esm/client/2_account_manager.d.ts +4 -1
  9. package/esm/client/2_account_manager.d.ts.map +1 -1
  10. package/esm/client/2_account_manager.js +18 -0
  11. package/esm/client/2_update_manager.js +7 -7
  12. package/esm/client/3_message_manager.js +17 -17
  13. package/esm/client/3_video_chat_manager.js +3 -3
  14. package/esm/client/4_chat_manager.js +3 -3
  15. package/esm/client/4_gift_manager.d.ts +3 -2
  16. package/esm/client/4_gift_manager.d.ts.map +1 -1
  17. package/esm/client/4_gift_manager.js +8 -7
  18. package/esm/client/5_client.d.ts +32 -5
  19. package/esm/client/5_client.d.ts.map +1 -1
  20. package/esm/client/5_client.js +39 -4
  21. package/esm/client/5_client_dispatcher.d.ts +32 -5
  22. package/esm/client/5_client_dispatcher.d.ts.map +1 -1
  23. package/esm/client/5_client_dispatcher.js +39 -4
  24. package/esm/types/0_button_style.d.ts +28 -0
  25. package/esm/types/0_button_style.d.ts.map +1 -0
  26. package/esm/types/0_button_style.js +36 -0
  27. package/esm/types/0_code_check_result.d.ts +14 -16
  28. package/esm/types/0_code_check_result.d.ts.map +1 -1
  29. package/esm/types/0_gift_component_rarity.d.ts +5 -0
  30. package/esm/types/0_gift_component_rarity.d.ts.map +1 -1
  31. package/esm/types/0_link_preview_media_size.d.ts +1 -0
  32. package/esm/types/0_link_preview_media_size.d.ts.map +1 -1
  33. package/esm/types/0_mini_app_button_info.d.ts +1 -0
  34. package/esm/types/0_mini_app_button_info.d.ts.map +1 -1
  35. package/esm/types/0_slow_mode_duration.d.ts +1 -0
  36. package/esm/types/0_slow_mode_duration.d.ts.map +1 -1
  37. package/esm/types/0_switch_inline_query_chosen_chats.d.ts +1 -0
  38. package/esm/types/0_switch_inline_query_chosen_chats.d.ts.map +1 -1
  39. package/esm/types/1_bot_command_scope.js +1 -1
  40. package/esm/types/1_inline_keyboard_button.d.ts +2 -0
  41. package/esm/types/1_inline_keyboard_button.d.ts.map +1 -1
  42. package/esm/types/1_inline_keyboard_button.js +30 -19
  43. package/esm/types/1_input_gift.d.ts +54 -0
  44. package/esm/types/1_input_gift.d.ts.map +1 -0
  45. package/esm/types/1_input_gift.js +32 -0
  46. package/esm/types/1_keyboard_button.d.ts +2 -0
  47. package/esm/types/1_keyboard_button.d.ts.map +1 -1
  48. package/esm/types/1_keyboard_button.js +67 -14
  49. package/esm/types/2_message_entity.js +2 -2
  50. package/esm/types/7_inline_query_result.js +6 -6
  51. package/package.json +1 -1
  52. package/script/3_types.d.ts +2 -0
  53. package/script/3_types.d.ts.map +1 -1
  54. package/script/3_types.js +2 -0
  55. package/script/client/0_params.d.ts +4 -0
  56. package/script/client/0_params.d.ts.map +1 -1
  57. package/script/client/1_client_generic.d.ts +32 -5
  58. package/script/client/1_client_generic.d.ts.map +1 -1
  59. package/script/client/2_account_manager.d.ts +4 -1
  60. package/script/client/2_account_manager.d.ts.map +1 -1
  61. package/script/client/2_account_manager.js +18 -0
  62. package/script/client/2_update_manager.js +7 -7
  63. package/script/client/3_message_manager.js +17 -17
  64. package/script/client/3_video_chat_manager.js +3 -3
  65. package/script/client/4_chat_manager.js +3 -3
  66. package/script/client/4_gift_manager.d.ts +3 -2
  67. package/script/client/4_gift_manager.d.ts.map +1 -1
  68. package/script/client/4_gift_manager.js +7 -6
  69. package/script/client/5_client.d.ts +32 -5
  70. package/script/client/5_client.d.ts.map +1 -1
  71. package/script/client/5_client.js +39 -4
  72. package/script/client/5_client_dispatcher.d.ts +32 -5
  73. package/script/client/5_client_dispatcher.d.ts.map +1 -1
  74. package/script/client/5_client_dispatcher.js +39 -4
  75. package/script/types/0_button_style.d.ts +28 -0
  76. package/script/types/0_button_style.d.ts.map +1 -0
  77. package/script/types/0_button_style.js +40 -0
  78. package/script/types/0_code_check_result.d.ts +14 -16
  79. package/script/types/0_code_check_result.d.ts.map +1 -1
  80. package/script/types/0_gift_component_rarity.d.ts +5 -0
  81. package/script/types/0_gift_component_rarity.d.ts.map +1 -1
  82. package/script/types/0_link_preview_media_size.d.ts +1 -0
  83. package/script/types/0_link_preview_media_size.d.ts.map +1 -1
  84. package/script/types/0_mini_app_button_info.d.ts +1 -0
  85. package/script/types/0_mini_app_button_info.d.ts.map +1 -1
  86. package/script/types/0_slow_mode_duration.d.ts +1 -0
  87. package/script/types/0_slow_mode_duration.d.ts.map +1 -1
  88. package/script/types/0_switch_inline_query_chosen_chats.d.ts +1 -0
  89. package/script/types/0_switch_inline_query_chosen_chats.d.ts.map +1 -1
  90. package/script/types/1_bot_command_scope.js +1 -1
  91. package/script/types/1_inline_keyboard_button.d.ts +2 -0
  92. package/script/types/1_inline_keyboard_button.d.ts.map +1 -1
  93. package/script/types/1_inline_keyboard_button.js +30 -19
  94. package/script/types/1_input_gift.d.ts +54 -0
  95. package/script/types/1_input_gift.d.ts.map +1 -0
  96. package/script/types/1_input_gift.js +35 -0
  97. package/script/types/1_keyboard_button.d.ts +2 -0
  98. package/script/types/1_keyboard_button.d.ts.map +1 -1
  99. package/script/types/1_keyboard_button.js +67 -14
  100. package/script/types/2_message_entity.js +2 -2
  101. package/script/types/7_inline_query_result.js +6 -6
@@ -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
- export declare namespace CodeCheckResult {
21
- /** The code was correct, but an additional password is required to sign in. */
22
- interface PasswordRequired {
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
- /** A result after checking a sent code. */
36
- export type CodeCheckResult = CodeCheckResult.PasswordRequired | CodeCheckResult.InvalidCode | CodeCheckResult.SignedIn;
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,MAAM,CAAC,OAAO,WAAW,eAAe,CAAC;IACvC,+EAA+E;IAC/E,UAAiB,gBAAgB;QAC/B,IAAI,EAAE,mBAAmB,CAAC;KAC3B;IAED,sCAAsC;IACtC,UAAiB,WAAW;QAC1B,IAAI,EAAE,cAAc,CAAC;KACtB;IAED,oDAAoD;IACpD,UAAiB,QAAQ;QACvB,IAAI,EAAE,WAAW,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KAChB;CACF;AAED,2CAA2C;AAC3C,MAAM,MAAM,eAAe,GAAG,eAAe,CAAC,gBAAgB,GAAG,eAAe,CAAC,WAAW,GAAG,eAAe,CAAC,QAAQ,CAAC"}
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"}
@@ -38,7 +38,7 @@ export async function botCommandScopeToTlObject(scope, getInputPeer) {
38
38
  if (!Api.is("inputPeerUser", user)) {
39
39
  unreachable();
40
40
  }
41
- return { _: "botCommandScopePeerUser", peer: await getInputPeer(scope.chatId), user_id: ({ _: "inputUser", user_id: user.user_id, access_hash: user.access_hash }) };
41
+ return { _: "botCommandScopePeerUser", peer: await getInputPeer(scope.chatId), user_id: { _: "inputUser", user_id: user.user_id, access_hash: user.access_hash } };
42
42
  }
43
43
  default:
44
44
  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;CACd;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,CAgC/F;AAED,wBAAsB,8BAA8B,CAAC,MAAM,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAuClJ"}
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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ED;;;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"}
@@ -21,43 +21,45 @@ import { unreachable } from "../0_deps.js";
21
21
  import { InputError } from "../0_errors.js";
22
22
  import { cleanObject, decodeText, encodeText } from "../1_utilities.js";
23
23
  import { Api } from "../2_tl.js";
24
+ import { buttonStyleToTlObject, constructButtonStyle } from "./0_button_style.js";
24
25
  import { constructMiniAppButtonInfo } from "./0_mini_app_button_info.js";
25
26
  export function constructInlineKeyboardButton(button_) {
27
+ const style = constructButtonStyle(button_.style);
26
28
  if (Api.is("keyboardButtonUrl", button_)) {
27
- return { text: button_.text, url: button_.url };
29
+ return cleanObject({ text: button_.text, url: button_.url, style });
28
30
  }
29
31
  else if (Api.is("keyboardButtonCallback", button_)) {
30
- return { text: button_.text, callbackData: decodeText(button_.data) };
32
+ return cleanObject({ text: button_.text, callbackData: decodeText(button_.data), style });
31
33
  }
32
34
  else if (Api.is("keyboardButtonWebView", button_) || Api.is("keyboardButtonSimpleWebView", button_)) {
33
- return { text: button_.text, miniApp: constructMiniAppButtonInfo(button_.url) };
35
+ return cleanObject({ text: button_.text, miniApp: constructMiniAppButtonInfo(button_.url), style });
34
36
  }
35
37
  else if (Api.is("keyboardButtonUrlAuth", button_)) {
36
- return { text: button_.text, loginUrl: { url: button_.url, forwardText: button_.fwd_text } };
38
+ return cleanObject({ text: button_.text, loginUrl: { url: button_.url, forwardText: button_.fwd_text }, style });
37
39
  }
38
40
  else if (Api.is("keyboardButtonSwitchInline", button_)) {
39
41
  if (button_.same_peer) {
40
- return { text: button_.text, switchInlineQueryCurrentChat: button_.query };
42
+ return cleanObject({ text: button_.text, switchInlineQueryCurrentChat: button_.query, style });
41
43
  }
42
44
  else if (button_.peer_types && button_.peer_types.length) {
43
45
  const allowUsers = button_.peer_types.some((v) => v._ === "inlineQueryPeerTypeBotPM") || undefined;
44
46
  const allowBots = button_.peer_types.some((v) => v._ === "inlineQueryPeerTypeSameBotPM" || v._ === "inlineQueryPeerTypeBotPM") || undefined;
45
47
  const allowGroups = button_.peer_types.some((v) => v._ === "inlineQueryPeerTypeChat" || v._ === "inlineQueryPeerTypeMegagroup") || undefined;
46
48
  const allowChannels = button_.peer_types.some((v) => v._ === "inlineQueryPeerTypeBroadcast") || undefined;
47
- return cleanObject({ text: button_.text, switchInlineQueryChosenChats: { query: button_.query, allowUsers, allowBots, allowGroups, allowChannels } });
49
+ return cleanObject({ text: button_.text, switchInlineQueryChosenChats: { query: button_.query, allowUsers, allowBots, allowGroups, allowChannels }, style });
48
50
  }
49
51
  else {
50
- return { text: button_.text, switchInlineQuery: button_.query };
52
+ return cleanObject({ text: button_.text, switchInlineQuery: button_.query, style });
51
53
  }
52
54
  }
53
55
  else if (Api.is("keyboardButtonBuy", button_)) {
54
- return { text: button_.text, pay: true };
56
+ return cleanObject({ text: button_.text, pay: true, style });
55
57
  }
56
58
  else if (Api.is("keyboardButtonGame", button_)) {
57
- return { text: button_.text, callbackGame: {} };
59
+ return cleanObject({ text: button_.text, callbackGame: {}, style });
58
60
  }
59
61
  else if (Api.is("keyboardButtonCopy", button_)) {
60
- return { text: button_.text, copy: button_.copy_text };
62
+ return cleanObject({ text: button_.text, copy: button_.copy_text, style });
61
63
  }
62
64
  else if (Api.is("keyboardButtonRequestPeer", button_)) {
63
65
  unreachable();
@@ -67,23 +69,32 @@ export function constructInlineKeyboardButton(button_) {
67
69
  }
68
70
  }
69
71
  export async function inlineKeyboardButtonToTlObject(button, usernameResolver) {
72
+ const style = buttonStyleToTlObject(button.style);
70
73
  if ("url" in button) {
71
- return { _: "keyboardButtonUrl", text: button.text, url: button.url };
74
+ return { _: "keyboardButtonUrl", text: button.text, url: button.url, style };
72
75
  }
73
76
  else if ("callbackData" in button) {
74
- return { _: "keyboardButtonCallback", text: button.text, data: encodeText(button.callbackData) };
77
+ return { _: "keyboardButtonCallback", text: button.text, data: encodeText(button.callbackData), style };
75
78
  }
76
79
  else if ("miniApp" in button) {
77
- return { _: "keyboardButtonWebView", text: button.text, url: button.miniApp.url };
80
+ return { _: "keyboardButtonWebView", text: button.text, url: button.miniApp.url, style };
78
81
  }
79
82
  else if ("loginUrl" in button) {
80
- return { _: "inputKeyboardButtonUrlAuth", text: button.text, url: button.loginUrl.url, fwd_text: button.loginUrl.forwardText, bot: button.loginUrl.botUsername ? await usernameResolver(button.loginUrl.botUsername) : { _: "inputUserSelf" }, request_write_access: button.loginUrl.requestWriteAccess || undefined };
83
+ return {
84
+ _: "inputKeyboardButtonUrlAuth",
85
+ text: button.text,
86
+ url: button.loginUrl.url,
87
+ fwd_text: button.loginUrl.forwardText,
88
+ bot: button.loginUrl.botUsername ? await usernameResolver(button.loginUrl.botUsername) : { _: "inputUserSelf" },
89
+ request_write_access: button.loginUrl.requestWriteAccess || undefined,
90
+ style,
91
+ };
81
92
  }
82
93
  else if ("switchInlineQuery" in button) {
83
- return { _: "keyboardButtonSwitchInline", text: button.text, query: button.switchInlineQuery };
94
+ return { _: "keyboardButtonSwitchInline", text: button.text, query: button.switchInlineQuery, style };
84
95
  }
85
96
  else if ("switchInlineQueryCurrentChat" in button) {
86
- return { _: "keyboardButtonSwitchInline", text: button.text, query: button.switchInlineQueryCurrentChat, same_peer: true };
97
+ return { _: "keyboardButtonSwitchInline", text: button.text, query: button.switchInlineQueryCurrentChat, same_peer: true, style };
87
98
  }
88
99
  else if ("switchInlineQueryChosenChats" in button) {
89
100
  const peerTypes = new Array();
@@ -103,13 +114,13 @@ export async function inlineKeyboardButtonToTlObject(button, usernameResolver) {
103
114
  if (allowChannels) {
104
115
  peerTypes.push({ _: "inlineQueryPeerTypeBroadcast" });
105
116
  }
106
- return { _: "keyboardButtonSwitchInline", text: button.text, query: button.switchInlineQueryChosenChats.query, peer_types: peerTypes };
117
+ return { _: "keyboardButtonSwitchInline", text: button.text, query: button.switchInlineQueryChosenChats.query, peer_types: peerTypes, style };
107
118
  }
108
119
  else if ("pay" in button) {
109
- return { _: "keyboardButtonBuy", text: button.text };
120
+ return { _: "keyboardButtonBuy", text: button.text, style };
110
121
  }
111
122
  else if ("copy" in button) {
112
- return { _: "keyboardButtonCopy", text: button.text, copy_text: button.copy };
123
+ return { _: "keyboardButtonCopy", text: button.text, copy_text: button.copy, style };
113
124
  }
114
125
  else {
115
126
  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,32 @@
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 { unreachable } from "../0_deps.js";
21
+ export async function inputGiftToTlObject(inputGift, getInputPeer) {
22
+ switch (inputGift.type) {
23
+ case "slug":
24
+ return { _: "inputSavedStarGiftSlug", slug: inputGift.slug };
25
+ case "chat":
26
+ return { _: "inputSavedStarGiftChat", peer: await getInputPeer(inputGift.chatId), saved_id: BigInt(inputGift.id) };
27
+ case "user":
28
+ return { _: "inputSavedStarGiftUser", msg_id: inputGift.messageId };
29
+ default:
30
+ unreachable();
31
+ }
32
+ }
@@ -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;AAGH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,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;CACd;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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B,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"}
@@ -18,22 +18,26 @@
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
20
  import { unreachable } from "../0_deps.js";
21
+ import { cleanObject } from "../1_utilities.js";
21
22
  import { Api } from "../2_tl.js";
23
+ import { buttonStyleToTlObject, constructButtonStyle } from "./0_button_style.js";
22
24
  import { chatAdministratorRightsToTlObject, constructChatAdministratorRights } from "./0_chat_administrator_rights.js";
23
25
  export function constructKeyboardButton(button_) {
26
+ const style = constructButtonStyle(button_.style);
24
27
  if (Api.is("keyboardButton", button_)) {
25
- return { text: button_.text };
28
+ return cleanObject({ text: button_.text, style });
26
29
  }
27
30
  else if (Api.is("keyboardButtonRequestPeer", button_)) {
28
31
  if (Api.is("requestPeerTypeUser", button_.peer_type)) {
29
- return {
32
+ return cleanObject({
30
33
  text: button_.text,
31
34
  requestUser: {
32
35
  requestId: button_.button_id,
33
36
  userIsBot: button_.peer_type.bot || false,
34
37
  userIsPremium: button_.peer_type.premium || false,
35
38
  },
36
- };
39
+ style,
40
+ });
37
41
  }
38
42
  else if (Api.is("requestPeerTypeChat", button_.peer_type)) {
39
43
  const button = {
@@ -53,6 +57,9 @@ export function constructKeyboardButton(button_) {
53
57
  if (button_.peer_type.user_admin_rights) {
54
58
  button.requestChat.userAdministratorRights = constructChatAdministratorRights(button_.peer_type.user_admin_rights);
55
59
  }
60
+ if (style) {
61
+ button.style = style;
62
+ }
56
63
  return button;
57
64
  }
58
65
  else if (Api.is("requestPeerTypeBroadcast", button_.peer_type)) {
@@ -71,6 +78,9 @@ export function constructKeyboardButton(button_) {
71
78
  if (button_.peer_type.user_admin_rights) {
72
79
  button.requestChat.userAdministratorRights = constructChatAdministratorRights(button_.peer_type.user_admin_rights);
73
80
  }
81
+ if (style) {
82
+ button.style = style;
83
+ }
74
84
  return button;
75
85
  }
76
86
  else {
@@ -78,50 +88,93 @@ export function constructKeyboardButton(button_) {
78
88
  }
79
89
  }
80
90
  else if (Api.is("keyboardButtonRequestPhone", button_)) {
81
- return { text: button_.text, requestContact: true };
91
+ return cleanObject({ text: button_.text, requestContact: true, style });
82
92
  }
83
93
  else if (Api.is("keyboardButtonRequestGeoLocation", button_)) {
84
- return { text: button_.text, requestLocation: true };
94
+ return cleanObject({ text: button_.text, requestLocation: true, style });
85
95
  }
86
96
  else if (Api.is("keyboardButtonRequestPoll", button_)) {
87
97
  const button = { text: button_.text, requestPoll: {} };
88
98
  if (button_.quiz) {
89
99
  button.requestPoll.type = "quiz";
90
100
  }
101
+ if (style) {
102
+ button.style = style;
103
+ }
91
104
  return button;
92
105
  }
93
106
  else if (Api.is("keyboardButtonWebView", button_) || Api.is("keyboardButtonSimpleWebView", button_)) {
94
- return { text: button_.text, miniApp: { url: button_.url } };
107
+ return cleanObject({ text: button_.text, miniApp: { url: button_.url }, style });
95
108
  }
96
109
  else {
97
110
  unreachable();
98
111
  }
99
112
  }
100
113
  export function keyboardButtonToTlObject(button) {
114
+ const style = buttonStyleToTlObject(button.style);
101
115
  if ("requestUser" in button) {
102
- return { _: "keyboardButtonRequestPeer", text: button.text, button_id: button.requestUser.requestId, peer_type: ({ _: "requestPeerTypeUser", bot: button.requestUser.userIsBot, premium: button.requestUser.userIsPremium }), max_quantity: 1 };
116
+ return {
117
+ _: "keyboardButtonRequestPeer",
118
+ text: button.text,
119
+ button_id: button.requestUser.requestId,
120
+ peer_type: { _: "requestPeerTypeUser", bot: button.requestUser.userIsBot, premium: button.requestUser.userIsPremium },
121
+ max_quantity: 1,
122
+ style,
123
+ };
103
124
  }
104
125
  else if ("requestChat" in button) {
105
126
  if (!button.requestChat.chatIsChannel) { // GUESS
106
- return { _: "keyboardButtonRequestPeer", text: button.text, button_id: button.requestChat.requestId, 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 ? chatAdministratorRightsToTlObject(button.requestChat.botAdministratorRights) : undefined, user_admin_rights: button.requestChat.userAdministratorRights ? chatAdministratorRightsToTlObject(button.requestChat.userAdministratorRights) : undefined }), max_quantity: 1 };
127
+ return {
128
+ _: "keyboardButtonRequestPeer",
129
+ text: button.text,
130
+ button_id: button.requestChat.requestId,
131
+ 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 ? chatAdministratorRightsToTlObject(button.requestChat.botAdministratorRights) : undefined, user_admin_rights: button.requestChat.userAdministratorRights ? chatAdministratorRightsToTlObject(button.requestChat.userAdministratorRights) : undefined },
132
+ max_quantity: 1,
133
+ style,
134
+ };
107
135
  }
108
136
  else {
109
- return { _: "keyboardButtonRequestPeer", text: button.text, button_id: button.requestChat.requestId, peer_type: ({ _: "requestPeerTypeBroadcast", has_username: button.requestChat.chatHasUsername, creator: button.requestChat.chatIsCreated || undefined, bot_admin_rights: button.requestChat.botAdministratorRights ? chatAdministratorRightsToTlObject(button.requestChat.botAdministratorRights) : undefined, user_admin_rights: button.requestChat.userAdministratorRights ? chatAdministratorRightsToTlObject(button.requestChat.userAdministratorRights) : undefined }), max_quantity: 1 };
137
+ return {
138
+ _: "keyboardButtonRequestPeer",
139
+ text: button.text,
140
+ button_id: button.requestChat.requestId,
141
+ peer_type: { _: "requestPeerTypeBroadcast", has_username: button.requestChat.chatHasUsername, creator: button.requestChat.chatIsCreated || undefined, bot_admin_rights: button.requestChat.botAdministratorRights ? chatAdministratorRightsToTlObject(button.requestChat.botAdministratorRights) : undefined, user_admin_rights: button.requestChat.userAdministratorRights ? chatAdministratorRightsToTlObject(button.requestChat.userAdministratorRights) : undefined },
142
+ max_quantity: 1,
143
+ style,
144
+ };
110
145
  }
111
146
  }
112
147
  else if ("requestContact" in button) {
113
- return { _: "keyboardButtonRequestPhone", text: button.text };
148
+ return {
149
+ _: "keyboardButtonRequestPhone",
150
+ text: button.text,
151
+ style,
152
+ };
114
153
  }
115
154
  else if ("requestLocation" in button) {
116
- return { _: "keyboardButtonRequestGeoLocation", text: button.text };
155
+ return {
156
+ _: "keyboardButtonRequestGeoLocation",
157
+ text: button.text,
158
+ style,
159
+ };
117
160
  }
118
161
  else if ("requestPoll" in button) {
119
- return { _: "keyboardButtonRequestPoll", text: button.text, quiz: button.requestPoll.type === "quiz" };
162
+ return {
163
+ _: "keyboardButtonRequestPoll",
164
+ text: button.text,
165
+ quiz: button.requestPoll.type === "quiz",
166
+ style,
167
+ };
120
168
  }
121
169
  else if ("miniApp" in button) {
122
- return { _: "keyboardButtonWebView", text: button.text, url: button.miniApp.url };
170
+ return {
171
+ _: "keyboardButtonWebView",
172
+ text: button.text,
173
+ url: button.miniApp.url,
174
+ style,
175
+ };
123
176
  }
124
177
  else {
125
- return { _: "keyboardButton", text: button.text };
178
+ return { _: "keyboardButton", text: button.text, style };
126
179
  }
127
180
  }
@@ -113,7 +113,7 @@ export function messageEntityToTlObject(entity, getPeer) {
113
113
  if (!peer) {
114
114
  unreachable();
115
115
  }
116
- return { _: "inputMessageEntityMentionName", offset, length, user_id: ({ _: "inputUser", user_id: BigInt(peer[0].id), access_hash: peer[1] }) };
116
+ return { _: "inputMessageEntityMentionName", offset, length, user_id: { _: "inputUser", user_id: BigInt(peer[0].id), access_hash: peer[1] } };
117
117
  }
118
118
  }
119
119
  }
@@ -127,7 +127,7 @@ export function messageEntityToTlObject(entity, getPeer) {
127
127
  if (!peer) {
128
128
  unreachable();
129
129
  }
130
- return { _: "inputMessageEntityMentionName", offset, length, user_id: ({ _: "inputUser", user_id: BigInt(peer[0].id), access_hash: peer[1] }) };
130
+ return { _: "inputMessageEntityMentionName", offset, length, user_id: { _: "inputUser", user_id: BigInt(peer[0].id), access_hash: peer[1] } };
131
131
  }
132
132
  case "cashtag":
133
133
  return { _: "messageEntityCashtag", offset, length };
@@ -327,7 +327,7 @@ export async function inlineQueryResultToTlObject(result_, parseText, usernameRe
327
327
  const title = "title" in result_ ? result_.title : undefined;
328
328
  const description = "description" in result_ ? result_.description : undefined;
329
329
  if (document !== null) {
330
- return { _: "inputBotInlineResult", id, type, title, description, thumb: thumb === null ? undefined : thumb, content: document, send_message: ({ _: "inputBotInlineMessageMediaAuto", message, entities, reply_markup: replyMarkup }) };
330
+ return { _: "inputBotInlineResult", id, type, title, description, thumb: thumb === null ? undefined : thumb, content: document, send_message: { _: "inputBotInlineMessageMediaAuto", message, entities, reply_markup: replyMarkup } };
331
331
  }
332
332
  else if (fileId_ !== null) {
333
333
  const fileId = deserializeFileId(fileId_);
@@ -337,20 +337,20 @@ export async function inlineQueryResultToTlObject(result_, parseText, usernameRe
337
337
  type: type === "document" ? "file" : type,
338
338
  title,
339
339
  description,
340
- document: ({
340
+ document: {
341
341
  _: "inputDocument",
342
342
  id: "id" in fileId.location ? fileId.location.id : unreachable(),
343
343
  access_hash: fileId.location.accessHash,
344
344
  file_reference: fileId.fileReference ?? new Uint8Array(),
345
- }),
345
+ },
346
346
  send_message: sendMessage,
347
347
  };
348
348
  }
349
349
  else if (result_.type === "location") {
350
- return { _: "inputBotInlineResult", id, type, title, description, thumb: thumb === null ? undefined : thumb, send_message: ({ _: "inputBotInlineMessageMediaGeo", geo_point: ({ _: "inputGeoPoint", lat: result_.latitude, long: result_.longitude, accuracy_radius: result_.horizontalAccuracy }), heading: result_.heading, period: result_.livePeriod, proximity_notification_radius: result_.proximityAlertRadius, reply_markup: replyMarkup }) };
350
+ return { _: "inputBotInlineResult", id, type, title, description, thumb: thumb === null ? undefined : thumb, send_message: { _: "inputBotInlineMessageMediaGeo", geo_point: { _: "inputGeoPoint", lat: result_.latitude, long: result_.longitude, accuracy_radius: result_.horizontalAccuracy }, heading: result_.heading, period: result_.livePeriod, proximity_notification_radius: result_.proximityAlertRadius, reply_markup: replyMarkup } };
351
351
  }
352
352
  else if (result_.type === "game") {
353
- return { _: "inputBotInlineResult", id, type, title, description, thumb: thumb === null ? undefined : thumb, send_message: ({ _: "inputBotInlineMessageGame", reply_markup: replyMarkup }) };
353
+ return { _: "inputBotInlineResult", id, type, title, description, thumb: thumb === null ? undefined : thumb, send_message: { _: "inputBotInlineMessageGame", reply_markup: replyMarkup } };
354
354
  }
355
355
  else if (result_.type === "article") {
356
356
  if (!("text" in result_.messageContent)) {
@@ -372,7 +372,7 @@ export async function inlineQueryResultToTlObject(result_, parseText, usernameRe
372
372
  if (!result_.foursquareId || !result_.foursquareType) {
373
373
  unreachable();
374
374
  }
375
- return { _: "inputBotInlineResult", id, type, title, description, thumb: thumb === null ? undefined : thumb, send_message: ({ _: "inputBotInlineMessageMediaVenue", geo_point: ({ _: "inputGeoPoint", long: result_.longitude, lat: result_.latitude }), address: result_.address, provider: "foursquare", title: result_.title, venue_id: result_.foursquareId, venue_type: result_.foursquareType, reply_markup: replyMarkup }) };
375
+ return { _: "inputBotInlineResult", id, type, title, description, thumb: thumb === null ? undefined : thumb, send_message: { _: "inputBotInlineMessageMediaVenue", geo_point: { _: "inputGeoPoint", long: result_.longitude, lat: result_.latitude }, address: result_.address, provider: "foursquare", title: result_.title, venue_id: result_.foursquareId, venue_type: result_.foursquareType, reply_markup: replyMarkup } };
376
376
  }
377
377
  else {
378
378
  unreachable();