@mtkruto/node 0.0.998 → 0.0.999

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 (185) hide show
  1. package/esm/3_types.d.ts +39 -3
  2. package/esm/3_types.js +39 -3
  3. package/esm/4_constants.d.ts +1 -1
  4. package/esm/4_constants.js +1 -1
  5. package/esm/client/3_types.d.ts +1 -5
  6. package/esm/client/4_client.d.ts +18 -2
  7. package/esm/client/4_client.js +37 -21
  8. package/esm/connection/1_connection_web_socket.js +2 -1
  9. package/esm/types/0_bot_command.d.ts +4 -0
  10. package/esm/types/0_chat_id.d.ts +4 -0
  11. package/esm/types/0_chat_id.js +1 -0
  12. package/esm/types/0_chat_photo.js +1 -1
  13. package/esm/types/0_input_contact_message_content.d.ts +6 -0
  14. package/esm/types/0_input_contact_message_content.js +1 -0
  15. package/esm/types/0_input_location_message_content.d.ts +8 -0
  16. package/esm/types/0_input_location_message_content.js +1 -0
  17. package/esm/types/0_input_venue_message_content.d.ts +10 -0
  18. package/esm/types/0_input_venue_message_content.js +1 -0
  19. package/esm/types/0_labeled_price.d.ts +4 -0
  20. package/esm/types/0_labeled_price.js +1 -0
  21. package/esm/types/0_parse_mode.d.ts +1 -0
  22. package/esm/types/0_parse_mode.js +1 -0
  23. package/esm/types/0_thumbnail.js +1 -1
  24. package/esm/types/{!0_misc.d.ts → 1__getters.d.ts} +7 -0
  25. package/esm/types/1__getters.js +1 -0
  26. package/esm/types/1_bot_command_scope.d.ts +32 -0
  27. package/esm/types/1_bot_command_scope.js +27 -0
  28. package/esm/types/1_inline_query_result_button.d.ts +6 -0
  29. package/esm/types/1_inline_query_result_button.js +1 -0
  30. package/esm/types/1_input_invoice_message_content.d.ts +23 -0
  31. package/esm/types/1_input_invoice_message_content.js +1 -0
  32. package/esm/types/1_input_text_message_content.d.ts +8 -0
  33. package/esm/types/1_input_text_message_content.js +1 -0
  34. package/esm/types/1_photo.js +1 -1
  35. package/esm/types/2_game.js +1 -1
  36. package/{script/types/1_inline_keyboard_button.d.ts → esm/types/2_inline_keyboard_button.d.ts} +2 -2
  37. package/esm/types/2_inline_query.d.ts +1 -1
  38. package/esm/types/2_input_message_content.d.ts +6 -0
  39. package/esm/types/2_input_message_content.js +1 -0
  40. package/esm/types/{2_inline_keyboard_markup.d.ts → 3_inline_keyboard_markup.d.ts} +3 -2
  41. package/esm/types/{2_inline_keyboard_markup.js → 3_inline_keyboard_markup.js} +1 -1
  42. package/esm/types/3_message.d.ts +2 -2
  43. package/esm/types/3_message.js +2 -2
  44. package/esm/types/4_callback_query.d.ts +1 -1
  45. package/esm/types/4_inline_query_result_article.d.ts +15 -0
  46. package/esm/types/4_inline_query_result_article.js +1 -0
  47. package/esm/types/4_inline_query_result_audio.d.ts +17 -0
  48. package/esm/types/4_inline_query_result_audio.js +1 -0
  49. package/esm/types/4_inline_query_result_cached_audio.d.ts +14 -0
  50. package/esm/types/4_inline_query_result_cached_audio.js +1 -0
  51. package/esm/types/4_inline_query_result_cached_document.d.ts +15 -0
  52. package/esm/types/4_inline_query_result_cached_document.js +1 -0
  53. package/esm/types/4_inline_query_result_cached_gif.d.ts +15 -0
  54. package/esm/types/4_inline_query_result_cached_gif.js +1 -0
  55. package/esm/types/4_inline_query_result_cached_mpeg4_gif.d.ts +15 -0
  56. package/esm/types/4_inline_query_result_cached_mpeg4_gif.js +1 -0
  57. package/esm/types/4_inline_query_result_cached_photo.d.ts +16 -0
  58. package/esm/types/4_inline_query_result_cached_photo.js +1 -0
  59. package/esm/types/4_inline_query_result_cached_sticker.d.ts +9 -0
  60. package/esm/types/4_inline_query_result_cached_sticker.js +1 -0
  61. package/esm/types/4_inline_query_result_cached_video.d.ts +16 -0
  62. package/esm/types/4_inline_query_result_cached_video.js +1 -0
  63. package/esm/types/4_inline_query_result_cached_voice.d.ts +15 -0
  64. package/esm/types/4_inline_query_result_cached_voice.js +1 -0
  65. package/esm/types/4_inline_query_result_contact.d.ts +15 -0
  66. package/esm/types/4_inline_query_result_contact.js +1 -0
  67. package/esm/types/4_inline_query_result_document.d.ts +18 -0
  68. package/esm/types/4_inline_query_result_document.js +1 -0
  69. package/esm/types/4_inline_query_result_game.d.ts +7 -0
  70. package/esm/types/4_inline_query_result_game.js +1 -0
  71. package/esm/types/4_inline_query_result_gif.d.ts +20 -0
  72. package/esm/types/4_inline_query_result_gif.js +1 -0
  73. package/esm/types/4_inline_query_result_location.d.ts +18 -0
  74. package/esm/types/4_inline_query_result_location.js +1 -0
  75. package/esm/types/4_inline_query_result_mpeg4_gif.d.ts +20 -0
  76. package/esm/types/4_inline_query_result_mpeg4_gif.js +1 -0
  77. package/esm/types/4_inline_query_result_photo.d.ts +19 -0
  78. package/esm/types/4_inline_query_result_photo.js +1 -0
  79. package/esm/types/4_inline_query_result_venue.d.ts +19 -0
  80. package/esm/types/4_inline_query_result_venue.js +1 -0
  81. package/esm/types/4_inline_query_result_video.d.ts +21 -0
  82. package/esm/types/4_inline_query_result_video.js +1 -0
  83. package/esm/types/4_inline_query_result_voice.d.ts +16 -0
  84. package/esm/types/4_inline_query_result_voice.js +1 -0
  85. package/esm/types/4_reply_markup.d.ts +7 -0
  86. package/esm/types/4_reply_markup.js +22 -0
  87. package/esm/types/5_inline_query_result.d.ts +29 -0
  88. package/esm/types/5_inline_query_result.js +256 -0
  89. package/package.json +1 -1
  90. package/script/3_types.d.ts +39 -3
  91. package/script/3_types.js +39 -3
  92. package/script/4_constants.d.ts +1 -1
  93. package/script/4_constants.js +1 -1
  94. package/script/client/3_types.d.ts +1 -5
  95. package/script/client/4_client.d.ts +18 -2
  96. package/script/client/4_client.js +36 -20
  97. package/script/connection/1_connection_web_socket.js +2 -1
  98. package/script/types/0_bot_command.d.ts +4 -0
  99. package/script/types/0_chat_id.d.ts +4 -0
  100. package/script/types/0_chat_id.js +2 -0
  101. package/script/types/0_chat_photo.js +7 -7
  102. package/script/types/0_input_contact_message_content.d.ts +6 -0
  103. package/script/types/0_input_contact_message_content.js +2 -0
  104. package/script/types/0_input_location_message_content.d.ts +8 -0
  105. package/script/types/0_input_location_message_content.js +2 -0
  106. package/script/types/0_input_venue_message_content.d.ts +10 -0
  107. package/script/types/0_input_venue_message_content.js +2 -0
  108. package/script/types/0_labeled_price.d.ts +4 -0
  109. package/script/types/0_labeled_price.js +2 -0
  110. package/script/types/0_parse_mode.d.ts +1 -0
  111. package/script/types/0_parse_mode.js +2 -0
  112. package/script/types/0_thumbnail.js +5 -5
  113. package/script/types/{!0_misc.d.ts → 1__getters.d.ts} +7 -0
  114. package/script/types/1__getters.js +2 -0
  115. package/script/types/1_bot_command_scope.d.ts +32 -0
  116. package/script/types/1_bot_command_scope.js +31 -0
  117. package/script/types/1_inline_query_result_button.d.ts +6 -0
  118. package/script/types/1_inline_query_result_button.js +2 -0
  119. package/script/types/1_input_invoice_message_content.d.ts +23 -0
  120. package/script/types/1_input_invoice_message_content.js +2 -0
  121. package/script/types/1_input_text_message_content.d.ts +8 -0
  122. package/script/types/1_input_text_message_content.js +2 -0
  123. package/script/types/1_photo.js +5 -5
  124. package/script/types/2_game.js +3 -3
  125. package/{esm/types/1_inline_keyboard_button.d.ts → script/types/2_inline_keyboard_button.d.ts} +2 -2
  126. package/script/types/2_inline_query.d.ts +1 -1
  127. package/script/types/2_input_message_content.d.ts +6 -0
  128. package/script/types/2_input_message_content.js +2 -0
  129. package/script/types/{2_inline_keyboard_markup.d.ts → 3_inline_keyboard_markup.d.ts} +3 -2
  130. package/script/types/{2_inline_keyboard_markup.js → 3_inline_keyboard_markup.js} +3 -3
  131. package/script/types/3_message.d.ts +2 -2
  132. package/script/types/3_message.js +12 -12
  133. package/script/types/4_callback_query.d.ts +1 -1
  134. package/script/types/4_inline_query_result_article.d.ts +15 -0
  135. package/script/types/4_inline_query_result_article.js +2 -0
  136. package/script/types/4_inline_query_result_audio.d.ts +17 -0
  137. package/script/types/4_inline_query_result_audio.js +2 -0
  138. package/script/types/4_inline_query_result_cached_audio.d.ts +14 -0
  139. package/script/types/4_inline_query_result_cached_audio.js +2 -0
  140. package/script/types/4_inline_query_result_cached_document.d.ts +15 -0
  141. package/script/types/4_inline_query_result_cached_document.js +2 -0
  142. package/script/types/4_inline_query_result_cached_gif.d.ts +15 -0
  143. package/script/types/4_inline_query_result_cached_gif.js +2 -0
  144. package/script/types/4_inline_query_result_cached_mpeg4_gif.d.ts +15 -0
  145. package/script/types/4_inline_query_result_cached_mpeg4_gif.js +2 -0
  146. package/script/types/4_inline_query_result_cached_photo.d.ts +16 -0
  147. package/script/types/4_inline_query_result_cached_photo.js +2 -0
  148. package/script/types/4_inline_query_result_cached_sticker.d.ts +9 -0
  149. package/script/types/4_inline_query_result_cached_sticker.js +2 -0
  150. package/script/types/4_inline_query_result_cached_video.d.ts +16 -0
  151. package/script/types/4_inline_query_result_cached_video.js +2 -0
  152. package/script/types/4_inline_query_result_cached_voice.d.ts +15 -0
  153. package/script/types/4_inline_query_result_cached_voice.js +2 -0
  154. package/script/types/4_inline_query_result_contact.d.ts +15 -0
  155. package/script/types/4_inline_query_result_contact.js +2 -0
  156. package/script/types/4_inline_query_result_document.d.ts +18 -0
  157. package/script/types/4_inline_query_result_document.js +2 -0
  158. package/script/types/4_inline_query_result_game.d.ts +7 -0
  159. package/script/types/4_inline_query_result_game.js +2 -0
  160. package/script/types/4_inline_query_result_gif.d.ts +20 -0
  161. package/script/types/4_inline_query_result_gif.js +2 -0
  162. package/script/types/4_inline_query_result_location.d.ts +18 -0
  163. package/script/types/4_inline_query_result_location.js +2 -0
  164. package/script/types/4_inline_query_result_mpeg4_gif.d.ts +20 -0
  165. package/script/types/4_inline_query_result_mpeg4_gif.js +2 -0
  166. package/script/types/4_inline_query_result_photo.d.ts +19 -0
  167. package/script/types/4_inline_query_result_photo.js +2 -0
  168. package/script/types/4_inline_query_result_venue.d.ts +19 -0
  169. package/script/types/4_inline_query_result_venue.js +2 -0
  170. package/script/types/4_inline_query_result_video.d.ts +21 -0
  171. package/script/types/4_inline_query_result_video.js +2 -0
  172. package/script/types/4_inline_query_result_voice.d.ts +16 -0
  173. package/script/types/4_inline_query_result_voice.js +2 -0
  174. package/script/types/4_reply_markup.d.ts +7 -0
  175. package/script/types/4_reply_markup.js +26 -0
  176. package/script/types/5_inline_query_result.d.ts +29 -0
  177. package/script/types/5_inline_query_result.js +260 -0
  178. /package/esm/types/{!0_file_id.d.ts → 0__file_id.d.ts} +0 -0
  179. /package/esm/types/{!0_file_id.js → 0__file_id.js} +0 -0
  180. /package/esm/types/{!0_misc.js → 0_bot_command.js} +0 -0
  181. /package/esm/types/{1_inline_keyboard_button.js → 2_inline_keyboard_button.js} +0 -0
  182. /package/script/types/{!0_file_id.d.ts → 0__file_id.d.ts} +0 -0
  183. /package/script/types/{!0_file_id.js → 0__file_id.js} +0 -0
  184. /package/script/types/{!0_misc.js → 0_bot_command.js} +0 -0
  185. /package/script/types/{1_inline_keyboard_button.js → 2_inline_keyboard_button.js} +0 -0
package/esm/3_types.d.ts CHANGED
@@ -1,16 +1,24 @@
1
- export * from "./types/!0_file_id.js";
2
1
  export * from "./types/0_audio.js";
2
+ export * from "./types/0_bot_command.js";
3
3
  export * from "./types/0_chat_action.js";
4
4
  export * from "./types/0_chat_administrator_rights.js";
5
+ export * from "./types/0_chat_id.js";
5
6
  export * from "./types/0_chat_photo.js";
7
+ export * from "./types/0_color.js";
6
8
  export * from "./types/0_contact.js";
7
9
  export * from "./types/0_dice.js";
10
+ export * from "./types/0__file_id.js";
8
11
  export * from "./types/0_force_reply.js";
12
+ export * from "./types/0_input_contact_message_content.js";
13
+ export * from "./types/0_input_location_message_content.js";
14
+ export * from "./types/0_input_venue_message_content.js";
9
15
  export * from "./types/0_keyboard_button_poll_type.js";
16
+ export * from "./types/0_labeled_price.js";
10
17
  export * from "./types/0_location.js";
11
18
  export * from "./types/0_login_url.js";
12
19
  export * from "./types/0_mask_position.js";
13
20
  export * from "./types/0_message_entity.js";
21
+ export * from "./types/0_parse_mode.js";
14
22
  export * from "./types/0_poll_option.js";
15
23
  export * from "./types/0_reply_keyboard_remove.js";
16
24
  export * from "./types/0_thumbnail.js";
@@ -18,9 +26,13 @@ export * from "./types/0_venue.js";
18
26
  export * from "./types/0_voice.js";
19
27
  export * from "./types/0_web_app_info.js";
20
28
  export * from "./types/1_animation.js";
29
+ export * from "./types/1_bot_command_scope.js";
21
30
  export * from "./types/1_chat.js";
22
31
  export * from "./types/1_document.js";
23
- export * from "./types/1_inline_keyboard_button.js";
32
+ export * from "./types/1__getters.js";
33
+ export * from "./types/1_inline_query_result_button.js";
34
+ export * from "./types/1_input_invoice_message_content.js";
35
+ export * from "./types/1_input_text_message_content.js";
24
36
  export * from "./types/1_keyboard_button.js";
25
37
  export * from "./types/1_photo.js";
26
38
  export * from "./types/1_poll.js";
@@ -29,8 +41,32 @@ export * from "./types/1_user.js";
29
41
  export * from "./types/1_video_note.js";
30
42
  export * from "./types/1_video.js";
31
43
  export * from "./types/2_game.js";
32
- export * from "./types/2_inline_keyboard_markup.js";
44
+ export * from "./types/2_inline_keyboard_button.js";
33
45
  export * from "./types/2_inline_query.js";
46
+ export * from "./types/2_input_message_content.js";
34
47
  export * from "./types/2_reply_keyboard_markup.js";
48
+ export * from "./types/3_inline_keyboard_markup.js";
35
49
  export * from "./types/3_message.js";
36
50
  export * from "./types/4_callback_query.js";
51
+ export * from "./types/4_inline_query_result_article.js";
52
+ export * from "./types/4_inline_query_result_audio.js";
53
+ export * from "./types/4_inline_query_result_cached_audio.js";
54
+ export * from "./types/4_inline_query_result_cached_document.js";
55
+ export * from "./types/4_inline_query_result_cached_gif.js";
56
+ export * from "./types/4_inline_query_result_cached_mpeg4_gif.js";
57
+ export * from "./types/4_inline_query_result_cached_photo.js";
58
+ export * from "./types/4_inline_query_result_cached_sticker.js";
59
+ export * from "./types/4_inline_query_result_cached_video.js";
60
+ export * from "./types/4_inline_query_result_cached_voice.js";
61
+ export * from "./types/4_inline_query_result_contact.js";
62
+ export * from "./types/4_inline_query_result_document.js";
63
+ export * from "./types/4_inline_query_result_game.js";
64
+ export * from "./types/4_inline_query_result_gif.js";
65
+ export * from "./types/4_inline_query_result_location.js";
66
+ export * from "./types/4_inline_query_result_mpeg4_gif.js";
67
+ export * from "./types/4_inline_query_result_photo.js";
68
+ export * from "./types/4_inline_query_result_venue.js";
69
+ export * from "./types/4_inline_query_result_video.js";
70
+ export * from "./types/4_inline_query_result_voice.js";
71
+ export * from "./types/4_reply_markup.js";
72
+ export * from "./types/5_inline_query_result.js";
package/esm/3_types.js CHANGED
@@ -1,16 +1,24 @@
1
- export * from "./types/!0_file_id.js";
2
1
  export * from "./types/0_audio.js";
2
+ export * from "./types/0_bot_command.js";
3
3
  export * from "./types/0_chat_action.js";
4
4
  export * from "./types/0_chat_administrator_rights.js";
5
+ export * from "./types/0_chat_id.js";
5
6
  export * from "./types/0_chat_photo.js";
7
+ export * from "./types/0_color.js";
6
8
  export * from "./types/0_contact.js";
7
9
  export * from "./types/0_dice.js";
10
+ export * from "./types/0__file_id.js";
8
11
  export * from "./types/0_force_reply.js";
12
+ export * from "./types/0_input_contact_message_content.js";
13
+ export * from "./types/0_input_location_message_content.js";
14
+ export * from "./types/0_input_venue_message_content.js";
9
15
  export * from "./types/0_keyboard_button_poll_type.js";
16
+ export * from "./types/0_labeled_price.js";
10
17
  export * from "./types/0_location.js";
11
18
  export * from "./types/0_login_url.js";
12
19
  export * from "./types/0_mask_position.js";
13
20
  export * from "./types/0_message_entity.js";
21
+ export * from "./types/0_parse_mode.js";
14
22
  export * from "./types/0_poll_option.js";
15
23
  export * from "./types/0_reply_keyboard_remove.js";
16
24
  export * from "./types/0_thumbnail.js";
@@ -18,9 +26,13 @@ export * from "./types/0_venue.js";
18
26
  export * from "./types/0_voice.js";
19
27
  export * from "./types/0_web_app_info.js";
20
28
  export * from "./types/1_animation.js";
29
+ export * from "./types/1_bot_command_scope.js";
21
30
  export * from "./types/1_chat.js";
22
31
  export * from "./types/1_document.js";
23
- export * from "./types/1_inline_keyboard_button.js";
32
+ export * from "./types/1__getters.js";
33
+ export * from "./types/1_inline_query_result_button.js";
34
+ export * from "./types/1_input_invoice_message_content.js";
35
+ export * from "./types/1_input_text_message_content.js";
24
36
  export * from "./types/1_keyboard_button.js";
25
37
  export * from "./types/1_photo.js";
26
38
  export * from "./types/1_poll.js";
@@ -29,8 +41,32 @@ export * from "./types/1_user.js";
29
41
  export * from "./types/1_video_note.js";
30
42
  export * from "./types/1_video.js";
31
43
  export * from "./types/2_game.js";
32
- export * from "./types/2_inline_keyboard_markup.js";
44
+ export * from "./types/2_inline_keyboard_button.js";
33
45
  export * from "./types/2_inline_query.js";
46
+ export * from "./types/2_input_message_content.js";
34
47
  export * from "./types/2_reply_keyboard_markup.js";
48
+ export * from "./types/3_inline_keyboard_markup.js";
35
49
  export * from "./types/3_message.js";
36
50
  export * from "./types/4_callback_query.js";
51
+ export * from "./types/4_inline_query_result_article.js";
52
+ export * from "./types/4_inline_query_result_audio.js";
53
+ export * from "./types/4_inline_query_result_cached_audio.js";
54
+ export * from "./types/4_inline_query_result_cached_document.js";
55
+ export * from "./types/4_inline_query_result_cached_gif.js";
56
+ export * from "./types/4_inline_query_result_cached_mpeg4_gif.js";
57
+ export * from "./types/4_inline_query_result_cached_photo.js";
58
+ export * from "./types/4_inline_query_result_cached_sticker.js";
59
+ export * from "./types/4_inline_query_result_cached_video.js";
60
+ export * from "./types/4_inline_query_result_cached_voice.js";
61
+ export * from "./types/4_inline_query_result_contact.js";
62
+ export * from "./types/4_inline_query_result_document.js";
63
+ export * from "./types/4_inline_query_result_game.js";
64
+ export * from "./types/4_inline_query_result_gif.js";
65
+ export * from "./types/4_inline_query_result_location.js";
66
+ export * from "./types/4_inline_query_result_mpeg4_gif.js";
67
+ export * from "./types/4_inline_query_result_photo.js";
68
+ export * from "./types/4_inline_query_result_venue.js";
69
+ export * from "./types/4_inline_query_result_video.js";
70
+ export * from "./types/4_inline_query_result_voice.js";
71
+ export * from "./types/4_reply_markup.js";
72
+ export * from "./types/5_inline_query_result.js";
@@ -5,7 +5,7 @@ export declare const PUBLIC_KEYS: PublicKeys;
5
5
  export declare const VECTOR_CONSTRUCTOR = 481674261;
6
6
  export declare const INITIAL_DC: DC;
7
7
  export declare const LAYER = 161;
8
- export declare const APP_VERSION = "MTKruto 0.0.998";
8
+ export declare const APP_VERSION = "MTKruto 0.0.999";
9
9
  export declare const DEVICE_MODEL: string;
10
10
  export declare const LANG_CODE: string;
11
11
  export declare const LANG_PACK = "";
@@ -54,7 +54,7 @@ export const PUBLIC_KEYS = Object.freeze([
54
54
  export const VECTOR_CONSTRUCTOR = 0x1CB5C415;
55
55
  export const INITIAL_DC = "2-test";
56
56
  export const LAYER = 161;
57
- export const APP_VERSION = "MTKruto 0.0.998";
57
+ export const APP_VERSION = "MTKruto 0.0.999";
58
58
  // @ts-ignore: lib
59
59
  export const DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
60
60
  export const LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
@@ -1,5 +1,5 @@
1
1
  import { MaybePromise } from "../1_utilities.js";
2
- import { CallbackQuery, ForceReply, InlineKeyboardMarkup, InlineQuery, Message, MessageEntity, ReplyKeyboardMarkup, ReplyKeyboardRemove } from "../3_types.js";
2
+ import { CallbackQuery, ChatID, ForceReply, InlineKeyboardMarkup, InlineQuery, Message, MessageEntity, ReplyKeyboardMarkup, ReplyKeyboardRemove } from "../3_types.js";
3
3
  import { With } from "./0_utilities.js";
4
4
  import { ClientPlainParams } from "./2_client_plain.js";
5
5
  export type ParseMode = "HTML" | null;
@@ -52,10 +52,6 @@ export interface AuthorizeUserParams<S = string> {
52
52
  code: S | (() => MaybePromise<S>);
53
53
  password: S | ((hint: string | null) => MaybePromise<S>);
54
54
  }
55
- /**
56
- * A chat identifier as provided by MTKruto or a string starting with a @ that is followed by a username.
57
- */
58
- export type ChatID = number | string;
59
55
  export interface SendMessagesParams {
60
56
  /**
61
57
  * The parse mode to use. If not provided, the default parse mode will be used.
@@ -2,10 +2,10 @@ import { MaybePromise } from "../1_utilities.js";
2
2
  import { functions, ReadObject, types } from "../2_tl.js";
3
3
  import { Storage } from "../3_storage.js";
4
4
  import { DC } from "../3_transport.js";
5
- import { ChatAction, Message } from "../3_types.js";
5
+ import { BotCommand, BotCommandScope, ChatAction, ChatID, InlineQueryResult, InlineQueryResultButton, Message } from "../3_types.js";
6
6
  import { With } from "./0_utilities.js";
7
7
  import { ClientAbstract } from "./1_client_abstract.js";
8
- import { AnswerCallbackQueryParams, AuthorizeUserParams, ChatID, ClientParams, EditMessageParams, FilterableUpdates, FilterUpdate, ForwardMessagesParams, Handler, ParseMode, SendMessagesParams, SendPollParams, Update } from "./3_types.js";
8
+ import { AnswerCallbackQueryParams, AuthorizeUserParams, ClientParams, EditMessageParams, FilterableUpdates, FilterUpdate, ForwardMessagesParams, Handler, ParseMode, SendMessagesParams, SendPollParams, Update } from "./3_types.js";
9
9
  export declare const getEntity: unique symbol;
10
10
  export declare const getStickerSetName: unique symbol;
11
11
  export declare const handleMigrationError: unique symbol;
@@ -192,6 +192,7 @@ export declare class Client extends ClientAbstract {
192
192
  * @param id ID of the callback query to answer.
193
193
  */
194
194
  answerCallbackQuery(id: string, params?: AnswerCallbackQueryParams): Promise<void>;
195
+ private usernameResolver;
195
196
  private constructReplyMarkup;
196
197
  private static assertMsgHas;
197
198
  /**
@@ -210,6 +211,21 @@ export declare class Client extends ClientAbstract {
210
211
  * @param messageThreadId The thread to send the chat action to.
211
212
  */
212
213
  sendChatAction(chatId: ChatID, action_: ChatAction, messageThreadId?: number): Promise<void>;
214
+ setMyCommands(commands: BotCommand[], params?: {
215
+ languageCode?: string;
216
+ scope?: BotCommandScope;
217
+ }): Promise<void>;
218
+ getMyCommands(params?: {
219
+ languageCode?: string;
220
+ scope?: BotCommandScope;
221
+ }): Promise<BotCommand[]>;
222
+ answerInlineQuery(id: string, results: InlineQueryResult[], params?: {
223
+ cacheTime?: number;
224
+ isPersonal?: boolean;
225
+ nextOffset?: string;
226
+ isGallery?: boolean;
227
+ button: InlineQueryResultButton;
228
+ }): Promise<void>;
213
229
  private handle;
214
230
  use(handler: Handler): void;
215
231
  branch(predicate: (upd: Update) => MaybePromise<boolean>, trueHandler: Handler, falseHandler: Handler): void;
@@ -2,7 +2,7 @@ import { debug, gunzip, Mutex } from "../0_deps.js";
2
2
  import { bigIntFromBuffer, drop, getRandomBigInt, getRandomId, mustPrompt, mustPromptOneOf, Queue, sha1, UNREACHABLE } from "../1_utilities.js";
3
3
  import { as, functions, getChannelChatId, Message_, MessageContainer, peerToChatId, RPCResult, TLError, TLReader, types } from "../2_tl.js";
4
4
  import { StorageMemory } from "../3_storage.js";
5
- import { constructCallbackQuery, constructInlineQuery, constructMessage, constructUser, FileID, FileType, forceReplyToTlObject, inlineKeyboardMarkupToTlObject, messageEntityToTlObject, replyKeyboardMarkupToTlObject, replyKeyboardRemoveToTlObject, ThumbnailSource } from "../3_types.js";
5
+ import { botCommandScopeToTlObject, constructCallbackQuery, constructInlineQuery, constructMessage, constructUser, FileID, FileType, inlineQueryResultToTlObject, messageEntityToTlObject, replyMarkupToTlObject, ThumbnailSource } from "../3_types.js";
6
6
  import { ACK_THRESHOLD, APP_VERSION, CHANNEL_DIFFERENCE_LIMIT_BOT, CHANNEL_DIFFERENCE_LIMIT_USER, DEVICE_MODEL, LANG_CODE, LANG_PACK, LAYER, MAX_CHANNEL_ID, MAX_CHAT_ID, STICKER_SET_NAME_TTL, SYSTEM_LANG_CODE, SYSTEM_VERSION, USERNAME_TTL, ZERO_CHANNEL_ID } from "../4_constants.js";
7
7
  import { isChannelPtsUpdate, isPtsUpdate, resolve } from "./0_utilities.js";
8
8
  import { decryptMessage, encryptMessage, getMessageId } from "./0_message.js";
@@ -212,6 +212,15 @@ export class Client extends ClientAbstract {
212
212
  writable: true,
213
213
  value: new Queue("processUpdates")
214
214
  });
215
+ Object.defineProperty(this, "usernameResolver", {
216
+ enumerable: true,
217
+ configurable: true,
218
+ writable: true,
219
+ value: async (v) => {
220
+ const inputPeer = await this.getInputPeer(v).then((v) => v[as](types.InputPeerUser));
221
+ return new types.InputUser({ userId: inputPeer.userId, accessHash: inputPeer.accessHash });
222
+ }
223
+ });
215
224
  Object.defineProperty(this, "handle", {
216
225
  enumerable: true,
217
226
  configurable: true,
@@ -1504,29 +1513,10 @@ export class Client extends ClientAbstract {
1504
1513
  }));
1505
1514
  }
1506
1515
  async constructReplyMarkup(params) {
1507
- let replyMarkup = undefined;
1508
1516
  if (params?.replyMarkup) {
1509
1517
  await this.assertBot("replyMarkup");
1510
- if ("inlineKeyboard" in params.replyMarkup) {
1511
- replyMarkup = await inlineKeyboardMarkupToTlObject(params.replyMarkup, async (v) => {
1512
- const inputPeer = await this.getInputPeer(v).then((v) => v[as](types.InputPeerUser));
1513
- return new types.InputUser({ userId: inputPeer.userId, accessHash: inputPeer.accessHash });
1514
- });
1515
- }
1516
- else if ("keyboard" in params.replyMarkup) {
1517
- replyMarkup = replyKeyboardMarkupToTlObject(params.replyMarkup);
1518
- }
1519
- else if ("removeKeyboard" in params.replyMarkup) {
1520
- replyMarkup = replyKeyboardRemoveToTlObject(params.replyMarkup);
1521
- }
1522
- else if ("forceReply" in params.replyMarkup) {
1523
- replyMarkup = forceReplyToTlObject(params.replyMarkup);
1524
- }
1525
- else {
1526
- throw new Error("The replyMarkup parameter has an unexpected type");
1527
- }
1518
+ return replyMarkupToTlObject(params.replyMarkup, this.usernameResolver.bind(this));
1528
1519
  }
1529
- return replyMarkup;
1530
1520
  }
1531
1521
  static assertMsgHas(message, key) {
1532
1522
  if (!(key in message) || message[key] === undefined) {
@@ -1634,6 +1624,32 @@ export class Client extends ClientAbstract {
1634
1624
  }
1635
1625
  await this.invoke(new functions.MessagesSetTyping({ peer: await this.getInputPeer(chatId), action, topMsgId: messageThreadId }));
1636
1626
  }
1627
+ async setMyCommands(commands, params) {
1628
+ await this.invoke(new functions.BotsSetBotCommands({
1629
+ commands: commands.map((v) => new types.BotCommand(v)),
1630
+ langCode: params?.languageCode ?? "",
1631
+ scope: await botCommandScopeToTlObject(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)), // TODO: use params.scope
1632
+ }));
1633
+ }
1634
+ async getMyCommands(params) {
1635
+ const commands_ = await this.invoke(new functions.BotsGetBotCommands({
1636
+ langCode: params?.languageCode ?? "",
1637
+ scope: await botCommandScopeToTlObject(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)), // TODO: use params.scope
1638
+ }));
1639
+ return commands_.map((v) => ({ command: v.command, description: v.description }));
1640
+ }
1641
+ async answerInlineQuery(id, results, params) {
1642
+ await this.invoke(new functions.MessagesSetInlineBotResults({
1643
+ queryId: BigInt(id),
1644
+ results: await Promise.all(results.map((v) => inlineQueryResultToTlObject(v, this.parseText.bind(this), this.usernameResolver.bind(this)))),
1645
+ cacheTime: params?.cacheTime ?? 300,
1646
+ private: params?.isPersonal ? true : undefined,
1647
+ switchWebview: params?.button && params.button.webApp ? new types.InlineBotWebView({ text: params.button.text, url: params.button.webApp.url }) : undefined,
1648
+ switchPm: params?.button && params.button.startParameter ? new types.InlineBotSwitchPM({ text: params.button.text, startParam: params.button.startParameter }) : undefined,
1649
+ gallery: params?.isGallery ? true : undefined,
1650
+ nextOffset: params?.nextOffset,
1651
+ }));
1652
+ }
1637
1653
  use(handler) {
1638
1654
  const handle = this.handle;
1639
1655
  this.handle = async (upd, next) => {
@@ -1,5 +1,6 @@
1
1
  import * as dntShim from "../_dnt.shims.js";
2
2
  import { debug, Mutex } from "../0_deps.js";
3
+ import { UNREACHABLE } from "../1_utilities.js";
3
4
  import { ConnectionUnframed } from "./0_connection.js";
4
5
  const d = debug("ConnectionWebSocket");
5
6
  export class ConnectionWebSocket extends ConnectionUnframed {
@@ -75,7 +76,7 @@ export class ConnectionWebSocket extends ConnectionUnframed {
75
76
  return;
76
77
  }
77
78
  const release = await mutex.acquire();
78
- const data = new Uint8Array(await new Blob([e.data].map((v) => v instanceof Blob ? v : v instanceof ArrayBuffer ? v : Array.isArray(v) ? v.map((v) => v.buffer) : v.buffer).flat()).arrayBuffer());
79
+ const data = new Uint8Array(await new Blob([e.data].map((v) => v instanceof Blob || v instanceof Uint8Array ? v : v instanceof ArrayBuffer ? v : UNREACHABLE())).arrayBuffer());
79
80
  for (const byte of data) {
80
81
  this.buffer.push(byte);
81
82
  }
@@ -0,0 +1,4 @@
1
+ export interface BotCommand {
2
+ command: string;
3
+ description: string;
4
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * A chat identifier as provided by MTKruto or a string starting with a @ that is followed by a username.
3
+ */
4
+ export type ChatID = number | string;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { types } from "../2_tl.js";
2
- import { FileID, FileType, FileUniqueID, FileUniqueType, ThumbnailSource } from "./!0_file_id.js";
2
+ import { FileID, FileType, FileUniqueID, FileUniqueType, ThumbnailSource } from "./0__file_id.js";
3
3
  export function constructChatPhoto(photo, chatId, chatAccessHash) {
4
4
  const smallFileId = new FileID(null, null, FileType.ChatPhoto, photo.dcId, {
5
5
  mediaId: photo.photoId,
@@ -0,0 +1,6 @@
1
+ export interface InputContactMessageContent {
2
+ phoneNumber: string;
3
+ firstName: string;
4
+ lastName?: string;
5
+ vcard?: string;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ export interface InputLocationMessageContent {
2
+ latitude: number;
3
+ longitude: number;
4
+ horizontalAccuracy?: number;
5
+ livePeriod?: number;
6
+ heading?: number;
7
+ proximityAlertRadius?: number;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ export interface InputVenuMessageContent {
2
+ latitude: number;
3
+ loingitude: number;
4
+ title: string;
5
+ address: string;
6
+ foursquareId?: string;
7
+ foursquareType?: string;
8
+ googlePlaceId?: string;
9
+ googlePlaceType?: string;
10
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export interface LabeledPrice {
2
+ label: string;
3
+ amount: number;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export type ParseMode = "HTML" | null;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { types } from "../2_tl.js";
2
- import { FileID, FileType, FileUniqueID, FileUniqueType, ThumbnailSource } from "./!0_file_id.js";
2
+ import { FileID, FileType, FileUniqueID, FileUniqueType, ThumbnailSource } from "./0__file_id.js";
3
3
  export function constructThumbnail(size, file) {
4
4
  const fileType = file instanceof types.Photo ? FileType.Photo : FileType.Document;
5
5
  const fileId = new FileID(null, null, fileType, file.dcId, {
@@ -1,7 +1,14 @@
1
1
  import { MaybePromise } from "../1_utilities.js";
2
2
  import { types } from "../2_tl.js";
3
+ import { ChatID } from "./0_chat_id.js";
3
4
  export interface EntityGetter {
4
5
  (peer: types.PeerUser): MaybePromise<types.User | null>;
5
6
  (peer: types.PeerChat): MaybePromise<types.Chat | null>;
6
7
  (peer: types.PeerChannel): MaybePromise<types.Channel | null>;
7
8
  }
9
+ export interface InputPeerGetter {
10
+ (id: ChatID): Promise<types.InputPeerUser | types.InputPeerChannel | types.InputPeerChat>;
11
+ }
12
+ export interface UsernameResolver {
13
+ (username: string): MaybePromise<types.InputUser>;
14
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import { ChatID } from "./0_chat_id.js";
2
+ import { types } from "../2_tl.js";
3
+ import { InputPeerGetter } from "./1__getters.js";
4
+ export declare namespace BotCommandScope {
5
+ interface Default {
6
+ type: "default";
7
+ }
8
+ interface AllPrivateChats {
9
+ type: "allPrivateChats";
10
+ }
11
+ interface AllGroupChats {
12
+ type: "allGroupChats";
13
+ }
14
+ interface AllChatAdministrators {
15
+ type: "allChatAdministrators";
16
+ }
17
+ interface Chat {
18
+ type: "chat";
19
+ chatId: ChatID;
20
+ }
21
+ interface ChatAdministrators {
22
+ type: "chatAdministrators";
23
+ chatId: ChatID;
24
+ }
25
+ interface ChatMember {
26
+ type: "chatMember";
27
+ chatId: ChatID;
28
+ userId: number;
29
+ }
30
+ }
31
+ export type BotCommandScope = BotCommandScope.Default | BotCommandScope.AllPrivateChats | BotCommandScope.AllGroupChats | BotCommandScope.AllChatAdministrators | BotCommandScope.Chat | BotCommandScope.ChatAdministrators | BotCommandScope.ChatMember;
32
+ export declare function botCommandScopeToTlObject(scope: BotCommandScope, getInputPeer: InputPeerGetter): Promise<types.BotCommandScopeDefault | types.BotCommandScopeUsers | types.BotCommandScopeChats | types.BotCommandScopeChatAdmins | types.BotCommandScopePeer | types.BotCommandScopePeerAdmins | types.BotCommandScopePeerUser>;
@@ -0,0 +1,27 @@
1
+ import { types } from "../2_tl.js";
2
+ import { UNREACHABLE } from "../1_utilities.js";
3
+ export async function botCommandScopeToTlObject(scope, getInputPeer) {
4
+ switch (scope.type) {
5
+ case "default":
6
+ return new types.BotCommandScopeDefault();
7
+ case "allPrivateChats":
8
+ return new types.BotCommandScopeUsers();
9
+ case "allGroupChats":
10
+ return new types.BotCommandScopeChats();
11
+ case "allChatAdministrators":
12
+ return new types.BotCommandScopeChatAdmins();
13
+ case "chat":
14
+ return new types.BotCommandScopePeer({ peer: await getInputPeer(scope.chatId) });
15
+ case "chatAdministrators":
16
+ return new types.BotCommandScopePeerAdmins({ peer: await getInputPeer(scope.chatId) });
17
+ case "chatMember": {
18
+ const user = await getInputPeer(scope.userId);
19
+ if (!(user instanceof types.InputPeerUser)) {
20
+ UNREACHABLE();
21
+ }
22
+ return new types.BotCommandScopePeerUser({ peer: await getInputPeer(scope.chatId), userId: new types.InputUser({ userId: user.userId, accessHash: user.accessHash }) });
23
+ }
24
+ default:
25
+ UNREACHABLE();
26
+ }
27
+ }
@@ -0,0 +1,6 @@
1
+ import { WebAppInfo } from "./0_web_app_info.js";
2
+ export interface InlineQueryResultButton {
3
+ text: string;
4
+ webApp?: WebAppInfo;
5
+ startParameter?: string;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import { LabeledPrice } from "../tl/2_types.js";
2
+ export interface InputInvoiceMessageContent {
3
+ title: string;
4
+ description: string;
5
+ payload: string;
6
+ providerToken: string;
7
+ currency: string;
8
+ prices: LabeledPrice[];
9
+ maxTipAmount?: number;
10
+ suggestedTipAmounts?: number[];
11
+ providerData?: string;
12
+ photoUrl?: string;
13
+ photoSize?: number;
14
+ photoWidth?: number;
15
+ photoHeight?: number;
16
+ needName?: boolean;
17
+ needPhoneNumber?: boolean;
18
+ needEmail?: boolean;
19
+ needShippingAAddress?: boolean;
20
+ sendPhoneNumberToPorvider?: boolean;
21
+ sendEmailToProvider?: boolean;
22
+ isFlexible?: boolean;
23
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { MessageEntity } from "./0_message_entity.js";
2
+ import { ParseMode } from "./0_parse_mode.js";
3
+ export interface InputTextMessageContent {
4
+ messageText: string;
5
+ parseMode?: ParseMode;
6
+ entities?: MessageEntity[];
7
+ disableWebPagePreview?: boolean;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { types } from "../2_tl.js";
2
- import { FileID, FileType, FileUniqueID, FileUniqueType, ThumbnailSource } from "./!0_file_id.js";
2
+ import { FileID, FileType, FileUniqueID, FileUniqueType, ThumbnailSource } from "./0__file_id.js";
3
3
  import { constructThumbnail } from "./0_thumbnail.js";
4
4
  export function constructPhoto(photo) {
5
5
  const sizes = photo.sizes
@@ -1,6 +1,6 @@
1
1
  import { cleanObject } from "../1_utilities.js";
2
2
  import { as, types } from "../2_tl.js";
3
- import { FileID, FileType, FileUniqueID, FileUniqueType } from "./!0_file_id.js";
3
+ import { FileID, FileType, FileUniqueID, FileUniqueType } from "./0__file_id.js";
4
4
  import { constructAnimation } from "./1_animation.js";
5
5
  import { constructPhoto } from "./1_photo.js";
6
6
  export function constructGame(media_) {
@@ -1,7 +1,7 @@
1
- import { MaybePromise } from "../1_utilities.js";
2
1
  import { types } from "../2_tl.js";
3
2
  import { WebAppInfo } from "./0_web_app_info.js";
4
3
  import { LoginUrl } from "./0_login_url.js";
4
+ import { UsernameResolver } from "./1__getters.js";
5
5
  export declare namespace InlineKeyboardButton {
6
6
  interface Base {
7
7
  /** Label text on the button */
@@ -42,4 +42,4 @@ export declare namespace InlineKeyboardButton {
42
42
  /** This object represents one button of an inline keyboard. You **must** use exactly one of the optional fields. */
43
43
  export type InlineKeyboardButton = InlineKeyboardButton.URL | InlineKeyboardButton.Callback | InlineKeyboardButton.WebApp | InlineKeyboardButton.Login | InlineKeyboardButton.SwitchInline | InlineKeyboardButton.SwitchInlineCurrent | InlineKeyboardButton.Game | InlineKeyboardButton.Pay;
44
44
  export declare function constructInlineKeyboardButton(button_: types.TypeKeyboardButton): InlineKeyboardButton;
45
- export declare function inlineKeyboardButtonToTlObject(button: InlineKeyboardButton, usernameResolver: (username: string) => MaybePromise<types.InputUser>): Promise<types.KeyboardButtonURL | types.KeyboardButtonCallback | types.KeyboardButtonSwitchInline | types.KeyboardButtonBuy | types.InputKeyboardButtonURLAuth | types.KeyboardButtonWebView>;
45
+ export declare function inlineKeyboardButtonToTlObject(button: InlineKeyboardButton, usernameResolver: UsernameResolver): Promise<types.KeyboardButtonURL | types.KeyboardButtonCallback | types.KeyboardButtonSwitchInline | types.KeyboardButtonBuy | types.InputKeyboardButtonURLAuth | types.KeyboardButtonWebView>;
@@ -1,6 +1,6 @@
1
1
  import { types } from "../2_tl.js";
2
- import { EntityGetter } from "./!0_misc.js";
3
2
  import { Location } from "./0_location.js";
3
+ import { EntityGetter } from "./1__getters.js";
4
4
  import { User } from "./1_user.js";
5
5
  export interface InlineQuery {
6
6
  /** Unique identifier for this query */
@@ -0,0 +1,6 @@
1
+ import { InputContactMessageContent } from "./0_input_contact_message_content.js";
2
+ import { InputLocationMessageContent } from "./0_input_location_message_content.js";
3
+ import { InputVenuMessageContent } from "./0_input_venue_message_content.js";
4
+ import { InputInvoiceMessageContent } from "./1_input_invoice_message_content.js";
5
+ import { InputTextMessageContent } from "./1_input_text_message_content.js";
6
+ export type InputMessageContent = InputTextMessageContent | InputLocationMessageContent | InputVenuMessageContent | InputContactMessageContent | InputInvoiceMessageContent;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,9 +1,10 @@
1
1
  import { types } from "../2_tl.js";
2
- import { InlineKeyboardButton, inlineKeyboardButtonToTlObject } from "./1_inline_keyboard_button.js";
2
+ import { UsernameResolver } from "./1__getters.js";
3
+ import { InlineKeyboardButton } from "./2_inline_keyboard_button.js";
3
4
  /** This object represents an inline keyboard that appears right next to the message it belongs to. */
4
5
  export interface InlineKeyboardMarkup {
5
6
  /** Array of button rows, each represented by an Array of InlineKeyboardButton objects */
6
7
  inlineKeyboard: InlineKeyboardButton[][];
7
8
  }
8
9
  export declare function constructInlineKeyboardMarkup(keyboard_: types.ReplyInlineMarkup): InlineKeyboardMarkup;
9
- export declare function inlineKeyboardMarkupToTlObject(keyboard: InlineKeyboardMarkup, usernameResolver: Parameters<typeof inlineKeyboardButtonToTlObject>[1]): Promise<types.ReplyInlineMarkup>;
10
+ export declare function inlineKeyboardMarkupToTlObject(keyboard: InlineKeyboardMarkup, usernameResolver: UsernameResolver): Promise<types.ReplyInlineMarkup>;