@mtkruto/node 0.1.800 → 0.2.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 (664) hide show
  1. package/esm/0_deps.d.ts +2 -0
  2. package/esm/0_deps.d.ts.map +1 -1
  3. package/esm/0_deps.js +2 -1
  4. package/esm/2_tl.d.ts +7 -8
  5. package/esm/2_tl.d.ts.map +1 -1
  6. package/esm/2_tl.js +7 -8
  7. package/esm/3_errors.d.ts +519 -515
  8. package/esm/3_errors.d.ts.map +1 -1
  9. package/esm/3_errors.js +527 -512
  10. package/esm/3_transport.d.ts +1 -0
  11. package/esm/3_transport.d.ts.map +1 -1
  12. package/esm/3_transport.js +1 -0
  13. package/esm/4_errors.d.ts +7 -7
  14. package/esm/4_errors.d.ts.map +1 -1
  15. package/esm/4_errors.js +5 -5
  16. package/esm/client/0_client_abstract.d.ts +1 -21
  17. package/esm/client/0_client_abstract.d.ts.map +1 -1
  18. package/esm/client/0_client_abstract.js +17 -15
  19. package/esm/client/0_message.d.ts +3 -3
  20. package/esm/client/0_message.d.ts.map +1 -1
  21. package/esm/client/0_message.js +4 -20
  22. package/esm/client/0_params.d.ts +1 -1
  23. package/esm/client/0_params.d.ts.map +1 -1
  24. package/esm/client/0_password.d.ts +2 -2
  25. package/esm/client/0_password.d.ts.map +1 -1
  26. package/esm/client/0_password.js +3 -8
  27. package/esm/client/0_storage_operations.d.ts +23 -23
  28. package/esm/client/0_storage_operations.d.ts.map +1 -1
  29. package/esm/client/0_storage_operations.js +13 -12
  30. package/esm/client/0_utilities.d.ts.map +1 -1
  31. package/esm/client/0_utilities.js +13 -10
  32. package/esm/client/1_client_encrypted.d.ts +3 -5
  33. package/esm/client/1_client_encrypted.d.ts.map +1 -1
  34. package/esm/client/1_client_encrypted.js +44 -28
  35. package/esm/client/1_client_plain.d.ts +2 -2
  36. package/esm/client/1_client_plain.d.ts.map +1 -1
  37. package/esm/client/1_client_plain.js +27 -19
  38. package/esm/client/1_types.d.ts +9 -22
  39. package/esm/client/1_types.d.ts.map +1 -1
  40. package/esm/client/2_account_manager.d.ts +2 -2
  41. package/esm/client/2_account_manager.js +16 -16
  42. package/esm/client/2_bot_info_manager.d.ts.map +1 -1
  43. package/esm/client/2_bot_info_manager.js +7 -6
  44. package/esm/client/2_business_connection_manager.d.ts +3 -3
  45. package/esm/client/2_business_connection_manager.d.ts.map +1 -1
  46. package/esm/client/2_business_connection_manager.js +6 -5
  47. package/esm/client/2_file_manager.d.ts +4 -4
  48. package/esm/client/2_file_manager.d.ts.map +1 -1
  49. package/esm/client/2_file_manager.js +26 -23
  50. package/esm/client/2_reaction_manager.d.ts +3 -3
  51. package/esm/client/2_reaction_manager.d.ts.map +1 -1
  52. package/esm/client/2_reaction_manager.js +16 -10
  53. package/esm/client/2_update_manager.d.ts +11 -11
  54. package/esm/client/2_update_manager.d.ts.map +1 -1
  55. package/esm/client/2_update_manager.js +162 -160
  56. package/esm/client/3_message_manager.d.ts +8 -9
  57. package/esm/client/3_message_manager.d.ts.map +1 -1
  58. package/esm/client/3_message_manager.js +205 -474
  59. package/esm/client/3_video_chat_manager.d.ts +3 -3
  60. package/esm/client/3_video_chat_manager.d.ts.map +1 -1
  61. package/esm/client/3_video_chat_manager.js +26 -36
  62. package/esm/client/4_callback_query_manager.d.ts +3 -3
  63. package/esm/client/4_callback_query_manager.d.ts.map +1 -1
  64. package/esm/client/4_callback_query_manager.js +5 -16
  65. package/esm/client/4_chat_list_manager.d.ts +5 -4
  66. package/esm/client/4_chat_list_manager.d.ts.map +1 -1
  67. package/esm/client/4_chat_list_manager.js +56 -34
  68. package/esm/client/4_inline_query_manager.d.ts +3 -3
  69. package/esm/client/4_inline_query_manager.d.ts.map +1 -1
  70. package/esm/client/4_inline_query_manager.js +6 -15
  71. package/esm/client/4_story_manager.d.ts +3 -3
  72. package/esm/client/4_story_manager.d.ts.map +1 -1
  73. package/esm/client/4_story_manager.js +15 -32
  74. package/esm/client/5_client.d.ts +10 -12
  75. package/esm/client/5_client.d.ts.map +1 -1
  76. package/esm/client/5_client.js +60 -114
  77. package/esm/{tl/7_message.d.ts → connection/1_connection_tcp.d.ts} +14 -12
  78. package/esm/connection/1_connection_tcp.d.ts.map +1 -0
  79. package/esm/connection/1_connection_tcp.js +169 -0
  80. package/esm/deps/deno.land/std@0.224.0/io/_constants.d.ts +3 -0
  81. package/esm/deps/deno.land/std@0.224.0/io/_constants.d.ts.map +1 -0
  82. package/esm/deps/deno.land/std@0.224.0/io/_constants.js +4 -0
  83. package/esm/deps/deno.land/std@0.224.0/io/iterate_reader.d.ts +70 -0
  84. package/esm/deps/deno.land/std@0.224.0/io/iterate_reader.d.ts.map +1 -0
  85. package/esm/deps/deno.land/std@0.224.0/io/iterate_reader.js +86 -0
  86. package/esm/deps/deno.land/std@0.224.0/io/types.d.ts +95 -0
  87. package/esm/deps/deno.land/std@0.224.0/io/types.d.ts.map +1 -0
  88. package/esm/deps/deno.land/std@0.224.0/io/types.js +3 -0
  89. package/esm/deps/deno.land/std@0.224.0/io/write_all.d.ts +39 -0
  90. package/esm/deps/deno.land/std@0.224.0/io/write_all.d.ts.map +1 -0
  91. package/esm/deps/deno.land/std@0.224.0/io/write_all.js +49 -0
  92. package/esm/deps/raw.githubusercontent.com/MTKruto/socks5/main/client.d.ts +45 -0
  93. package/esm/deps/raw.githubusercontent.com/MTKruto/socks5/main/client.d.ts.map +1 -0
  94. package/esm/deps/raw.githubusercontent.com/MTKruto/socks5/main/client.js +253 -0
  95. package/esm/deps/raw.githubusercontent.com/MTKruto/socks5/main/deps.d.ts +3 -0
  96. package/esm/deps/raw.githubusercontent.com/MTKruto/socks5/main/deps.d.ts.map +1 -0
  97. package/esm/deps/raw.githubusercontent.com/MTKruto/socks5/main/deps.js +1 -0
  98. package/esm/deps/raw.githubusercontent.com/MTKruto/socks5/main/utils.d.ts +3 -0
  99. package/esm/deps/raw.githubusercontent.com/MTKruto/socks5/main/utils.d.ts.map +1 -0
  100. package/esm/deps/raw.githubusercontent.com/MTKruto/socks5/main/utils.js +13 -0
  101. package/esm/mod.d.ts +0 -1
  102. package/esm/mod.d.ts.map +1 -1
  103. package/esm/mod.js +0 -1
  104. package/esm/tl/0_api.d.ts +14813 -0
  105. package/esm/tl/0_api.d.ts.map +1 -0
  106. package/esm/tl/0_api.js +23222 -0
  107. package/esm/tl/1_utilities.d.ts +32 -0
  108. package/esm/tl/1_utilities.d.ts.map +1 -0
  109. package/esm/tl/1_utilities.js +65 -0
  110. package/esm/tl/1_utilities_test.d.ts.map +1 -0
  111. package/esm/tl/2_deserialize.d.ts +23 -0
  112. package/esm/tl/2_deserialize.d.ts.map +1 -0
  113. package/esm/tl/{3_deserialize.js → 2_deserialize.js} +16 -17
  114. package/esm/tl/2_serialize.d.ts +22 -0
  115. package/esm/tl/2_serialize.d.ts.map +1 -0
  116. package/esm/tl/2_serialize.js +160 -0
  117. package/esm/tl/2_serialize_test.d.ts.map +1 -0
  118. package/esm/tl/{4_tl_reader.d.ts → 3_tl_reader.d.ts} +3 -3
  119. package/esm/tl/3_tl_reader.d.ts.map +1 -0
  120. package/esm/tl/{4_tl_reader.js → 3_tl_reader.js} +5 -5
  121. package/esm/tl/3_utilities.d.ts +5 -5
  122. package/esm/tl/3_utilities.d.ts.map +1 -1
  123. package/esm/tl/3_utilities.js +9 -10
  124. package/esm/tl/4_rpc_result.d.ts +27 -0
  125. package/esm/tl/4_rpc_result.d.ts.map +1 -0
  126. package/esm/tl/4_rpc_result.js +28 -0
  127. package/{script/tl/5_tl_writer.d.ts → esm/tl/4_tl_writer.d.ts} +2 -2
  128. package/esm/tl/4_tl_writer.d.ts.map +1 -0
  129. package/esm/tl/{5_tl_writer.js → 4_tl_writer.js} +4 -4
  130. package/esm/tl/5_message.d.ts +39 -0
  131. package/esm/tl/5_message.d.ts.map +1 -0
  132. package/esm/tl/5_message.js +98 -0
  133. package/esm/tl/5_message_test.d.ts.map +1 -0
  134. package/esm/transport/3_transport_provider_tcp.d.ts +14 -0
  135. package/esm/transport/3_transport_provider_tcp.d.ts.map +1 -0
  136. package/esm/transport/3_transport_provider_tcp.js +15 -0
  137. package/esm/types/0_birthday.d.ts +2 -2
  138. package/esm/types/0_birthday.d.ts.map +1 -1
  139. package/esm/types/0_callback_query_answer.d.ts +2 -2
  140. package/esm/types/0_callback_query_answer.d.ts.map +1 -1
  141. package/esm/types/0_chat_administrator_rights.d.ts +3 -3
  142. package/esm/types/0_chat_administrator_rights.d.ts.map +1 -1
  143. package/esm/types/0_chat_administrator_rights.js +1 -11
  144. package/esm/types/0_chat_member_rights.d.ts +3 -3
  145. package/esm/types/0_chat_member_rights.d.ts.map +1 -1
  146. package/esm/types/0_chat_member_rights.js +3 -3
  147. package/esm/types/0_chat_photo.d.ts +2 -2
  148. package/esm/types/0_chat_photo.d.ts.map +1 -1
  149. package/esm/types/0_chat_photo.js +2 -2
  150. package/esm/types/0_contact.d.ts +2 -2
  151. package/esm/types/0_contact.d.ts.map +1 -1
  152. package/esm/types/0_dice.d.ts +2 -2
  153. package/esm/types/0_dice.d.ts.map +1 -1
  154. package/esm/types/0_giveaway_parameters.d.ts +2 -2
  155. package/esm/types/0_giveaway_parameters.d.ts.map +1 -1
  156. package/esm/types/0_giveaway_parameters.js +3 -3
  157. package/esm/types/0_link_preview.d.ts +2 -2
  158. package/esm/types/0_link_preview.d.ts.map +1 -1
  159. package/esm/types/0_live_stream_channel.d.ts +2 -2
  160. package/esm/types/0_live_stream_channel.d.ts.map +1 -1
  161. package/esm/types/0_location.d.ts +2 -2
  162. package/esm/types/0_location.d.ts.map +1 -1
  163. package/esm/types/0_location.js +5 -5
  164. package/esm/types/0_mask_position.d.ts +2 -2
  165. package/esm/types/0_mask_position.d.ts.map +1 -1
  166. package/esm/types/0_message_entity.d.ts +3 -3
  167. package/esm/types/0_message_entity.d.ts.map +1 -1
  168. package/esm/types/0_message_entity.js +42 -42
  169. package/esm/types/0_message_search_filter.d.ts +2 -2
  170. package/esm/types/0_message_search_filter.d.ts.map +1 -1
  171. package/esm/types/0_message_search_filter.js +14 -15
  172. package/esm/types/0_opening_hours.d.ts +2 -2
  173. package/esm/types/0_opening_hours.d.ts.map +1 -1
  174. package/esm/types/0_poll_option.d.ts +2 -2
  175. package/esm/types/0_poll_option.d.ts.map +1 -1
  176. package/esm/types/0_reaction.d.ts +3 -3
  177. package/esm/types/0_reaction.d.ts.map +1 -1
  178. package/esm/types/0_reaction.js +4 -4
  179. package/esm/types/0_restriction_reason.d.ts +2 -2
  180. package/esm/types/0_restriction_reason.d.ts.map +1 -1
  181. package/esm/types/0_thumbnail.d.ts +2 -2
  182. package/esm/types/0_thumbnail.d.ts.map +1 -1
  183. package/esm/types/0_thumbnail.js +3 -3
  184. package/esm/types/0_video_chat.d.ts +2 -2
  185. package/esm/types/0_video_chat.d.ts.map +1 -1
  186. package/esm/types/0_video_chat.js +2 -2
  187. package/esm/types/0_voice.d.ts +2 -2
  188. package/esm/types/0_voice.d.ts.map +1 -1
  189. package/esm/types/1_animation.d.ts +2 -2
  190. package/esm/types/1_animation.d.ts.map +1 -1
  191. package/esm/types/1_animation.js +2 -2
  192. package/esm/types/1_audio.d.ts +2 -2
  193. package/esm/types/1_audio.d.ts.map +1 -1
  194. package/esm/types/1_audio.js +2 -2
  195. package/esm/types/1_bot_command_scope.d.ts +9 -2
  196. package/esm/types/1_bot_command_scope.d.ts.map +1 -1
  197. package/esm/types/1_bot_command_scope.js +9 -9
  198. package/esm/types/1_chat_p.d.ts +5 -5
  199. package/esm/types/1_chat_p.d.ts.map +1 -1
  200. package/esm/types/1_chat_p.js +6 -6
  201. package/esm/types/1_document.d.ts +2 -2
  202. package/esm/types/1_document.d.ts.map +1 -1
  203. package/esm/types/1_document.js +2 -2
  204. package/esm/types/1_giveaway.d.ts +2 -2
  205. package/esm/types/1_giveaway.d.ts.map +1 -1
  206. package/esm/types/1_keyboard_button.d.ts +3 -3
  207. package/esm/types/1_keyboard_button.d.ts.map +1 -1
  208. package/esm/types/1_keyboard_button.js +18 -45
  209. package/esm/types/1_message_reaction.d.ts +2 -2
  210. package/esm/types/1_message_reaction.d.ts.map +1 -1
  211. package/esm/types/1_message_reaction.js +5 -5
  212. package/esm/types/1_photo.d.ts +5 -5
  213. package/esm/types/1_photo.d.ts.map +1 -1
  214. package/esm/types/1_photo.js +4 -4
  215. package/esm/types/1_poll.d.ts +2 -2
  216. package/esm/types/1_poll.d.ts.map +1 -1
  217. package/esm/types/1_reaction_count.d.ts +2 -2
  218. package/esm/types/1_reaction_count.d.ts.map +1 -1
  219. package/esm/types/1_reply_quote.d.ts +2 -2
  220. package/esm/types/1_reply_quote.d.ts.map +1 -1
  221. package/esm/types/1_sticker.d.ts +3 -3
  222. package/esm/types/1_sticker.d.ts.map +1 -1
  223. package/esm/types/1_sticker.js +9 -9
  224. package/esm/types/1_story_privacy.d.ts +3 -3
  225. package/esm/types/1_story_privacy.d.ts.map +1 -1
  226. package/esm/types/1_story_privacy.js +14 -14
  227. package/esm/types/1_story_reaction.d.ts +2 -2
  228. package/esm/types/1_story_reaction.d.ts.map +1 -1
  229. package/esm/types/1_user.d.ts +2 -2
  230. package/esm/types/1_user.d.ts.map +1 -1
  231. package/esm/types/1_user.js +2 -2
  232. package/esm/types/1_venue.d.ts +2 -2
  233. package/esm/types/1_venue.d.ts.map +1 -1
  234. package/esm/types/1_venue.js +2 -2
  235. package/esm/types/1_video.d.ts +2 -2
  236. package/esm/types/1_video.d.ts.map +1 -1
  237. package/esm/types/1_video.js +2 -2
  238. package/esm/types/1_video_note.d.ts +2 -2
  239. package/esm/types/1_video_note.d.ts.map +1 -1
  240. package/esm/types/1_video_note.js +2 -2
  241. package/esm/types/2_business_connection.d.ts +2 -2
  242. package/esm/types/2_business_connection.d.ts.map +1 -1
  243. package/esm/types/2_business_connection.js +1 -2
  244. package/esm/types/2_chat.d.ts +2 -2
  245. package/esm/types/2_chat.d.ts.map +1 -1
  246. package/esm/types/2_chat.js +11 -11
  247. package/esm/types/2_chat_member.d.ts +2 -2
  248. package/esm/types/2_chat_member.d.ts.map +1 -1
  249. package/esm/types/2_chat_member.js +10 -10
  250. package/esm/types/2_chosen_inline_result.d.ts +2 -2
  251. package/esm/types/2_chosen_inline_result.d.ts.map +1 -1
  252. package/esm/types/2_chosen_inline_result.js +5 -5
  253. package/esm/types/2_game.d.ts +2 -2
  254. package/esm/types/2_game.d.ts.map +1 -1
  255. package/esm/types/2_game.js +4 -4
  256. package/esm/types/2_inactive_chat.d.ts +2 -2
  257. package/esm/types/2_inactive_chat.d.ts.map +1 -1
  258. package/esm/types/2_inactive_chat.js +2 -2
  259. package/esm/types/2_inline_keyboard_button.d.ts +3 -3
  260. package/esm/types/2_inline_keyboard_button.d.ts.map +1 -1
  261. package/esm/types/2_inline_keyboard_button.js +15 -21
  262. package/esm/types/2_inline_query.d.ts +2 -2
  263. package/esm/types/2_inline_query.d.ts.map +1 -1
  264. package/esm/types/2_inline_query.js +8 -8
  265. package/esm/types/2_invite_link.d.ts +2 -2
  266. package/esm/types/2_invite_link.d.ts.map +1 -1
  267. package/esm/types/2_invite_link.js +1 -2
  268. package/esm/types/2_message_reaction_count.d.ts +2 -2
  269. package/esm/types/2_message_reaction_count.d.ts.map +1 -1
  270. package/esm/types/2_message_reactions.d.ts +2 -2
  271. package/esm/types/2_message_reactions.d.ts.map +1 -1
  272. package/esm/types/2_message_reactions.js +2 -2
  273. package/esm/types/2_story_content.d.ts +2 -2
  274. package/esm/types/2_story_content.d.ts.map +1 -1
  275. package/esm/types/2_story_content.js +6 -6
  276. package/esm/types/2_story_interactions.d.ts +2 -2
  277. package/esm/types/2_story_interactions.d.ts.map +1 -1
  278. package/esm/types/2_story_interactive_area.d.ts +3 -3
  279. package/esm/types/2_story_interactive_area.d.ts.map +1 -1
  280. package/esm/types/2_story_interactive_area.js +19 -29
  281. package/esm/types/3_chat_member_updated.d.ts +2 -2
  282. package/esm/types/3_chat_member_updated.d.ts.map +1 -1
  283. package/esm/types/3_chat_member_updated.js +7 -7
  284. package/esm/types/3_reply_markup.d.ts +3 -3
  285. package/esm/types/3_reply_markup.d.ts.map +1 -1
  286. package/esm/types/3_reply_markup.js +12 -22
  287. package/esm/types/3_story.d.ts +2 -2
  288. package/esm/types/3_story.d.ts.map +1 -1
  289. package/esm/types/4_inline_query_result.d.ts +3 -3
  290. package/esm/types/4_inline_query_result.d.ts.map +1 -1
  291. package/esm/types/4_inline_query_result.js +53 -161
  292. package/esm/types/4_message.d.ts +3 -3
  293. package/esm/types/4_message.d.ts.map +1 -1
  294. package/esm/types/4_message.js +68 -59
  295. package/esm/types/5_callback_query.d.ts +3 -3
  296. package/esm/types/5_callback_query.d.ts.map +1 -1
  297. package/esm/types/5_callback_query.js +5 -5
  298. package/esm/types/5_chat_list_item.d.ts +3 -3
  299. package/esm/types/5_chat_list_item.d.ts.map +1 -1
  300. package/esm/types/5_chat_list_item.js +2 -2
  301. package/esm/types/5_inline_query_answer.d.ts +2 -2
  302. package/esm/types/5_inline_query_answer.d.ts.map +1 -1
  303. package/esm/types/_file_id.d.ts +2 -2
  304. package/esm/types/_file_id.d.ts.map +1 -1
  305. package/esm/types/_file_id.js +4 -4
  306. package/esm/types/_getters.d.ts +7 -7
  307. package/esm/types/_getters.d.ts.map +1 -1
  308. package/package.json +1 -1
  309. package/script/0_deps.d.ts +2 -0
  310. package/script/0_deps.d.ts.map +1 -1
  311. package/script/0_deps.js +5 -2
  312. package/script/2_tl.d.ts +7 -8
  313. package/script/2_tl.d.ts.map +1 -1
  314. package/script/2_tl.js +20 -11
  315. package/script/3_errors.d.ts +519 -515
  316. package/script/3_errors.d.ts.map +1 -1
  317. package/script/3_errors.js +543 -514
  318. package/script/3_transport.d.ts +1 -0
  319. package/script/3_transport.d.ts.map +1 -1
  320. package/script/3_transport.js +1 -0
  321. package/script/4_errors.d.ts +7 -7
  322. package/script/4_errors.d.ts.map +1 -1
  323. package/script/4_errors.js +6 -6
  324. package/script/client/0_client_abstract.d.ts +1 -21
  325. package/script/client/0_client_abstract.d.ts.map +1 -1
  326. package/script/client/0_client_abstract.js +41 -16
  327. package/script/client/0_message.d.ts +3 -3
  328. package/script/client/0_message.d.ts.map +1 -1
  329. package/script/client/0_message.js +3 -19
  330. package/script/client/0_params.d.ts +1 -1
  331. package/script/client/0_params.d.ts.map +1 -1
  332. package/script/client/0_password.d.ts +2 -2
  333. package/script/client/0_password.d.ts.map +1 -1
  334. package/script/client/0_password.js +2 -7
  335. package/script/client/0_storage_operations.d.ts +23 -23
  336. package/script/client/0_storage_operations.d.ts.map +1 -1
  337. package/script/client/0_storage_operations.js +12 -11
  338. package/script/client/0_utilities.d.ts.map +1 -1
  339. package/script/client/0_utilities.js +12 -9
  340. package/script/client/1_client_encrypted.d.ts +3 -5
  341. package/script/client/1_client_encrypted.d.ts.map +1 -1
  342. package/script/client/1_client_encrypted.js +42 -26
  343. package/script/client/1_client_plain.d.ts +2 -2
  344. package/script/client/1_client_plain.d.ts.map +1 -1
  345. package/script/client/1_client_plain.js +25 -17
  346. package/script/client/1_types.d.ts +9 -22
  347. package/script/client/1_types.d.ts.map +1 -1
  348. package/script/client/2_account_manager.d.ts +2 -2
  349. package/script/client/2_account_manager.js +15 -15
  350. package/script/client/2_bot_info_manager.d.ts.map +1 -1
  351. package/script/client/2_bot_info_manager.js +7 -6
  352. package/script/client/2_business_connection_manager.d.ts +3 -3
  353. package/script/client/2_business_connection_manager.d.ts.map +1 -1
  354. package/script/client/2_business_connection_manager.js +5 -4
  355. package/script/client/2_file_manager.d.ts +4 -4
  356. package/script/client/2_file_manager.d.ts.map +1 -1
  357. package/script/client/2_file_manager.js +25 -22
  358. package/script/client/2_reaction_manager.d.ts +3 -3
  359. package/script/client/2_reaction_manager.d.ts.map +1 -1
  360. package/script/client/2_reaction_manager.js +15 -9
  361. package/script/client/2_update_manager.d.ts +11 -11
  362. package/script/client/2_update_manager.d.ts.map +1 -1
  363. package/script/client/2_update_manager.js +161 -159
  364. package/script/client/3_message_manager.d.ts +8 -9
  365. package/script/client/3_message_manager.d.ts.map +1 -1
  366. package/script/client/3_message_manager.js +204 -473
  367. package/script/client/3_video_chat_manager.d.ts +3 -3
  368. package/script/client/3_video_chat_manager.d.ts.map +1 -1
  369. package/script/client/3_video_chat_manager.js +25 -35
  370. package/script/client/4_callback_query_manager.d.ts +3 -3
  371. package/script/client/4_callback_query_manager.d.ts.map +1 -1
  372. package/script/client/4_callback_query_manager.js +4 -15
  373. package/script/client/4_chat_list_manager.d.ts +5 -4
  374. package/script/client/4_chat_list_manager.d.ts.map +1 -1
  375. package/script/client/4_chat_list_manager.js +54 -32
  376. package/script/client/4_inline_query_manager.d.ts +3 -3
  377. package/script/client/4_inline_query_manager.d.ts.map +1 -1
  378. package/script/client/4_inline_query_manager.js +5 -14
  379. package/script/client/4_story_manager.d.ts +3 -3
  380. package/script/client/4_story_manager.d.ts.map +1 -1
  381. package/script/client/4_story_manager.js +14 -31
  382. package/script/client/5_client.d.ts +10 -12
  383. package/script/client/5_client.d.ts.map +1 -1
  384. package/script/client/5_client.js +59 -113
  385. package/{esm/tl/6_rpc_result.d.ts → script/connection/1_connection_tcp.d.ts} +14 -10
  386. package/script/connection/1_connection_tcp.d.ts.map +1 -0
  387. package/script/connection/1_connection_tcp.js +196 -0
  388. package/script/deps/deno.land/std@0.224.0/io/_constants.d.ts +3 -0
  389. package/script/deps/deno.land/std@0.224.0/io/_constants.d.ts.map +1 -0
  390. package/script/deps/deno.land/std@0.224.0/io/_constants.js +7 -0
  391. package/script/deps/deno.land/std@0.224.0/io/iterate_reader.d.ts +70 -0
  392. package/script/deps/deno.land/std@0.224.0/io/iterate_reader.d.ts.map +1 -0
  393. package/script/deps/deno.land/std@0.224.0/io/iterate_reader.js +91 -0
  394. package/script/deps/deno.land/std@0.224.0/io/types.d.ts +95 -0
  395. package/script/deps/deno.land/std@0.224.0/io/types.d.ts.map +1 -0
  396. package/script/deps/deno.land/std@0.224.0/io/types.js +4 -0
  397. package/script/deps/deno.land/std@0.224.0/io/write_all.d.ts +39 -0
  398. package/script/deps/deno.land/std@0.224.0/io/write_all.d.ts.map +1 -0
  399. package/script/deps/deno.land/std@0.224.0/io/write_all.js +54 -0
  400. package/script/deps/raw.githubusercontent.com/MTKruto/socks5/main/client.d.ts +45 -0
  401. package/script/deps/raw.githubusercontent.com/MTKruto/socks5/main/client.d.ts.map +1 -0
  402. package/script/deps/raw.githubusercontent.com/MTKruto/socks5/main/client.js +280 -0
  403. package/script/deps/raw.githubusercontent.com/MTKruto/socks5/main/deps.d.ts +3 -0
  404. package/script/deps/raw.githubusercontent.com/MTKruto/socks5/main/deps.d.ts.map +1 -0
  405. package/script/deps/raw.githubusercontent.com/MTKruto/socks5/main/deps.js +5 -0
  406. package/script/deps/raw.githubusercontent.com/MTKruto/socks5/main/utils.d.ts +3 -0
  407. package/script/deps/raw.githubusercontent.com/MTKruto/socks5/main/utils.d.ts.map +1 -0
  408. package/script/deps/raw.githubusercontent.com/MTKruto/socks5/main/utils.js +40 -0
  409. package/script/mod.d.ts +0 -1
  410. package/script/mod.d.ts.map +1 -1
  411. package/script/mod.js +0 -1
  412. package/script/tl/0_api.d.ts +14813 -0
  413. package/script/tl/0_api.d.ts.map +1 -0
  414. package/script/tl/0_api.js +23248 -0
  415. package/script/tl/1_utilities.d.ts +32 -0
  416. package/script/tl/1_utilities.d.ts.map +1 -0
  417. package/script/tl/1_utilities.js +76 -0
  418. package/script/tl/1_utilities_test.d.ts.map +1 -0
  419. package/script/tl/2_deserialize.d.ts +23 -0
  420. package/script/tl/2_deserialize.d.ts.map +1 -0
  421. package/script/tl/{3_deserialize.js → 2_deserialize.js} +19 -20
  422. package/script/tl/2_serialize.d.ts +22 -0
  423. package/script/tl/2_serialize.d.ts.map +1 -0
  424. package/script/tl/2_serialize.js +164 -0
  425. package/script/tl/2_serialize_test.d.ts.map +1 -0
  426. package/script/tl/{4_tl_reader.d.ts → 3_tl_reader.d.ts} +3 -3
  427. package/script/tl/3_tl_reader.d.ts.map +1 -0
  428. package/script/tl/{4_tl_reader.js → 3_tl_reader.js} +5 -5
  429. package/script/tl/3_utilities.d.ts +5 -5
  430. package/script/tl/3_utilities.d.ts.map +1 -1
  431. package/script/tl/3_utilities.js +9 -10
  432. package/script/tl/4_rpc_result.d.ts +27 -0
  433. package/script/tl/4_rpc_result.d.ts.map +1 -0
  434. package/{esm/tl/8_message_container.d.ts → script/tl/4_rpc_result.js} +12 -12
  435. package/{esm/tl/5_tl_writer.d.ts → script/tl/4_tl_writer.d.ts} +2 -2
  436. package/script/tl/4_tl_writer.d.ts.map +1 -0
  437. package/script/tl/{5_tl_writer.js → 4_tl_writer.js} +4 -4
  438. package/script/tl/5_message.d.ts +39 -0
  439. package/script/tl/5_message.d.ts.map +1 -0
  440. package/script/tl/5_message.js +106 -0
  441. package/script/tl/5_message_test.d.ts.map +1 -0
  442. package/script/transport/3_transport_provider_tcp.d.ts +14 -0
  443. package/script/transport/3_transport_provider_tcp.d.ts.map +1 -0
  444. package/script/transport/3_transport_provider_tcp.js +19 -0
  445. package/script/types/0_birthday.d.ts +2 -2
  446. package/script/types/0_birthday.d.ts.map +1 -1
  447. package/script/types/0_callback_query_answer.d.ts +2 -2
  448. package/script/types/0_callback_query_answer.d.ts.map +1 -1
  449. package/script/types/0_chat_administrator_rights.d.ts +3 -3
  450. package/script/types/0_chat_administrator_rights.d.ts.map +1 -1
  451. package/script/types/0_chat_administrator_rights.js +1 -11
  452. package/script/types/0_chat_member_rights.d.ts +3 -3
  453. package/script/types/0_chat_member_rights.d.ts.map +1 -1
  454. package/script/types/0_chat_member_rights.js +3 -3
  455. package/script/types/0_chat_photo.d.ts +2 -2
  456. package/script/types/0_chat_photo.d.ts.map +1 -1
  457. package/script/types/0_chat_photo.js +1 -1
  458. package/script/types/0_contact.d.ts +2 -2
  459. package/script/types/0_contact.d.ts.map +1 -1
  460. package/script/types/0_dice.d.ts +2 -2
  461. package/script/types/0_dice.d.ts.map +1 -1
  462. package/script/types/0_giveaway_parameters.d.ts +2 -2
  463. package/script/types/0_giveaway_parameters.d.ts.map +1 -1
  464. package/script/types/0_giveaway_parameters.js +2 -2
  465. package/script/types/0_link_preview.d.ts +2 -2
  466. package/script/types/0_link_preview.d.ts.map +1 -1
  467. package/script/types/0_live_stream_channel.d.ts +2 -2
  468. package/script/types/0_live_stream_channel.d.ts.map +1 -1
  469. package/script/types/0_location.d.ts +2 -2
  470. package/script/types/0_location.d.ts.map +1 -1
  471. package/script/types/0_location.js +4 -4
  472. package/script/types/0_mask_position.d.ts +2 -2
  473. package/script/types/0_mask_position.d.ts.map +1 -1
  474. package/script/types/0_message_entity.d.ts +3 -3
  475. package/script/types/0_message_entity.d.ts.map +1 -1
  476. package/script/types/0_message_entity.js +41 -41
  477. package/script/types/0_message_search_filter.d.ts +2 -2
  478. package/script/types/0_message_search_filter.d.ts.map +1 -1
  479. package/script/types/0_message_search_filter.js +14 -15
  480. package/script/types/0_opening_hours.d.ts +2 -2
  481. package/script/types/0_opening_hours.d.ts.map +1 -1
  482. package/script/types/0_poll_option.d.ts +2 -2
  483. package/script/types/0_poll_option.d.ts.map +1 -1
  484. package/script/types/0_reaction.d.ts +3 -3
  485. package/script/types/0_reaction.d.ts.map +1 -1
  486. package/script/types/0_reaction.js +3 -3
  487. package/script/types/0_restriction_reason.d.ts +2 -2
  488. package/script/types/0_restriction_reason.d.ts.map +1 -1
  489. package/script/types/0_thumbnail.d.ts +2 -2
  490. package/script/types/0_thumbnail.d.ts.map +1 -1
  491. package/script/types/0_thumbnail.js +2 -2
  492. package/script/types/0_video_chat.d.ts +2 -2
  493. package/script/types/0_video_chat.d.ts.map +1 -1
  494. package/script/types/0_video_chat.js +1 -1
  495. package/script/types/0_voice.d.ts +2 -2
  496. package/script/types/0_voice.d.ts.map +1 -1
  497. package/script/types/1_animation.d.ts +2 -2
  498. package/script/types/1_animation.d.ts.map +1 -1
  499. package/script/types/1_animation.js +1 -1
  500. package/script/types/1_audio.d.ts +2 -2
  501. package/script/types/1_audio.d.ts.map +1 -1
  502. package/script/types/1_audio.js +1 -1
  503. package/script/types/1_bot_command_scope.d.ts +9 -2
  504. package/script/types/1_bot_command_scope.d.ts.map +1 -1
  505. package/script/types/1_bot_command_scope.js +8 -8
  506. package/script/types/1_chat_p.d.ts +5 -5
  507. package/script/types/1_chat_p.d.ts.map +1 -1
  508. package/script/types/1_chat_p.js +5 -5
  509. package/script/types/1_document.d.ts +2 -2
  510. package/script/types/1_document.d.ts.map +1 -1
  511. package/script/types/1_document.js +1 -1
  512. package/script/types/1_giveaway.d.ts +2 -2
  513. package/script/types/1_giveaway.d.ts.map +1 -1
  514. package/script/types/1_keyboard_button.d.ts +3 -3
  515. package/script/types/1_keyboard_button.d.ts.map +1 -1
  516. package/script/types/1_keyboard_button.js +17 -44
  517. package/script/types/1_message_reaction.d.ts +2 -2
  518. package/script/types/1_message_reaction.d.ts.map +1 -1
  519. package/script/types/1_message_reaction.js +4 -4
  520. package/script/types/1_photo.d.ts +5 -5
  521. package/script/types/1_photo.d.ts.map +1 -1
  522. package/script/types/1_photo.js +3 -3
  523. package/script/types/1_poll.d.ts +2 -2
  524. package/script/types/1_poll.d.ts.map +1 -1
  525. package/script/types/1_reaction_count.d.ts +2 -2
  526. package/script/types/1_reaction_count.d.ts.map +1 -1
  527. package/script/types/1_reply_quote.d.ts +2 -2
  528. package/script/types/1_reply_quote.d.ts.map +1 -1
  529. package/script/types/1_sticker.d.ts +3 -3
  530. package/script/types/1_sticker.d.ts.map +1 -1
  531. package/script/types/1_sticker.js +8 -8
  532. package/script/types/1_story_privacy.d.ts +3 -3
  533. package/script/types/1_story_privacy.d.ts.map +1 -1
  534. package/script/types/1_story_privacy.js +13 -13
  535. package/script/types/1_story_reaction.d.ts +2 -2
  536. package/script/types/1_story_reaction.d.ts.map +1 -1
  537. package/script/types/1_user.d.ts +2 -2
  538. package/script/types/1_user.d.ts.map +1 -1
  539. package/script/types/1_user.js +1 -1
  540. package/script/types/1_venue.d.ts +2 -2
  541. package/script/types/1_venue.d.ts.map +1 -1
  542. package/script/types/1_venue.js +1 -1
  543. package/script/types/1_video.d.ts +2 -2
  544. package/script/types/1_video.d.ts.map +1 -1
  545. package/script/types/1_video.js +1 -1
  546. package/script/types/1_video_note.d.ts +2 -2
  547. package/script/types/1_video_note.d.ts.map +1 -1
  548. package/script/types/1_video_note.js +1 -1
  549. package/script/types/2_business_connection.d.ts +2 -2
  550. package/script/types/2_business_connection.d.ts.map +1 -1
  551. package/script/types/2_business_connection.js +1 -2
  552. package/script/types/2_chat.d.ts +2 -2
  553. package/script/types/2_chat.d.ts.map +1 -1
  554. package/script/types/2_chat.js +10 -10
  555. package/script/types/2_chat_member.d.ts +2 -2
  556. package/script/types/2_chat_member.d.ts.map +1 -1
  557. package/script/types/2_chat_member.js +9 -9
  558. package/script/types/2_chosen_inline_result.d.ts +2 -2
  559. package/script/types/2_chosen_inline_result.d.ts.map +1 -1
  560. package/script/types/2_chosen_inline_result.js +4 -4
  561. package/script/types/2_game.d.ts +2 -2
  562. package/script/types/2_game.d.ts.map +1 -1
  563. package/script/types/2_game.js +3 -3
  564. package/script/types/2_inactive_chat.d.ts +2 -2
  565. package/script/types/2_inactive_chat.d.ts.map +1 -1
  566. package/script/types/2_inactive_chat.js +1 -1
  567. package/script/types/2_inline_keyboard_button.d.ts +3 -3
  568. package/script/types/2_inline_keyboard_button.d.ts.map +1 -1
  569. package/script/types/2_inline_keyboard_button.js +14 -20
  570. package/script/types/2_inline_query.d.ts +2 -2
  571. package/script/types/2_inline_query.d.ts.map +1 -1
  572. package/script/types/2_inline_query.js +7 -7
  573. package/script/types/2_invite_link.d.ts +2 -2
  574. package/script/types/2_invite_link.d.ts.map +1 -1
  575. package/script/types/2_invite_link.js +1 -2
  576. package/script/types/2_message_reaction_count.d.ts +2 -2
  577. package/script/types/2_message_reaction_count.d.ts.map +1 -1
  578. package/script/types/2_message_reactions.d.ts +2 -2
  579. package/script/types/2_message_reactions.d.ts.map +1 -1
  580. package/script/types/2_message_reactions.js +1 -1
  581. package/script/types/2_story_content.d.ts +2 -2
  582. package/script/types/2_story_content.d.ts.map +1 -1
  583. package/script/types/2_story_content.js +5 -5
  584. package/script/types/2_story_interactions.d.ts +2 -2
  585. package/script/types/2_story_interactions.d.ts.map +1 -1
  586. package/script/types/2_story_interactive_area.d.ts +3 -3
  587. package/script/types/2_story_interactive_area.d.ts.map +1 -1
  588. package/script/types/2_story_interactive_area.js +18 -28
  589. package/script/types/3_chat_member_updated.d.ts +2 -2
  590. package/script/types/3_chat_member_updated.d.ts.map +1 -1
  591. package/script/types/3_chat_member_updated.js +6 -6
  592. package/script/types/3_reply_markup.d.ts +3 -3
  593. package/script/types/3_reply_markup.d.ts.map +1 -1
  594. package/script/types/3_reply_markup.js +11 -21
  595. package/script/types/3_story.d.ts +2 -2
  596. package/script/types/3_story.d.ts.map +1 -1
  597. package/script/types/4_inline_query_result.d.ts +3 -3
  598. package/script/types/4_inline_query_result.d.ts.map +1 -1
  599. package/script/types/4_inline_query_result.js +52 -160
  600. package/script/types/4_message.d.ts +3 -3
  601. package/script/types/4_message.d.ts.map +1 -1
  602. package/script/types/4_message.js +67 -58
  603. package/script/types/5_callback_query.d.ts +3 -3
  604. package/script/types/5_callback_query.d.ts.map +1 -1
  605. package/script/types/5_callback_query.js +4 -4
  606. package/script/types/5_chat_list_item.d.ts +3 -3
  607. package/script/types/5_chat_list_item.d.ts.map +1 -1
  608. package/script/types/5_chat_list_item.js +1 -1
  609. package/script/types/5_inline_query_answer.d.ts +2 -2
  610. package/script/types/5_inline_query_answer.d.ts.map +1 -1
  611. package/script/types/_file_id.d.ts +2 -2
  612. package/script/types/_file_id.d.ts.map +1 -1
  613. package/script/types/_file_id.js +3 -3
  614. package/script/types/_getters.d.ts +7 -7
  615. package/script/types/_getters.d.ts.map +1 -1
  616. package/esm/tl/1_tl_object.d.ts +0 -64
  617. package/esm/tl/1_tl_object.d.ts.map +0 -1
  618. package/esm/tl/1_tl_object.js +0 -221
  619. package/esm/tl/1_tl_object_test.d.ts.map +0 -1
  620. package/esm/tl/2_types.d.ts +0 -28060
  621. package/esm/tl/2_types.d.ts.map +0 -1
  622. package/esm/tl/2_types.js +0 -68685
  623. package/esm/tl/2_types_test.d.ts.map +0 -1
  624. package/esm/tl/3_deserialize.d.ts +0 -23
  625. package/esm/tl/3_deserialize.d.ts.map +0 -1
  626. package/esm/tl/3_functions.d.ts +0 -14094
  627. package/esm/tl/3_functions.d.ts.map +0 -1
  628. package/esm/tl/3_functions.js +0 -28475
  629. package/esm/tl/3_functions_test.d.ts.map +0 -1
  630. package/esm/tl/4_tl_reader.d.ts.map +0 -1
  631. package/esm/tl/5_tl_writer.d.ts.map +0 -1
  632. package/esm/tl/6_rpc_result.d.ts.map +0 -1
  633. package/esm/tl/6_rpc_result.js +0 -49
  634. package/esm/tl/7_message.d.ts.map +0 -1
  635. package/esm/tl/7_message.js +0 -90
  636. package/esm/tl/7_message_test.d.ts.map +0 -1
  637. package/esm/tl/8_message_container.d.ts.map +0 -1
  638. package/esm/tl/8_message_container.js +0 -72
  639. package/script/tl/1_tl_object.d.ts +0 -64
  640. package/script/tl/1_tl_object.d.ts.map +0 -1
  641. package/script/tl/1_tl_object.js +0 -228
  642. package/script/tl/1_tl_object_test.d.ts.map +0 -1
  643. package/script/tl/2_types.d.ts +0 -28060
  644. package/script/tl/2_types.d.ts.map +0 -1
  645. package/script/tl/2_types.js +0 -70558
  646. package/script/tl/2_types_test.d.ts.map +0 -1
  647. package/script/tl/3_deserialize.d.ts +0 -23
  648. package/script/tl/3_deserialize.d.ts.map +0 -1
  649. package/script/tl/3_functions.d.ts +0 -14094
  650. package/script/tl/3_functions.d.ts.map +0 -1
  651. package/script/tl/3_functions.js +0 -29121
  652. package/script/tl/3_functions_test.d.ts.map +0 -1
  653. package/script/tl/4_tl_reader.d.ts.map +0 -1
  654. package/script/tl/5_tl_writer.d.ts.map +0 -1
  655. package/script/tl/6_rpc_result.d.ts +0 -30
  656. package/script/tl/6_rpc_result.d.ts.map +0 -1
  657. package/script/tl/6_rpc_result.js +0 -53
  658. package/script/tl/7_message.d.ts +0 -32
  659. package/script/tl/7_message.d.ts.map +0 -1
  660. package/script/tl/7_message.js +0 -95
  661. package/script/tl/7_message_test.d.ts.map +0 -1
  662. package/script/tl/8_message_container.d.ts +0 -32
  663. package/script/tl/8_message_container.d.ts.map +0 -1
  664. package/script/tl/8_message_container.js +0 -76
@@ -32,7 +32,7 @@ var _MessageManager_instances, _MessageManager_c, _MessageManager_LresolveFileId
32
32
  import { contentType, unreachable } from "../0_deps.js";
33
33
  import { InputError } from "../0_errors.js";
34
34
  import { getLogger, getRandomId, toUnixTimestamp } from "../1_utilities.js";
35
- import { as, functions, getChannelChatId, peerToChatId, types } from "../2_tl.js";
35
+ import { as, getChannelChatId, is, peerToChatId } from "../2_tl.js";
36
36
  import { constructChatMemberUpdated, constructInviteLink, deserializeFileId, selfDestructOptionToInt } from "../3_types.js";
37
37
  import { assertMessageType, chatMemberRightsToTlObject, constructChatMember, constructMessage as constructMessage_, deserializeInlineMessageId, FileType, messageEntityToTlObject, reactionEqual, reactionToTlObject, replyMarkupToTlObject } from "../3_types.js";
38
38
  import { messageSearchFilterToTlObject } from "../types/0_message_search_filter.js";
@@ -53,8 +53,8 @@ export class MessageManager {
53
53
  configurable: true,
54
54
  writable: true,
55
55
  value: async (v) => {
56
- const inputPeer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(v).then((v) => v[as](types.InputPeerUser));
57
- return new types.InputUser(inputPeer);
56
+ const inputPeer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(v).then((v) => as("inputPeerUser", v));
57
+ return { ...inputPeer, _: "inputUser" };
58
58
  }
59
59
  });
60
60
  __classPrivateFieldSet(this, _MessageManager_c, c, "f");
@@ -79,21 +79,19 @@ export class MessageManager {
79
79
  }
80
80
  }
81
81
  if (shouldFetch) {
82
- if (peer instanceof types.InputPeerChannel) {
83
- messages_ = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.getMessages({
84
- channel: new types.InputChannel(peer),
85
- id: messageIds.map((v) => new types.InputMessageID({ id: v })),
86
- }).then((v) => v[as](types.messages.ChannelMessages).messages);
82
+ if (is("inputPeerChannel", peer)) {
83
+ messages_ = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.getMessages", channel: ({ ...peer, _: "inputChannel" }), id: messageIds.map((v) => ({ _: "inputMessageID", id: v })) }).then((v) => as("messages.channelMessages", v).messages);
87
84
  }
88
85
  else {
89
- messages_ = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.getMessages({
90
- id: messageIds.map((v) => new types.InputMessageID({ id: v })),
91
- }).then((v) => v[as](types.messages.Messages).messages);
86
+ messages_ = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
87
+ _: "messages.getMessages",
88
+ id: messageIds.map((v) => ({ _: "inputMessageID", id: v })),
89
+ }).then((v) => as("messages.messages", v).messages);
92
90
  }
93
91
  }
94
92
  const messages = new Array();
95
93
  for (const message_ of messages_) {
96
- if (message_ instanceof types.MessageEmpty) {
94
+ if (is("messageEmpty", message_)) {
97
95
  continue;
98
96
  }
99
97
  const message = await this.constructMessage(message_);
@@ -156,18 +154,7 @@ export class MessageManager {
156
154
  }
157
155
  async forwardMessages(from, to, messageIds, params) {
158
156
  checkArray(messageIds, checkMessageId);
159
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.forwardMessages({
160
- from_peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(from),
161
- to_peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(to),
162
- id: messageIds,
163
- random_id: messageIds.map(() => getRandomId()),
164
- silent: params?.disableNotification || undefined,
165
- top_msg_id: params?.messageThreadId,
166
- noforwards: params?.disableNotification || undefined,
167
- send_as: params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined,
168
- drop_author: params?.dropSenderName || undefined,
169
- drop_media_captions: params?.dropCaption || undefined,
170
- });
157
+ const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.forwardMessages", from_peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(from), to_peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(to), id: messageIds, random_id: messageIds.map(() => getRandomId()), silent: params?.disableNotification || undefined, top_msg_id: params?.messageThreadId, noforwards: params?.disableNotification || undefined, send_as: params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined, drop_author: params?.dropSenderName || undefined, drop_media_captions: params?.dropCaption || undefined });
171
158
  return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, to, result);
172
159
  }
173
160
  async getHistory(chatId, params) {
@@ -188,16 +175,7 @@ export class MessageManager {
188
175
  if (messages.length > 0) {
189
176
  offsetId = messages[messages.length - 1].id; // TODO: track id of oldest message and don't send requests for it
190
177
  }
191
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.getHistory({
192
- peer: peer,
193
- offset_id: offsetId,
194
- offset_date: 0,
195
- add_offset: 0,
196
- limit,
197
- max_id: 0,
198
- min_id: 0,
199
- hash: 0n,
200
- });
178
+ const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.getHistory", peer: peer, offset_id: offsetId, offset_date: 0, add_offset: 0, limit, max_id: 0, min_id: 0, hash: 0n });
201
179
  if (!("messages" in result)) {
202
180
  unreachable();
203
181
  }
@@ -219,10 +197,12 @@ export class MessageManager {
219
197
  const sendAs = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveSendAs).call(this, params);
220
198
  let result;
221
199
  if (!noWebpage && params?.linkPreview?.url) {
222
- result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke(new functions.messages.sendMedia({
200
+ result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
201
+ _: "messages.sendMedia",
223
202
  peer,
224
203
  random_id: randomId,
225
- media: new types.InputMediaWebPage({
204
+ media: ({
205
+ _: "inputMediaWebPage",
226
206
  url: params.linkPreview.url,
227
207
  force_large_media: params.linkPreview.largeMedia ? true : undefined,
228
208
  force_small_media: params.linkPreview.smallMedia ? true : undefined,
@@ -236,10 +216,11 @@ export class MessageManager {
236
216
  send_as: sendAs,
237
217
  entities,
238
218
  reply_markup: replyMarkup,
239
- }), params?.businessConnectionId);
219
+ }, params?.businessConnectionId);
240
220
  }
241
221
  else {
242
- result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke(new functions.messages.sendMessage({
222
+ result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
223
+ _: "messages.sendMessage",
243
224
  peer,
244
225
  random_id: randomId,
245
226
  message,
@@ -251,7 +232,7 @@ export class MessageManager {
251
232
  send_as: sendAs,
252
233
  entities,
253
234
  reply_markup: replyMarkup,
254
- }), params?.businessConnectionId);
235
+ }, params?.businessConnectionId);
255
236
  }
256
237
  const message_ = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId).then((v) => v[0]);
257
238
  return assertMessageType(message_, "text");
@@ -261,9 +242,10 @@ export class MessageManager {
261
242
  const randomId = getRandomId();
262
243
  const silent = params?.disableNotification ? true : undefined;
263
244
  const noforwards = params?.protectContent ? true : undefined;
264
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
245
+ const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
265
246
  const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
266
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke(new functions.messages.sendMedia({
247
+ const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
248
+ _: "messages.sendMedia",
267
249
  peer,
268
250
  random_id: randomId,
269
251
  silent,
@@ -271,8 +253,10 @@ export class MessageManager {
271
253
  reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
272
254
  send_as: sendAs,
273
255
  reply_markup: replyMarkup,
274
- media: new types.InputMediaVenue({
275
- geo_point: new types.InputGeoPoint({
256
+ media: ({
257
+ _: "inputMediaVenue",
258
+ geo_point: ({
259
+ _: "inputGeoPoint",
276
260
  lat: latitude,
277
261
  long: longitude,
278
262
  }),
@@ -283,7 +267,7 @@ export class MessageManager {
283
267
  provider: "foursquare",
284
268
  }),
285
269
  message: "",
286
- }), params?.businessConnectionId);
270
+ }, params?.businessConnectionId);
287
271
  const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId).then((v) => v[0]);
288
272
  return assertMessageType(message, "venue");
289
273
  }
@@ -292,9 +276,10 @@ export class MessageManager {
292
276
  const randomId = getRandomId();
293
277
  const silent = params?.disableNotification ? true : undefined;
294
278
  const noforwards = params?.protectContent ? true : undefined;
295
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
279
+ const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
296
280
  const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
297
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke(new functions.messages.sendMedia({
281
+ const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
282
+ _: "messages.sendMedia",
298
283
  peer,
299
284
  random_id: randomId,
300
285
  silent,
@@ -302,14 +287,15 @@ export class MessageManager {
302
287
  reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
303
288
  send_as: sendAs,
304
289
  reply_markup: replyMarkup,
305
- media: new types.InputMediaContact({
290
+ media: ({
291
+ _: "inputMediaContact",
306
292
  phone_number: number,
307
293
  first_name: firstName,
308
294
  last_name: params?.lastName ?? "",
309
295
  vcard: params?.vcard ?? "",
310
296
  }),
311
297
  message: "",
312
- }), params?.businessConnectionId);
298
+ }, params?.businessConnectionId);
313
299
  const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId).then((v) => v[0]);
314
300
  return assertMessageType(message, "contact");
315
301
  }
@@ -318,9 +304,10 @@ export class MessageManager {
318
304
  const randomId = getRandomId();
319
305
  const silent = params?.disableNotification ? true : undefined;
320
306
  const noforwards = params?.protectContent ? true : undefined;
321
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
307
+ const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
322
308
  const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
323
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke(new functions.messages.sendMedia({
309
+ const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
310
+ _: "messages.sendMedia",
324
311
  peer,
325
312
  random_id: randomId,
326
313
  silent,
@@ -328,11 +315,12 @@ export class MessageManager {
328
315
  reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
329
316
  send_as: sendAs,
330
317
  reply_markup: replyMarkup,
331
- media: new types.InputMediaDice({
318
+ media: ({
319
+ _: "inputMediaDice",
332
320
  emoticon: params?.emoji ?? "🎲",
333
321
  }),
334
322
  message: "",
335
- }), params?.businessConnectionId);
323
+ }, params?.businessConnectionId);
336
324
  const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId).then((v) => v[0]);
337
325
  return assertMessageType(message, "dice");
338
326
  }
@@ -341,9 +329,10 @@ export class MessageManager {
341
329
  const randomId = getRandomId();
342
330
  const silent = params?.disableNotification ? true : undefined;
343
331
  const noforwards = params?.protectContent ? true : undefined;
344
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
332
+ const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
345
333
  const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
346
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke(new functions.messages.sendMedia({
334
+ const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
335
+ _: "messages.sendMedia",
347
336
  peer,
348
337
  random_id: randomId,
349
338
  silent,
@@ -352,8 +341,10 @@ export class MessageManager {
352
341
  send_as: sendAs,
353
342
  reply_markup: replyMarkup,
354
343
  media: params?.livePeriod !== undefined
355
- ? new types.InputMediaGeoLive({
356
- geo_point: new types.InputGeoPoint({
344
+ ? ({
345
+ _: "inputMediaGeoLive",
346
+ geo_point: ({
347
+ _: "inputGeoPoint",
357
348
  lat: latitude,
358
349
  long: longitude,
359
350
  accuracy_radius: params?.horizontalAccuracy,
@@ -362,68 +353,48 @@ export class MessageManager {
362
353
  period: params.livePeriod,
363
354
  proximity_notification_radius: params?.proximityAlertRadius,
364
355
  })
365
- : new types.InputMediaGeoPoint({
366
- geo_point: new types.InputGeoPoint({
356
+ : ({
357
+ _: "inputMediaGeoPoint",
358
+ geo_point: ({
359
+ _: "inputGeoPoint",
367
360
  lat: latitude,
368
361
  long: longitude,
369
362
  accuracy_radius: params?.horizontalAccuracy,
370
363
  }),
371
364
  }),
372
365
  message: "",
373
- }), params?.businessConnectionId);
366
+ }, params?.businessConnectionId);
374
367
  const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId).then((v) => v[0]);
375
368
  return assertMessageType(message, "location");
376
369
  }
377
370
  async sendVideoNote(chatId, audio, params) {
378
371
  const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, audio, params, FileType.VideoNote, [
379
- new types.DocumentAttributeVideo({
380
- round_message: true,
381
- w: params?.length ?? 0,
382
- h: params?.length ?? 0,
383
- duration: params?.duration ?? 0,
384
- }),
372
+ { _: "documentAttributeVideo", round_message: true, w: params?.length ?? 0, h: params?.length ?? 0, duration: params?.duration ?? 0 },
385
373
  ], false);
386
374
  return assertMessageType(message, "videoNote");
387
375
  }
388
376
  async sendAudio(chatId, audio, params) {
389
377
  const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, audio, params, FileType.Audio, [
390
- new types.DocumentAttributeAudio({
391
- duration: params?.duration ?? 0,
392
- performer: params?.performer,
393
- title: params?.title,
394
- }),
378
+ { _: "documentAttributeAudio", duration: params?.duration ?? 0, performer: params?.performer, title: params?.title },
395
379
  ]);
396
380
  return assertMessageType(message, "audio");
397
381
  }
398
382
  async sendVoice(chatId, voice, params) {
399
383
  const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, voice, params, FileType.VoiceNote, [
400
- new types.DocumentAttributeAudio({
401
- voice: true,
402
- duration: params?.duration ?? 0,
403
- }),
384
+ { _: "documentAttributeAudio", voice: true, duration: params?.duration ?? 0 },
404
385
  ]);
405
386
  return assertMessageType(message, "voice");
406
387
  }
407
388
  async sendAnimation(chatId, animation, params) {
408
389
  const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, animation, params, FileType.Animation, [
409
- new types.DocumentAttributeAnimated(),
410
- new types.DocumentAttributeVideo({
411
- supports_streaming: true,
412
- w: params?.width ?? 0,
413
- h: params?.height ?? 0,
414
- duration: params?.duration ?? 0,
415
- }),
390
+ { _: "documentAttributeAnimated" },
391
+ { _: "documentAttributeVideo", supports_streaming: true, w: params?.width ?? 0, h: params?.height ?? 0, duration: params?.duration ?? 0 },
416
392
  ]);
417
393
  return assertMessageType(message, "animation");
418
394
  }
419
395
  async sendVideo(chatId, video, params) {
420
396
  const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, video, params, FileType.Video, [
421
- new types.DocumentAttributeVideo({
422
- supports_streaming: params?.supportsStreaming ? true : undefined,
423
- w: params?.width ?? 0,
424
- h: params?.height ?? 0,
425
- duration: params?.duration ?? 0,
426
- }),
397
+ { _: "documentAttributeVideo", supports_streaming: params?.supportsStreaming ? true : undefined, w: params?.width ?? 0, h: params?.height ?? 0, duration: params?.duration ?? 0 },
427
398
  ]);
428
399
  return assertMessageType(message, "video");
429
400
  }
@@ -432,7 +403,7 @@ export class MessageManager {
432
403
  return assertMessageType(message, "document");
433
404
  }
434
405
  async sendSticker(chatId, sticker, params) {
435
- const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, sticker, params, FileType.Sticker, [new types.DocumentAttributeSticker({ alt: params?.emoji || "", stickerset: new types.InputStickerSetEmpty() })], undefined, STICKER_MIME_TYPES);
406
+ const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, sticker, params, FileType.Sticker, [{ _: "documentAttributeSticker", alt: params?.emoji || "", stickerset: { _: "inputStickerSetEmpty" } }], undefined, STICKER_MIME_TYPES);
436
407
  return assertMessageType(message, "sticker");
437
408
  }
438
409
  async sendPhoto(chatId, photo, params) {
@@ -442,28 +413,16 @@ export class MessageManager {
442
413
  if (typeof photo === "string") {
443
414
  const fileId = this.resolveFileId(photo, [FileType.Photo, FileType.ProfilePhoto]);
444
415
  if (fileId != null) {
445
- media = new types.InputMediaPhoto({
446
- id: new types.InputPhoto(fileId),
447
- spoiler,
448
- ttl_seconds,
449
- });
416
+ media = { _: "inputMediaPhoto", id: { ...fileId, _: "inputPhoto" }, spoiler, ttl_seconds };
450
417
  }
451
418
  }
452
419
  if (media == null) {
453
420
  if (typeof photo === "string" && isHttpUrl(photo)) {
454
- media = new types.InputMediaPhotoExternal({
455
- url: photo,
456
- spoiler,
457
- ttl_seconds: (params && "selfDestruct" in params && params.selfDestruct !== undefined) ? selfDestructOptionToInt(params.selfDestruct) : undefined,
458
- });
421
+ media = { _: "inputMediaPhotoExternal", url: photo, spoiler, ttl_seconds: (params && "selfDestruct" in params && params.selfDestruct !== undefined) ? selfDestructOptionToInt(params.selfDestruct) : undefined };
459
422
  }
460
423
  else {
461
424
  const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(photo, params, null, false);
462
- media = new types.InputMediaUploadedPhoto({
463
- file,
464
- spoiler,
465
- ttl_seconds: (params && "selfDestruct" in params && params.selfDestruct !== undefined) ? selfDestructOptionToInt(params.selfDestruct) : undefined,
466
- });
425
+ media = { _: "inputMediaUploadedPhoto", file, spoiler, ttl_seconds: (params && "selfDestruct" in params && params.selfDestruct !== undefined) ? selfDestructOptionToInt(params.selfDestruct) : undefined };
467
426
  }
468
427
  }
469
428
  const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendMedia).call(this, chatId, media, params);
@@ -502,31 +461,17 @@ export class MessageManager {
502
461
  const randomId = getRandomId();
503
462
  const silent = params?.disableNotification ? true : undefined;
504
463
  const noforwards = params?.protectContent ? true : undefined;
505
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
464
+ const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
506
465
  const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
507
466
  const explanation = params?.explanation;
508
467
  const parseResult = explanation !== undefined ? await this.parseText(explanation, { parseMode: params?.explanationParseMode, entities: params?.explanationEntities }) : undefined;
509
468
  const solution = parseResult === undefined ? undefined : parseResult[0];
510
469
  const solutionEntities = parseResult === undefined ? undefined : parseResult[1];
511
- const answers = options.map((v, i) => new types.PollAnswer({ option: new Uint8Array([i]), text: v }));
512
- const poll = new types.Poll({
513
- id: getRandomId(),
514
- answers,
515
- question,
516
- closed: params?.isClosed ? true : undefined,
517
- close_date: params?.closeDate ? toUnixTimestamp(params.closeDate) : undefined,
518
- close_period: params?.openPeriod ? params.openPeriod : undefined,
519
- multiple_choice: params?.allowMultipleAnswers ? true : undefined,
520
- public_voters: params?.isAnonymous === false ? true : undefined,
521
- quiz: params?.type == "quiz" ? true : undefined,
522
- });
523
- const media = new types.InputMediaPoll({
524
- poll,
525
- correct_answers: params?.correctOptionIndex ? [new Uint8Array([params.correctOptionIndex])] : undefined,
526
- solution,
527
- solution_entities: solutionEntities,
528
- });
529
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke(new functions.messages.sendMedia({
470
+ const answers = options.map((v, i) => ({ _: "pollAnswer", option: new Uint8Array([i]), text: v }));
471
+ const poll = { _: "poll", id: getRandomId(), answers, question, closed: params?.isClosed ? true : undefined, close_date: params?.closeDate ? toUnixTimestamp(params.closeDate) : undefined, close_period: params?.openPeriod ? params.openPeriod : undefined, multiple_choice: params?.allowMultipleAnswers ? true : undefined, public_voters: params?.isAnonymous === false ? true : undefined, quiz: params?.type == "quiz" ? true : undefined };
472
+ const media = { _: "inputMediaPoll", poll, correct_answers: params?.correctOptionIndex ? [new Uint8Array([params.correctOptionIndex])] : undefined, solution, solution_entities: solutionEntities };
473
+ const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
474
+ _: "messages.sendMedia",
530
475
  peer,
531
476
  random_id: randomId,
532
477
  silent,
@@ -536,25 +481,18 @@ export class MessageManager {
536
481
  send_as: sendAs,
537
482
  media,
538
483
  message: "",
539
- }), params?.businessConnectionId);
484
+ }, params?.businessConnectionId);
540
485
  const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId).then((v) => v[0]);
541
486
  return assertMessageType(message, "poll");
542
487
  }
543
488
  async editMessageReplyMarkup(chatId, messageId, params) {
544
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.editMessage({
545
- id: checkMessageId(messageId),
546
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
547
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
548
- });
489
+ const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editMessage", id: checkMessageId(messageId), peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params) });
549
490
  const message_ = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
550
491
  return message_;
551
492
  }
552
493
  async editInlineMessageReplyMarkup(inlineMessageId, params) {
553
494
  const id = deserializeInlineMessageId(inlineMessageId);
554
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.editInlineBotMessage({
555
- id,
556
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
557
- });
495
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editInlineBotMessage", id, reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params) });
558
496
  }
559
497
  async editMessageText(chatId, messageId, text, params) {
560
498
  const [message, entities] = await this.parseText(text, params);
@@ -562,23 +500,9 @@ export class MessageManager {
562
500
  const invertMedia = params?.linkPreview?.aboveText ? true : undefined;
563
501
  let media = undefined;
564
502
  if (!noWebpage && params?.linkPreview?.url) {
565
- media = new types.InputMediaWebPage({
566
- url: params.linkPreview.url,
567
- force_large_media: params.linkPreview.largeMedia ? true : undefined,
568
- force_small_media: params.linkPreview.smallMedia ? true : undefined,
569
- optional: message.length ? undefined : true,
570
- });
503
+ media = { _: "inputMediaWebPage", url: params.linkPreview.url, force_large_media: params.linkPreview.largeMedia ? true : undefined, force_small_media: params.linkPreview.smallMedia ? true : undefined, optional: message.length ? undefined : true };
571
504
  }
572
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.editMessage({
573
- id: checkMessageId(messageId),
574
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
575
- entities,
576
- message,
577
- media,
578
- no_webpage: noWebpage,
579
- invert_media: invertMedia,
580
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
581
- });
505
+ const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editMessage", id: checkMessageId(messageId), peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), entities, message, media, no_webpage: noWebpage, invert_media: invertMedia, reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params) });
582
506
  const message_ = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
583
507
  return assertMessageType(message_, "text");
584
508
  }
@@ -589,22 +513,9 @@ export class MessageManager {
589
513
  const invertMedia = params?.linkPreview?.aboveText ? true : undefined;
590
514
  let media = undefined;
591
515
  if (!noWebpage && params?.linkPreview?.url) {
592
- media = new types.InputMediaWebPage({
593
- url: params.linkPreview.url,
594
- force_large_media: params.linkPreview.largeMedia ? true : undefined,
595
- force_small_media: params.linkPreview.smallMedia ? true : undefined,
596
- optional: message.length ? undefined : true,
597
- });
516
+ media = { _: "inputMediaWebPage", url: params.linkPreview.url, force_large_media: params.linkPreview.largeMedia ? true : undefined, force_small_media: params.linkPreview.smallMedia ? true : undefined, optional: message.length ? undefined : true };
598
517
  }
599
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.editInlineBotMessage({
600
- id,
601
- entities,
602
- message,
603
- media,
604
- no_webpage: noWebpage,
605
- invert_media: invertMedia,
606
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
607
- });
518
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editInlineBotMessage", id, entities, message, media, no_webpage: noWebpage, invert_media: invertMedia, reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params) });
608
519
  }
609
520
  async editMessageMedia(chatId, messageId, media, params) {
610
521
  const message = await this.getMessage(chatId, messageId);
@@ -614,63 +525,41 @@ export class MessageManager {
614
525
  if (!("animation" in message) && !("audio" in message) && !("document" in message) && !("photo" in message) && !("video" in message)) {
615
526
  throw new InputError("Unexpected message type.");
616
527
  }
617
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.editMessage({
618
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
619
- id: messageId,
620
- media: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMedia).call(this, media),
621
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
622
- });
528
+ const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editMessage", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), id: messageId, media: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMedia).call(this, media), reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params) });
623
529
  const message_ = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
624
530
  return message_;
625
531
  }
626
532
  async editInlineMessageMedia(inlineMessageId, media, params) {
627
533
  await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("editInlineMessageMedia");
628
534
  const id = deserializeInlineMessageId(inlineMessageId);
629
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.editInlineBotMessage({
630
- id,
631
- media: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMedia).call(this, media),
632
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
633
- });
535
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editInlineBotMessage", id, media: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMedia).call(this, media), reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params) });
634
536
  }
635
537
  async deleteMessages(chatId, messageIds, params) {
636
538
  checkArray(messageIds, checkMessageId);
637
539
  const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
638
- if (peer instanceof types.InputPeerChannel) {
639
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.deleteMessages({ channel: new types.InputChannel(peer), id: messageIds });
540
+ if (is("inputPeerChannel", peer)) {
541
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.deleteMessages", channel: { ...peer, _: "inputChannel" }, id: messageIds });
640
542
  }
641
543
  else {
642
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.deleteMessages({ id: messageIds, revoke: params?.onlyForMe ? undefined : true });
544
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.deleteMessages", id: messageIds, revoke: params?.onlyForMe ? undefined : true });
643
545
  }
644
546
  }
645
547
  async deleteChatMemberMessages(chatId, memberId) {
646
548
  const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
647
549
  const participant = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(memberId);
648
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.deleteParticipantHistory({ channel, participant });
550
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.deleteParticipantHistory", channel, participant });
649
551
  }
650
552
  async pinMessage(chatId, messageId, params) {
651
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.updatePinnedMessage({
652
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
653
- id: checkMessageId(messageId),
654
- silent: params?.disableNotification ? true : undefined,
655
- pm_oneside: params?.bothSides ? undefined : true,
656
- });
553
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.updatePinnedMessage", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), id: checkMessageId(messageId), silent: params?.disableNotification ? true : undefined, pm_oneside: params?.bothSides ? undefined : true });
657
554
  }
658
555
  async unpinMessage(chatId, messageId) {
659
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.updatePinnedMessage({
660
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
661
- id: checkMessageId(messageId),
662
- unpin: true,
663
- });
556
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.updatePinnedMessage", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), id: checkMessageId(messageId), unpin: true });
664
557
  }
665
558
  async unpinMessages(chatId) {
666
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.unpinAllMessages({ peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId) });
559
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.unpinAllMessages", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId) });
667
560
  }
668
561
  async setAvailableReactions(chatId, availableReactions) {
669
- // TODO: sync with storage
670
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.setChatAvailableReactions({
671
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
672
- available_reactions: availableReactions == "none" ? new types.ChatReactionsNone() : availableReactions == "all" ? new types.ChatReactionsAll() : Array.isArray(availableReactions) ? new types.ChatReactionsSome({ reactions: availableReactions.map((v) => v.type == "emoji" ? new types.ReactionEmoji({ emoticon: v.emoji }) : new types.ReactionCustomEmoji({ document_id: BigInt(v.id) })) }) : unreachable(),
673
- });
562
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.setChatAvailableReactions", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), available_reactions: availableReactions == "none" ? { _: "chatReactionsNone" } : availableReactions == "all" ? { _: "chatReactionsAll" } : Array.isArray(availableReactions) ? ({ _: "chatReactionsSome", reactions: availableReactions.map((v) => v.type == "emoji" ? ({ _: "reactionEmoji", emoticon: v.emoji }) : ({ _: "reactionCustomEmoji", document_id: BigInt(v.id) })) }) : unreachable() });
674
563
  }
675
564
  async setReactions(chatId, messageId, reactions, params) {
676
565
  await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendReaction).call(this, chatId, messageId, reactions, params);
@@ -704,32 +593,32 @@ export class MessageManager {
704
593
  }
705
594
  }
706
595
  static canHandleUpdate(update) {
707
- return update instanceof types.UpdateNewMessage ||
708
- update instanceof types.UpdateNewChannelMessage ||
709
- update instanceof types.UpdateEditMessage ||
710
- update instanceof types.UpdateEditChannelMessage ||
711
- update instanceof types.UpdateBotNewBusinessMessage ||
712
- update instanceof types.UpdateBotEditBusinessMessage ||
713
- update instanceof types.UpdateBotDeleteBusinessMessage ||
714
- update instanceof types.UpdateDeleteMessages ||
715
- update instanceof types.UpdateDeleteChannelMessages ||
716
- update instanceof types.UpdateChannelParticipant ||
717
- update instanceof types.UpdateChatParticipant;
596
+ return is("updateNewMessage", update) ||
597
+ is("updateNewChannelMessage", update) ||
598
+ is("updateEditMessage", update) ||
599
+ is("updateEditChannelMessage", update) ||
600
+ is("updateBotNewBusinessMessage", update) ||
601
+ is("updateBotEditBusinessMessage", update) ||
602
+ is("updateBotDeleteBusinessMessage", update) ||
603
+ is("updateDeleteMessages", update) ||
604
+ is("updateDeleteChannelMessages", update) ||
605
+ is("updateChannelParticipant", update) ||
606
+ is("updateChatParticipant", update);
718
607
  }
719
608
  async handleUpdate(update) {
720
- if (update instanceof types.UpdateNewMessage || update instanceof types.UpdateNewChannelMessage || update instanceof types.UpdateEditMessage || update instanceof types.UpdateEditChannelMessage) {
721
- if (update.message instanceof types.Message || update.message instanceof types.MessageService) {
609
+ if (is("updateNewMessage", update) || is("updateNewChannelMessage", update) || is("updateEditMessage", update) || is("updateEditChannelMessage", update)) {
610
+ if (is("message", update.message) || is("messageService", update.message)) {
722
611
  const chatId = peerToChatId(update.message.peer_id);
723
612
  await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.setMessage(chatId, update.message.id, update.message);
724
613
  }
725
614
  }
726
- if (update instanceof types.UpdateNewMessage ||
727
- update instanceof types.UpdateNewChannelMessage ||
728
- update instanceof types.UpdateEditMessage ||
729
- update instanceof types.UpdateEditChannelMessage ||
730
- update instanceof types.UpdateBotNewBusinessMessage ||
731
- update instanceof types.UpdateBotEditBusinessMessage) {
732
- if (!(update.message instanceof types.MessageEmpty)) {
615
+ if (is("updateNewMessage", update) ||
616
+ is("updateNewChannelMessage", update) ||
617
+ is("updateEditMessage", update) ||
618
+ is("updateEditChannelMessage", update) ||
619
+ is("updateBotNewBusinessMessage", update) ||
620
+ is("updateBotEditBusinessMessage", update)) {
621
+ if (!(is("messageEmpty", update.message))) {
733
622
  const isOutgoing = update.message.out;
734
623
  let shouldIgnore = isOutgoing ? (await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.getAccountType()) == "user" ? false : true : false;
735
624
  if (__classPrivateFieldGet(this, _MessageManager_c, "f").ignoreOutgoing != null && isOutgoing) {
@@ -738,16 +627,16 @@ export class MessageManager {
738
627
  if (!shouldIgnore) {
739
628
  const business = "connection_id" in update ? { connectionId: update.connection_id, replyToMessage: update.reply_to_message } : undefined;
740
629
  const message = await this.constructMessage(update.message, undefined, business);
741
- if (update instanceof types.UpdateNewMessage || update instanceof types.UpdateNewChannelMessage || update instanceof types.UpdateBotNewBusinessMessage) {
742
- return ({ message });
630
+ if (is("updateNewMessage", update) || is("updateNewChannelMessage", update) || is("updateBotNewBusinessMessage", update)) {
631
+ return { message };
743
632
  }
744
633
  else {
745
- return ({ editedMessage: message });
634
+ return { editedMessage: message };
746
635
  }
747
636
  }
748
637
  }
749
638
  }
750
- if (update instanceof types.UpdateDeleteMessages) {
639
+ if (is("updateDeleteMessages", update)) {
751
640
  const deletedMessages = new Array();
752
641
  for (const messageId of update.messages) {
753
642
  const chatId = await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.getMessageChat(messageId);
@@ -759,7 +648,7 @@ export class MessageManager {
759
648
  return { deletedMessages };
760
649
  }
761
650
  }
762
- else if (update instanceof types.UpdateDeleteChannelMessages) {
651
+ else if (is("updateDeleteChannelMessages", update)) {
763
652
  const chatId = getChannelChatId(update.channel_id);
764
653
  const deletedMessages = new Array();
765
654
  for (const messageId of update.messages) {
@@ -770,12 +659,12 @@ export class MessageManager {
770
659
  }
771
660
  return { deletedMessages };
772
661
  }
773
- else if (update instanceof types.UpdateBotDeleteBusinessMessage) {
662
+ else if (is("updateBotDeleteBusinessMessage", update)) {
774
663
  const chatId = peerToChatId(update.peer);
775
664
  const deletedMessages = update.messages.map((v) => ({ chatId, messageId: v }));
776
665
  return { deletedMessages, businessConnectionId: update.connection_id };
777
666
  }
778
- if (update instanceof types.UpdateChannelParticipant || update instanceof types.UpdateChatParticipant) {
667
+ if (is("updateChannelParticipant", update) || is("updateChatParticipant", update)) {
779
668
  const chatMember = await constructChatMemberUpdated(update, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity);
780
669
  const selfId = await __classPrivateFieldGet(this, _MessageManager_c, "f").getSelfId();
781
670
  if (chatMember.oldChatMember.user.id == selfId) {
@@ -791,76 +680,76 @@ export class MessageManager {
791
680
  let action_;
792
681
  switch (action) {
793
682
  case "type":
794
- action_ = new types.SendMessageTypingAction();
683
+ action_ = { _: "sendMessageTypingAction" };
795
684
  break;
796
685
  case "uploadPhoto":
797
- action_ = new types.SendMessageUploadPhotoAction({ progress: 0 });
686
+ action_ = { _: "sendMessageUploadPhotoAction", progress: 0 };
798
687
  break;
799
688
  case "recordVideo":
800
- action_ = new types.SendMessageRecordVideoAction();
689
+ action_ = { _: "sendMessageRecordVideoAction" };
801
690
  break;
802
691
  case "uploadVideo":
803
- action_ = new types.SendMessageRecordVideoAction();
692
+ action_ = { _: "sendMessageRecordVideoAction" };
804
693
  break;
805
694
  case "recordVoice":
806
- action_ = new types.SendMessageRecordAudioAction();
695
+ action_ = { _: "sendMessageRecordAudioAction" };
807
696
  break;
808
697
  case "uploadAudio":
809
- action_ = new types.SendMessageUploadAudioAction({ progress: 0 });
698
+ action_ = { _: "sendMessageUploadAudioAction", progress: 0 };
810
699
  break;
811
700
  case "uploadDocument":
812
- action_ = new types.SendMessageUploadDocumentAction({ progress: 0 });
701
+ action_ = { _: "sendMessageUploadDocumentAction", progress: 0 };
813
702
  break;
814
703
  case "chooseSticker":
815
- action_ = new types.SendMessageChooseStickerAction();
704
+ action_ = { _: "sendMessageChooseStickerAction" };
816
705
  break;
817
706
  case "findLocation":
818
- action_ = new types.SendMessageGeoLocationAction();
707
+ action_ = { _: "sendMessageGeoLocationAction" };
819
708
  break;
820
709
  case "recordVideoNote":
821
- action_ = new types.SendMessageRecordRoundAction();
710
+ action_ = { _: "sendMessageRecordRoundAction" };
822
711
  break;
823
712
  case "uploadVideoNote":
824
- action_ = new types.SendMessageUploadRoundAction({ progress: 0 });
713
+ action_ = { _: "sendMessageUploadRoundAction", progress: 0 };
825
714
  break;
826
715
  default:
827
716
  throw new InputError(`Invalid chat action: ${action}`);
828
717
  }
829
- await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke(new functions.messages.setTyping({ peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), action: action_, top_msg_id: params?.messageThreadId }), params?.businessConnectionId);
718
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.setTyping", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), action: action_, top_msg_id: params?.messageThreadId }, params?.businessConnectionId);
830
719
  }
831
720
  async deleteChatPhoto(chatId) {
832
721
  const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
833
- if (!(peer instanceof types.InputPeerChannel) && !(peer instanceof types.InputPeerChat)) {
722
+ if (!(is("inputPeerChannel", peer)) && !(is("inputPeerChat", peer))) {
834
723
  unreachable();
835
724
  }
836
- if (peer instanceof types.InputPeerChannel) {
837
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.editPhoto({ channel: new types.InputChannel(peer), photo: new types.InputChatPhotoEmpty() });
725
+ if (is("inputPeerChannel", peer)) {
726
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.editPhoto", channel: { ...peer, _: "inputChannel" }, photo: { _: "inputChatPhotoEmpty" } });
838
727
  }
839
- else if (peer instanceof types.InputPeerChat) {
840
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.editChatPhoto({ chat_id: peer.chat_id, photo: new types.InputChatPhotoEmpty() });
728
+ else if (is("inputPeerChat", peer)) {
729
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editChatPhoto", chat_id: peer.chat_id, photo: { _: "inputChatPhotoEmpty" } });
841
730
  }
842
731
  }
843
732
  async setChatPhoto(chatId, photo, params) {
844
733
  const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
845
- if (!(peer instanceof types.InputPeerChannel) && !(peer instanceof types.InputPeerChat)) {
734
+ if (!(is("inputPeerChannel", peer)) && !(is("inputPeerChat", peer))) {
846
735
  unreachable();
847
736
  }
848
737
  const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(photo, params);
849
- const photo_ = new types.InputChatUploadedPhoto({ file });
850
- if (peer instanceof types.InputPeerChannel) {
851
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.editPhoto({ channel: new types.InputChannel(peer), photo: photo_ });
738
+ const photo_ = { _: "inputChatUploadedPhoto", file };
739
+ if (is("inputPeerChannel", peer)) {
740
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.editPhoto", channel: { ...peer, _: "inputChannel" }, photo: photo_ });
852
741
  }
853
- else if (peer instanceof types.InputPeerChat) {
854
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.editChatPhoto({ chat_id: peer.chat_id, photo: photo_ });
742
+ else if (is("inputPeerChat", peer)) {
743
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editChatPhoto", chat_id: peer.chat_id, photo: photo_ });
855
744
  }
856
745
  }
857
746
  async banChatMember(chatId, memberId, params) {
858
747
  const chat = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
859
- if (!(chat instanceof types.InputPeerChannel) && !(chat instanceof types.InputPeerChat)) {
748
+ if (!(is("inputPeerChannel", chat)) && !(is("inputPeerChat", chat))) {
860
749
  throw new InputError("Expected a channel, supergroup, or group ID.");
861
750
  }
862
751
  const member = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(memberId);
863
- if (chat instanceof types.InputPeerChannel) {
752
+ if (is("inputPeerChannel", chat)) {
864
753
  if (params?.deleteMessages) {
865
754
  try {
866
755
  await this.deleteChatMemberMessages(chatId, memberId);
@@ -869,11 +758,13 @@ export class MessageManager {
869
758
  //
870
759
  }
871
760
  }
872
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.editBanned({
873
- channel: new types.InputChannel(chat),
761
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
762
+ _: "channels.editBanned",
763
+ channel: { ...chat, _: "inputChannel" },
874
764
  participant: member,
875
- banned_rights: new types.ChatBannedRights({
876
- until_date: params?.untilDate ? toUnixTimestamp(params.untilDate) : 0, // todo
765
+ banned_rights: ({
766
+ _: "chatBannedRights",
767
+ until_date: params?.untilDate ? toUnixTimestamp(params.untilDate) : 0,
877
768
  view_messages: true,
878
769
  send_messages: true,
879
770
  send_media: true,
@@ -885,69 +776,22 @@ export class MessageManager {
885
776
  }),
886
777
  });
887
778
  }
888
- else if (chat instanceof types.InputPeerChat) {
889
- if (!(member instanceof types.InputPeerUser)) {
779
+ else if (is("inputPeerChat", chat)) {
780
+ if (!(is("inputPeerUser", member))) {
890
781
  throw new InputError(`Invalid user ID: ${memberId}`);
891
782
  }
892
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.deleteChatUser({
893
- chat_id: chat.chat_id,
894
- user_id: new types.InputUser(member),
895
- revoke_history: params?.deleteMessages ? true : undefined,
896
- });
783
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.deleteChatUser", chat_id: chat.chat_id, user_id: { ...member, _: "inputUser" }, revoke_history: params?.deleteMessages ? true : undefined });
897
784
  }
898
785
  }
899
786
  async unbanChatMember(chatId, memberId) {
900
787
  const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
901
788
  const member = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(memberId);
902
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.editBanned({
903
- channel,
904
- participant: member,
905
- banned_rights: new types.ChatBannedRights({ until_date: 0 }),
906
- });
789
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.editBanned", channel, participant: member, banned_rights: ({ _: "chatBannedRights", until_date: 0 }) });
907
790
  }
908
791
  async setChatMemberRights(chatId, memberId, params) {
909
792
  const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
910
793
  const member = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(memberId);
911
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.editBanned({
912
- channel,
913
- participant: member,
914
- banned_rights: chatMemberRightsToTlObject(params?.rights, params?.untilDate),
915
- });
916
- }
917
- async getChatAdministrators(chatId) {
918
- const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
919
- if (peer instanceof types.InputPeerChannel) {
920
- const channel = new types.InputChannel(peer);
921
- const participants = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.getParticipants({
922
- channel,
923
- filter: new types.ChannelParticipantsAdmins(),
924
- offset: 0,
925
- limit: 100,
926
- hash: 0n,
927
- });
928
- if (participants instanceof types.channels.ChannelParticipantsNotModified) {
929
- unreachable();
930
- }
931
- const chatMembers = new Array();
932
- for (const p of participants.participants) {
933
- chatMembers.push(await constructChatMember(p, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity));
934
- }
935
- return chatMembers;
936
- }
937
- else if (peer instanceof types.InputPeerChat) {
938
- const fullChat = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.getFullChat(peer); // TODO: full chat cache
939
- if (!(fullChat.full_chat instanceof types.ChatFull) || !(fullChat.full_chat.participants instanceof types.ChatParticipants)) {
940
- unreachable();
941
- }
942
- const chatMembers = new Array();
943
- for (const p of fullChat.full_chat.participants.participants) {
944
- chatMembers.push(await constructChatMember(p, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity));
945
- }
946
- return chatMembers;
947
- }
948
- else {
949
- unreachable();
950
- }
794
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.editBanned", channel, participant: member, banned_rights: chatMemberRightsToTlObject(params?.rights, params?.untilDate) });
951
795
  }
952
796
  async enableJoinRequests(chatId) {
953
797
  await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("enableJoinRequests");
@@ -958,20 +802,7 @@ export class MessageManager {
958
802
  await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_toggleJoinRequests).call(this, chatId, false);
959
803
  }
960
804
  async searchMessages(chatId, query, params) {
961
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.search({
962
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
963
- q: query,
964
- add_offset: 0,
965
- filter: messageSearchFilterToTlObject(params?.filter ?? "empty"),
966
- hash: 0n,
967
- limit: params?.limit ?? 100,
968
- max_date: 0,
969
- max_id: 0,
970
- min_date: 0,
971
- min_id: 0,
972
- offset_id: params?.after ? params.after : 0,
973
- from_id: params?.from ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.from) : undefined,
974
- });
805
+ const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.search", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), q: query, add_offset: 0, filter: messageSearchFilterToTlObject(params?.filter ?? "empty"), hash: 0n, limit: params?.limit ?? 100, max_date: 0, max_id: 0, min_date: 0, min_id: 0, offset_id: params?.after ? params.after : 0, from_id: params?.from ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.from) : undefined });
975
806
  if (!("messages" in result)) {
976
807
  unreachable();
977
808
  }
@@ -984,44 +815,31 @@ export class MessageManager {
984
815
  }
985
816
  async setBoostsRequiredToCircumventRestrictions(chatId, boosts) {
986
817
  const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
987
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.setBoostsToUnblockRestrictions({ channel, boosts });
818
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.setBoostsToUnblockRestrictions", channel, boosts });
988
819
  }
989
820
  async createInviteLink(chatId, params) {
990
821
  if (params?.requireApproval && params?.limit) {
991
822
  throw new InputError("requireApproval cannot be true while limit is specified.");
992
823
  }
993
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.exportChatInvite({
994
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
995
- title: params?.title,
996
- expire_date: params?.expireAt ? toUnixTimestamp(params.expireAt) : undefined,
997
- request_needed: params?.requireApproval ? true : undefined,
998
- usage_limit: params?.limit,
999
- });
1000
- return await constructInviteLink(result[as](types.ChatInviteExported), __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity);
824
+ const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.exportChatInvite", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), title: params?.title, expire_date: params?.expireAt ? toUnixTimestamp(params.expireAt) : undefined, request_needed: params?.requireApproval ? true : undefined, usage_limit: params?.limit });
825
+ return await constructInviteLink(as("chatInviteExported", result), __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity);
1001
826
  }
1002
827
  async getCreatedInviteLinks(chatId, params) {
1003
828
  await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("getCreatedInviteLinks");
1004
- const { invites } = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.getExportedChatInvites({
1005
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
1006
- revoked: params?.revoked ? true : undefined,
1007
- admin_id: params?.by ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputUser(params.by) : new types.InputUserEmpty(),
1008
- limit: params?.limit ?? 100,
1009
- offset_date: params?.afterDate ? toUnixTimestamp(params.afterDate) : undefined,
1010
- offset_link: params?.afterInviteLink,
1011
- });
1012
- return await Promise.all(invites.map((v) => v[as](types.ChatInviteExported)).map((v) => constructInviteLink(v, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity)));
829
+ const { invites } = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.getExportedChatInvites", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), revoked: params?.revoked ? true : undefined, admin_id: params?.by ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputUser(params.by) : { _: "inputUserEmpty" }, limit: params?.limit ?? 100, offset_date: params?.afterDate ? toUnixTimestamp(params.afterDate) : undefined, offset_link: params?.afterInviteLink });
830
+ return await Promise.all(invites.map((v) => as("chatInviteExported", v)).map((v) => constructInviteLink(v, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity)));
1013
831
  }
1014
832
  async joinChat(chatId) {
1015
833
  await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("joinChat");
1016
834
  const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
1017
- if (peer instanceof types.InputPeerUser) {
835
+ if (is("inputPeerUser", peer)) {
1018
836
  throw new InputError("Cannot join private chats.");
1019
837
  }
1020
- else if (peer instanceof types.InputPeerChannel) {
1021
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.joinChannel({ channel: new types.InputChannel(peer) });
838
+ else if (is("inputPeerChannel", peer)) {
839
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.joinChannel", channel: { ...peer, _: "inputChannel" } });
1022
840
  }
1023
- else if (peer instanceof types.InputPeerChat) {
1024
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.addChatUser({ chat_id: peer.chat_id, user_id: new types.InputUserSelf(), fwd_limit: 0 }); // TODO: use potential high-level method for adding participants to chats
841
+ else if (is("inputPeerChat", peer)) {
842
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.addChatUser", chat_id: peer.chat_id, user_id: { _: "inputUserSelf" }, fwd_limit: 0 }); // TODO: use potential high-level method for adding participants to chats
1025
843
  }
1026
844
  else {
1027
845
  unreachable();
@@ -1029,14 +847,14 @@ export class MessageManager {
1029
847
  }
1030
848
  async leaveChat(chatId) {
1031
849
  const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
1032
- if (peer instanceof types.InputPeerUser) {
850
+ if (is("inputPeerUser", peer)) {
1033
851
  throw new InputError("Cannot leave private chats.");
1034
852
  }
1035
- else if (peer instanceof types.InputPeerChannel) {
1036
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.leaveChannel({ channel: new types.InputChannel(peer) });
853
+ else if (is("inputPeerChannel", peer)) {
854
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.leaveChannel", channel: { ...peer, _: "inputChannel" } });
1037
855
  }
1038
- else if (peer instanceof types.InputPeerChat) {
1039
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.deleteChatUser({ chat_id: peer.chat_id, user_id: new types.InputUserSelf() }); // TODO: use potential high-level method for adding participants to chats
856
+ else if (is("inputPeerChat", peer)) {
857
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.deleteChatUser", chat_id: peer.chat_id, user_id: { _: "inputUserSelf" } }); // TODO: use potential high-level method for adding participants to chats
1040
858
  }
1041
859
  else {
1042
860
  unreachable();
@@ -1045,32 +863,29 @@ export class MessageManager {
1045
863
  async blockUser(userId) {
1046
864
  await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("blockUser");
1047
865
  const id = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(userId);
1048
- if (!(id instanceof types.User)) {
866
+ if (!(is("user", id))) {
1049
867
  throw new InputError("Only users can be blocked or unblocked.");
1050
868
  }
1051
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.contacts.block({ id });
869
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "contacts.block", id });
1052
870
  }
1053
871
  async unblockUser(userId) {
1054
872
  await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("unblockUser");
1055
873
  const id = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(userId);
1056
- if (!(id instanceof types.User)) {
874
+ if (!(is("user", id))) {
1057
875
  throw new InputError("Only users can be blocked or unblocked.");
1058
876
  }
1059
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.contacts.unblock({ id });
877
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "contacts.unblock", id });
1060
878
  }
1061
879
  async getChatMember(chatId, userId) {
1062
880
  const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
1063
- if (peer instanceof types.InputPeerChannel) {
1064
- const { participant } = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.getParticipant({
1065
- channel: new types.InputChannel(peer),
1066
- participant: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(userId),
1067
- });
881
+ if (is("inputPeerChannel", peer)) {
882
+ const { participant } = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.getParticipant", channel: { ...peer, _: "inputChannel" }, participant: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(userId) });
1068
883
  return await constructChatMember(participant, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity);
1069
884
  }
1070
- else if (peer instanceof types.InputPeerChat) {
885
+ else if (is("inputPeerChat", peer)) {
1071
886
  const user = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputUser(userId);
1072
- const fullChat = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.getFullChat(peer).then((v) => v.full_chat[as](types.ChatFull));
1073
- const participant = fullChat.participants[as](types.ChatParticipants).participants.find((v) => v.user_id == user.user_id);
887
+ const fullChat = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ ...peer, _: "messages.getFullChat" }).then((v) => as("chatFull", v.full_chat));
888
+ const participant = as("chatParticipants", fullChat.participants).participants.find((v) => v.user_id == user.user_id);
1074
889
  return await constructChatMember(participant, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity);
1075
890
  }
1076
891
  else {
@@ -1079,11 +894,11 @@ export class MessageManager {
1079
894
  }
1080
895
  async setChatStickerSet(chatId, setName) {
1081
896
  const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
1082
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.setStickers({ channel, stickerset: new types.InputStickerSetShortName({ short_name: setName }) });
897
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetShortName", short_name: setName } });
1083
898
  }
1084
899
  async deleteChatStickerSet(chatId) {
1085
900
  const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
1086
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.setStickers({ channel, stickerset: new types.InputStickerSetEmpty() });
901
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetEmpty" } });
1087
902
  }
1088
903
  async stopPoll(chatId, messageId, params) {
1089
904
  const message = await this.getMessage(chatId, messageId);
@@ -1096,39 +911,14 @@ export class MessageManager {
1096
911
  if (message.poll.isClosed) {
1097
912
  throw new InputError("Poll is already stopped.");
1098
913
  }
1099
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.editMessage({
1100
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
1101
- id: messageId,
1102
- media: new types.InputMediaPoll({
1103
- poll: new types.Poll({
1104
- id: BigInt(message.poll.id),
1105
- closed: true,
1106
- question: "",
1107
- answers: [],
1108
- }),
1109
- }),
1110
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
1111
- });
914
+ const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editMessage", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), id: messageId, media: ({ _: "inputMediaPoll", poll: ({ _: "poll", id: BigInt(message.poll.id), closed: true, question: "", answers: [] }) }), reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params) });
1112
915
  const message_ = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
1113
916
  return assertMessageType(message_, "poll").poll;
1114
917
  }
1115
918
  async editMessageLiveLocation(chatId, messageId, latitude, longitude, params) {
1116
919
  const message = await this.getMessage(chatId, messageId);
1117
920
  if (message && "location" in message && message.location.livePeriod) {
1118
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.editMessage({
1119
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
1120
- id: messageId,
1121
- media: new types.InputMediaGeoLive({
1122
- geo_point: new types.InputGeoPoint({
1123
- lat: latitude,
1124
- long: longitude,
1125
- accuracy_radius: params?.horizontalAccuracy,
1126
- }),
1127
- heading: params?.heading,
1128
- proximity_notification_radius: params?.proximityAlertRadius,
1129
- }),
1130
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
1131
- });
921
+ const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editMessage", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), id: messageId, media: ({ _: "inputMediaGeoLive", geo_point: ({ _: "inputGeoPoint", lat: latitude, long: longitude, accuracy_radius: params?.horizontalAccuracy }), heading: params?.heading, proximity_notification_radius: params?.proximityAlertRadius }), reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params) });
1132
922
  const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
1133
923
  return assertMessageType(message, "location");
1134
924
  }
@@ -1137,43 +927,31 @@ export class MessageManager {
1137
927
  async editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params) {
1138
928
  await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("editInlineMessageLiveLocation");
1139
929
  const id = deserializeInlineMessageId(inlineMessageId);
1140
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.editInlineBotMessage({
1141
- id,
1142
- media: new types.InputMediaGeoLive({
1143
- geo_point: new types.InputGeoPoint({
1144
- lat: latitude,
1145
- long: longitude,
1146
- accuracy_radius: params?.horizontalAccuracy,
1147
- }),
1148
- heading: params?.heading,
1149
- proximity_notification_radius: params?.proximityAlertRadius,
1150
- }),
1151
- reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
1152
- });
930
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editInlineBotMessage", id, media: ({ _: "inputMediaGeoLive", geo_point: ({ _: "inputGeoPoint", lat: latitude, long: longitude, accuracy_radius: params?.horizontalAccuracy }), heading: params?.heading, proximity_notification_radius: params?.proximityAlertRadius }), reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params) });
1153
931
  }
1154
932
  }
1155
933
  _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(), _MessageManager_instances = new WeakSet(), _MessageManager_updatesToMessages = async function _MessageManager_updatesToMessages(chatId, updates, businessConnectionId) {
1156
934
  const messages = new Array();
1157
- if (updates instanceof types.Updates) {
935
+ if (is("updates", updates)) {
1158
936
  for (const update of updates.updates) {
1159
- if ("message" in update && update.message instanceof types.MessageEmpty) {
937
+ if ("message" in update && is("messageEmpty", update.message)) {
1160
938
  continue;
1161
939
  }
1162
- if (update instanceof types.UpdateNewMessage || update instanceof types.UpdateEditMessage) {
940
+ if (is("updateNewMessage", update) || is("updateEditMessage", update)) {
1163
941
  messages.push(await this.constructMessage(update.message));
1164
942
  }
1165
- else if (update instanceof types.UpdateNewChannelMessage || update instanceof types.UpdateEditChannelMessage) {
943
+ else if (is("updateNewChannelMessage", update) || is("updateEditChannelMessage", update)) {
1166
944
  messages.push(await this.constructMessage(update.message));
1167
945
  }
1168
- else if (update instanceof types.UpdateBotNewBusinessMessage) {
946
+ else if (is("updateBotNewBusinessMessage", update)) {
1169
947
  messages.push(await this.constructMessage(update.message, false, { connectionId: businessConnectionId ?? update.connection_id, replyToMessage: update.reply_to_message }));
1170
948
  }
1171
- else if (update instanceof types.UpdateBotEditBusinessMessage) {
949
+ else if (is("updateBotEditBusinessMessage", update)) {
1172
950
  messages.push(await this.constructMessage(update.message, false, { connectionId: businessConnectionId ?? update.connection_id, replyToMessage: update.reply_to_message }));
1173
951
  }
1174
952
  }
1175
953
  }
1176
- else if (updates instanceof types.UpdateShortSentMessage) {
954
+ else if (is("updateShortSentMessage", updates)) {
1177
955
  const message = await this.getMessage(chatId, updates.id);
1178
956
  if (message != null) {
1179
957
  messages.push(message);
@@ -1194,7 +972,7 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
1194
972
  }, _MessageManager_constructReplyTo = async function _MessageManager_constructReplyTo(params) {
1195
973
  const topMsgId = params?.messageThreadId;
1196
974
  const replyToMsgId = params?.replyToMessageId;
1197
- return replyToMsgId !== undefined ? new types.InputReplyToMessage({ reply_to_msg_id: replyToMsgId, top_msg_id: topMsgId, quote_text: params?.replyQuote?.text, quote_entities: await Promise.all(params?.replyQuote?.entities.map((v) => messageEntityToTlObject(v, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity)) ?? []), quote_offset: params?.replyQuote?.offset }) : undefined;
975
+ return replyToMsgId !== undefined ? ({ _: "inputReplyToMessage", reply_to_msg_id: replyToMsgId, top_msg_id: topMsgId, quote_text: params?.replyQuote?.text, quote_entities: await Promise.all(params?.replyQuote?.entities.map((v) => messageEntityToTlObject(v, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity)) ?? []), quote_offset: params?.replyQuote?.offset }) : undefined;
1198
976
  }, _MessageManager_sendDocumentInner = async function _MessageManager_sendDocumentInner(chatId, document, params, fileType, otherAttribs, urlSupported = true, expectedMimeTypes) {
1199
977
  let media = null;
1200
978
  const spoiler = params?.hasSpoiler ? true : undefined;
@@ -1202,12 +980,7 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
1202
980
  if (typeof document === "string") {
1203
981
  const fileId = this.resolveFileId(document, fileType);
1204
982
  if (fileId != null) {
1205
- media = new types.InputMediaDocument({
1206
- id: new types.InputDocument(fileId),
1207
- spoiler,
1208
- query: otherAttribs.find((v) => v instanceof types.DocumentAttributeSticker)?.alt || undefined,
1209
- ttl_seconds,
1210
- });
983
+ media = { _: "inputMediaDocument", id: { ...fileId, _: "inputDocument" }, spoiler, query: otherAttribs.find((v) => is("documentAttributeSticker", v))?.alt || undefined, ttl_seconds };
1211
984
  }
1212
985
  }
1213
986
  if (media == null) {
@@ -1215,7 +988,7 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
1215
988
  if (!urlSupported) {
1216
989
  throw new InputError("URL not supported.");
1217
990
  }
1218
- media = new types.InputMediaDocumentExternal({ url: document, spoiler, ttl_seconds });
991
+ media = { _: "inputMediaDocumentExternal", url: document, spoiler, ttl_seconds };
1219
992
  }
1220
993
  else {
1221
994
  let mimeType;
@@ -1233,15 +1006,7 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
1233
1006
  if (params?.thumbnail) {
1234
1007
  thumb = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(params.thumbnail, { chunkSize: params?.chunkSize, signal: params?.signal });
1235
1008
  }
1236
- media = new types.InputMediaUploadedDocument({
1237
- file,
1238
- thumb,
1239
- spoiler,
1240
- attributes: [new types.DocumentAttributeFilename({ file_name: file.name }), ...otherAttribs],
1241
- mime_type: mimeType,
1242
- force_file: fileType == FileType.Document ? true : undefined,
1243
- ttl_seconds,
1244
- });
1009
+ media = { _: "inputMediaUploadedDocument", file, thumb, spoiler, attributes: [{ _: "documentAttributeFilename", file_name: file.name }, ...otherAttribs], mime_type: mimeType, force_file: fileType == FileType.Document ? true : undefined, ttl_seconds };
1245
1010
  }
1246
1011
  }
1247
1012
  const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendMedia).call(this, chatId, media, params);
@@ -1251,13 +1016,14 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
1251
1016
  const randomId = getRandomId();
1252
1017
  const silent = params?.disableNotification ? true : undefined;
1253
1018
  const noforwards = params?.protectContent ? true : undefined;
1254
- const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
1019
+ const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
1255
1020
  const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
1256
1021
  const caption_ = params?.caption;
1257
1022
  const parseResult = caption_ !== undefined ? await this.parseText(caption_, { parseMode: params?.parseMode, entities: params?.captionEntities }) : undefined;
1258
1023
  const caption = parseResult === undefined ? undefined : parseResult[0];
1259
1024
  const captionEntities = parseResult === undefined ? undefined : parseResult[1];
1260
- const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke(new functions.messages.sendMedia({
1025
+ const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
1026
+ _: "messages.sendMedia",
1261
1027
  peer,
1262
1028
  random_id: randomId,
1263
1029
  silent,
@@ -1268,7 +1034,7 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
1268
1034
  media,
1269
1035
  message: caption ?? "",
1270
1036
  entities: captionEntities,
1271
- }), params?.businessConnectionId);
1037
+ }, params?.businessConnectionId);
1272
1038
  return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId).then((v) => v[0]);
1273
1039
  }, _MessageManager_resolveInputMediaInner = async function _MessageManager_resolveInputMediaInner(document, media, fileType, otherAttribs) {
1274
1040
  let media_ = null;
@@ -1276,16 +1042,12 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
1276
1042
  if (typeof document === "string") {
1277
1043
  const fileId = this.resolveFileId(document, fileType);
1278
1044
  if (fileId != null) {
1279
- media_ = new types.InputMediaDocument({
1280
- id: new types.InputDocument(fileId),
1281
- spoiler,
1282
- query: otherAttribs.find((v) => v instanceof types.DocumentAttributeSticker)?.alt || undefined,
1283
- });
1045
+ media_ = { _: "inputMediaDocument", id: { ...fileId, _: "inputDocument" }, spoiler, query: otherAttribs.find((v) => is("documentAttributeSticker", v))?.alt || undefined };
1284
1046
  }
1285
1047
  }
1286
1048
  if (media_ == null) {
1287
1049
  if (typeof document === "string" && isHttpUrl(document)) {
1288
- media_ = new types.InputMediaDocumentExternal({ url: document, spoiler });
1050
+ media_ = { _: "inputMediaDocumentExternal", url: document, spoiler };
1289
1051
  }
1290
1052
  else {
1291
1053
  let mimeType;
@@ -1300,36 +1062,20 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
1300
1062
  if ("thumbnail" in media && media.thumbnail) {
1301
1063
  thumb = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(media.thumbnail, { chunkSize: media?.chunkSize, signal: media?.signal });
1302
1064
  }
1303
- media_ = new types.InputMediaUploadedDocument({
1304
- file,
1305
- thumb,
1306
- spoiler,
1307
- attributes: [new types.DocumentAttributeFilename({ file_name: file.name }), ...otherAttribs],
1308
- mime_type: mimeType,
1309
- force_file: fileType == FileType.Document ? true : undefined,
1310
- });
1065
+ media_ = { _: "inputMediaUploadedDocument", file, thumb, spoiler, attributes: [{ _: "documentAttributeFilename", file_name: file.name }, ...otherAttribs], mime_type: mimeType, force_file: fileType == FileType.Document ? true : undefined };
1311
1066
  }
1312
1067
  }
1313
1068
  return media_;
1314
1069
  }, _MessageManager_resolveInputMedia = async function _MessageManager_resolveInputMedia(media) {
1315
1070
  if ("animation" in media) {
1316
1071
  return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMediaInner).call(this, media.animation, media, FileType.Animation, [
1317
- new types.DocumentAttributeAnimated(),
1318
- new types.DocumentAttributeVideo({
1319
- supports_streaming: true,
1320
- w: media?.width ?? 0,
1321
- h: media?.height ?? 0,
1322
- duration: media?.duration ?? 0,
1323
- }),
1072
+ { _: "documentAttributeAnimated" },
1073
+ { _: "documentAttributeVideo", supports_streaming: true, w: media?.width ?? 0, h: media?.height ?? 0, duration: media?.duration ?? 0 },
1324
1074
  ]);
1325
1075
  }
1326
1076
  else if ("audio" in media) {
1327
1077
  return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMediaInner).call(this, media.audio, media, FileType.Audio, [
1328
- new types.DocumentAttributeAudio({
1329
- duration: media?.duration ?? 0,
1330
- performer: media?.performer,
1331
- title: media?.title,
1332
- }),
1078
+ { _: "documentAttributeAudio", duration: media?.duration ?? 0, performer: media?.performer, title: media?.title },
1333
1079
  ]);
1334
1080
  }
1335
1081
  else if ("document" in media) {
@@ -1342,20 +1088,16 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
1342
1088
  if (typeof media.photo === "string") {
1343
1089
  const fileId = this.resolveFileId(media.photo, [FileType.Photo, FileType.ProfilePhoto]);
1344
1090
  if (fileId != null) {
1345
- media_ = new types.InputMediaPhoto({
1346
- id: new types.InputPhoto(fileId),
1347
- spoiler,
1348
- ttl_seconds,
1349
- });
1091
+ media_ = { _: "inputMediaPhoto", id: { ...fileId, _: "inputPhoto" }, spoiler, ttl_seconds };
1350
1092
  }
1351
1093
  }
1352
1094
  if (media_ == null) {
1353
1095
  if (typeof media.photo === "string" && isHttpUrl(media.photo)) {
1354
- media_ = new types.InputMediaPhotoExternal({ url: media.photo, spoiler });
1096
+ media_ = { _: "inputMediaPhotoExternal", url: media.photo, spoiler };
1355
1097
  }
1356
1098
  else {
1357
1099
  const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(media.photo, media, null, false);
1358
- media_ = new types.InputMediaUploadedPhoto({ file, spoiler, ttl_seconds });
1100
+ media_ = { _: "inputMediaUploadedPhoto", file, spoiler, ttl_seconds };
1359
1101
  }
1360
1102
  }
1361
1103
  return media_;
@@ -1363,12 +1105,7 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
1363
1105
  else if ("video" in media) {
1364
1106
  const ttl_seconds = "selfDestruct" in media && media.selfDestruct !== undefined ? selfDestructOptionToInt(media.selfDestruct) : undefined;
1365
1107
  const media_ = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMediaInner).call(this, media.video, media, FileType.Video, [
1366
- new types.DocumentAttributeVideo({
1367
- supports_streaming: media?.supportsStreaming ? true : undefined,
1368
- w: media?.width ?? 0,
1369
- h: media?.height ?? 0,
1370
- duration: media?.duration ?? 0,
1371
- }),
1108
+ { _: "documentAttributeVideo", supports_streaming: media?.supportsStreaming ? true : undefined, w: media?.width ?? 0, h: media?.height ?? 0, duration: media?.duration ?? 0 },
1372
1109
  ]);
1373
1110
  media_.ttl_seconds = ttl_seconds;
1374
1111
  return media_;
@@ -1377,14 +1114,8 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
1377
1114
  unreachable();
1378
1115
  }
1379
1116
  }, _MessageManager_sendReaction = async function _MessageManager_sendReaction(chatId, messageId, reactions, params) {
1380
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.sendReaction({
1381
- peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
1382
- msg_id: checkMessageId(messageId),
1383
- reaction: reactions.map((v) => reactionToTlObject(v)),
1384
- big: params?.big ? true : undefined,
1385
- add_to_recent: params?.addToRecents ? true : undefined,
1386
- });
1117
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.sendReaction", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), msg_id: checkMessageId(messageId), reaction: reactions.map((v) => reactionToTlObject(v)), big: params?.big ? true : undefined, add_to_recent: params?.addToRecents ? true : undefined });
1387
1118
  }, _MessageManager_toggleJoinRequests = async function _MessageManager_toggleJoinRequests(chatId, enabled) {
1388
1119
  const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
1389
- await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.toggleJoinRequest({ channel, enabled });
1120
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.toggleJoinRequest", channel, enabled });
1390
1121
  };