@mtkruto/node 0.67.1 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/0_errors.js +2 -6
- package/esm/3_errors.js +2 -12
- package/esm/3_transport.d.ts +3 -3
- package/esm/3_transport.js +3 -3
- package/esm/3_types.d.ts +8 -7
- package/esm/3_types.d.ts.map +1 -1
- package/esm/3_types.js +8 -7
- package/esm/4_errors.js +2 -12
- package/esm/_dnt.polyfills.d.ts +99 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/_dnt.polyfills.js +127 -1
- package/esm/_dnt.test_polyfills.d.ts.map +1 -0
- package/esm/client/0_filters_test.d.ts.map +1 -1
- package/esm/client/0_markdown_test.d.ts.map +1 -1
- package/esm/client/0_params.d.ts +2 -0
- package/esm/client/0_params.d.ts.map +1 -1
- package/esm/client/0_password.d.ts +5 -5
- package/esm/client/0_password.d.ts.map +1 -1
- package/esm/client/0_password_test.d.ts.map +1 -1
- package/esm/client/0_storage_operations.js +143 -155
- package/esm/client/0_storage_operations_test.d.ts.map +1 -1
- package/esm/client/0_utilities.d.ts +1 -1
- package/esm/client/0_utilities_test.d.ts.map +1 -1
- package/esm/client/1_client_plain.js +4 -22
- package/esm/client/1_composer.js +8 -21
- package/esm/client/2_account_manager.js +85 -97
- package/esm/client/2_bot_info_manager.js +26 -38
- package/esm/client/2_business_connection_manager.js +10 -23
- package/esm/client/2_client_encrypted.js +194 -211
- package/esm/client/2_file_manager.d.ts +4 -3
- package/esm/client/2_file_manager.d.ts.map +1 -1
- package/esm/client/2_file_manager.js +268 -224
- package/esm/client/2_file_manager_test.d.ts.map +1 -1
- package/esm/client/2_network_statistics_manager.js +8 -21
- package/esm/client/2_payment_manager.js +7 -20
- package/esm/client/2_reaction_manager.js +7 -20
- package/esm/client/2_translations_manager.js +97 -107
- package/esm/client/2_update_manager.js +764 -759
- package/esm/client/3_client_encrypted_pool.js +10 -26
- package/esm/client/3_client_encrypted_pool_test.d.ts.map +1 -1
- package/esm/client/3_message_manager.d.ts +1 -1
- package/esm/client/3_message_manager.js +441 -448
- package/esm/client/3_message_manager_test.d.ts.map +1 -1
- package/esm/client/3_video_chat_manager.d.ts +1 -1
- package/esm/client/3_video_chat_manager.js +57 -68
- package/esm/client/4_callback_query_manager.js +18 -30
- package/esm/client/4_chat_list_manager.js +322 -318
- package/esm/client/4_chat_manager.js +118 -131
- package/esm/client/4_forum_manager.js +67 -73
- package/esm/client/4_gift_manager.js +16 -29
- package/esm/client/4_inline_query_manager.js +16 -28
- package/esm/client/4_link_preview_manager.js +6 -19
- package/esm/client/4_poll_manager.js +44 -57
- package/esm/client/4_story_manager.js +41 -53
- package/esm/client/5_client.d.ts +7 -0
- package/esm/client/5_client.d.ts.map +1 -1
- package/esm/client/5_client.js +1271 -1290
- package/esm/connection/1_connection_tcp.node.js +48 -65
- package/esm/connection/1_connection_web_socket.js +75 -91
- package/esm/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
- package/esm/deps/jsr.io/@std/assert/1.0.13/equals.js +4 -4
- package/esm/deps/jsr.io/@std/async/1.0.13/mux_async_iterator.js +31 -47
- package/esm/deps/jsr.io/@std/async/1.0.13/tee.js +11 -34
- package/esm/deps/jsr.io/@std/datetime/0.225.5/_date_time_formatter.js +4 -17
- package/esm/deps/jsr.io/@std/internal/1.0.10/build_message.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/diff.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/diff_str.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/format.d.ts +29 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/format.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/format.js +70 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/styles.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/types.d.ts.map +1 -0
- package/esm/mod.js +2 -12
- package/esm/session/0_session_state.js +12 -38
- package/esm/session/1_session.js +49 -72
- package/esm/session/2_session_encrypted.js +324 -320
- package/esm/storage/1_utilities_test.d.ts.map +1 -1
- package/esm/storage/2_storage_indexed_db.js +26 -44
- package/esm/storage/2_storage_local_storage.node.js +12 -25
- package/esm/storage/2_storage_memory.js +24 -41
- package/esm/storage/2_storage_session_storage.js +3 -16
- package/esm/tl/0_utilities_test.d.ts.map +1 -1
- package/esm/tl/1_tl_reader.js +80 -88
- package/esm/tl/1_tl_reader_test.d.ts.map +1 -1
- package/esm/tl/1_tl_writer.js +155 -164
- package/esm/tl/1_tl_writer_test.d.ts.map +1 -1
- package/esm/tl/2_telegram.d.ts +9 -10
- package/esm/tl/2_telegram.d.ts.map +1 -1
- package/esm/tl/2_telegram.js +10 -10
- package/esm/transport/0_transport.js +1 -8
- package/esm/transport/1_transport_abridged.js +11 -24
- package/esm/transport/1_transport_intermediate.js +10 -23
- package/{script/transport/2_transport_provider.d.ts → esm/transport/1_transport_provider.d.ts} +1 -1
- package/esm/transport/{2_transport_provider.d.ts.map → 1_transport_provider.d.ts.map} +1 -1
- package/{script/transport/3_transport_provider_tcp.d.ts → esm/transport/2_transport_provider_tcp.d.ts} +2 -2
- package/esm/transport/{3_transport_provider_tcp.d.ts.map → 2_transport_provider_tcp.d.ts.map} +1 -1
- package/esm/transport/{3_transport_provider_tcp.js → 2_transport_provider_tcp.js} +1 -1
- package/esm/transport/{3_transport_provider_web_socket.d.ts → 2_transport_provider_web_socket.d.ts} +2 -2
- package/esm/transport/2_transport_provider_web_socket.d.ts.map +1 -0
- package/esm/transport/{3_transport_provider_web_socket.js → 2_transport_provider_web_socket.js} +1 -1
- package/esm/types/0_upload_progress.d.ts +29 -0
- package/esm/types/0_upload_progress.d.ts.map +1 -0
- package/esm/types/0_upload_progress.js +20 -0
- package/esm/types/{2_inline_keyboard_button.d.ts → 1_inline_keyboard_button.d.ts} +1 -1
- package/esm/types/{2_inline_keyboard_button.d.ts.map → 1_inline_keyboard_button.d.ts.map} +1 -1
- package/esm/types/1_sticker.d.ts +1 -1
- package/esm/types/1_sticker.d.ts.map +1 -1
- package/esm/types/2_chat.d.ts.map +1 -1
- package/esm/types/2_poll_answer.d.ts +19 -0
- package/esm/types/2_poll_answer.d.ts.map +1 -1
- package/esm/types/2_poll_answer.js +19 -0
- package/esm/types/2_pre_checkout_query.d.ts.map +1 -1
- package/esm/types/{3_reply_markup.d.ts → 2_reply_markup.d.ts} +2 -2
- package/esm/types/{3_reply_markup.d.ts.map → 2_reply_markup.d.ts.map} +1 -1
- package/esm/types/{3_reply_markup.js → 2_reply_markup.js} +1 -1
- package/esm/types/2_story_interactive_area.d.ts.map +1 -1
- package/esm/types/3_chat_member_updated.d.ts.map +1 -1
- package/esm/types/3_story.d.ts.map +1 -1
- package/esm/types/5_message.d.ts +1 -1
- package/esm/types/5_message.d.ts.map +1 -1
- package/esm/types/5_message.js +1 -1
- package/esm/types/6_inline_query_result.d.ts +1 -1
- package/esm/types/6_inline_query_result.js +1 -1
- package/esm/types/7_update.d.ts +21 -2
- package/esm/types/7_update.d.ts.map +1 -1
- package/esm/utilities/0_bigint_test.d.ts.map +1 -1
- package/esm/utilities/0_buffer.d.ts +1 -1
- package/esm/utilities/0_buffer.d.ts.map +1 -1
- package/esm/utilities/0_buffer_test.d.ts.map +1 -1
- package/esm/utilities/0_hash.d.ts +2 -2
- package/esm/utilities/0_hash.d.ts.map +1 -1
- package/esm/utilities/0_mutex.js +4 -19
- package/esm/utilities/0_part_stream.js +11 -25
- package/esm/utilities/0_part_stream_test.d.ts.map +1 -1
- package/esm/utilities/0_rle.d.ts +2 -2
- package/esm/utilities/0_rle.d.ts.map +1 -1
- package/esm/utilities/0_rle_test.d.ts.map +1 -1
- package/esm/utilities/0_text.d.ts +20 -1
- package/esm/utilities/0_text.d.ts.map +1 -1
- package/esm/utilities/0_text.js +19 -0
- package/esm/utilities/1_auth.d.ts +1 -1
- package/esm/utilities/1_auth.d.ts.map +1 -1
- package/esm/utilities/1_base64.d.ts +1 -1
- package/esm/utilities/1_base64.d.ts.map +1 -1
- package/esm/utilities/1_base64_test.d.ts.map +1 -1
- package/esm/utilities/1_crypto.js +42 -53
- package/esm/utilities/1_crypto_test.d.ts.map +1 -1
- package/esm/utilities/1_logger.d.ts +2 -2
- package/esm/utilities/1_math_test.d.ts.map +1 -1
- package/esm/utilities/2_queue.js +29 -47
- package/package.json +1 -1
- package/script/0_errors.js +2 -6
- package/script/2_tl.js +17 -7
- package/script/3_errors.js +2 -12
- package/script/3_transport.d.ts +3 -3
- package/script/3_transport.js +3 -3
- package/script/3_types.d.ts +8 -7
- package/script/3_types.d.ts.map +1 -1
- package/script/3_types.js +8 -7
- package/script/4_constants.js +17 -7
- package/script/4_errors.js +2 -12
- package/script/_dnt.polyfills.d.ts +99 -0
- package/script/_dnt.polyfills.d.ts.map +1 -1
- package/script/_dnt.polyfills.js +128 -0
- package/script/_dnt.test_polyfills.d.ts.map +1 -0
- package/script/client/0_filters_test.d.ts.map +1 -1
- package/script/client/0_markdown_test.d.ts.map +1 -1
- package/script/client/0_params.d.ts +2 -0
- package/script/client/0_params.d.ts.map +1 -1
- package/script/client/0_password.d.ts +5 -5
- package/script/client/0_password.d.ts.map +1 -1
- package/script/client/0_password.js +17 -7
- package/script/client/0_password_test.d.ts.map +1 -1
- package/script/client/0_storage_operations.js +143 -155
- package/script/client/0_storage_operations_test.d.ts.map +1 -1
- package/script/client/0_utilities.d.ts +1 -1
- package/script/client/0_utilities_test.d.ts.map +1 -1
- package/script/client/1_client_plain.js +4 -22
- package/script/client/1_composer.js +8 -21
- package/script/client/2_account_manager.js +85 -97
- package/script/client/2_bot_info_manager.js +26 -38
- package/script/client/2_business_connection_manager.js +10 -23
- package/script/client/2_client_encrypted.js +195 -212
- package/script/client/2_file_manager.d.ts +4 -3
- package/script/client/2_file_manager.d.ts.map +1 -1
- package/script/client/2_file_manager.js +285 -231
- package/script/client/2_file_manager_test.d.ts.map +1 -1
- package/script/client/2_network_statistics_manager.js +8 -21
- package/script/client/2_payment_manager.js +7 -20
- package/script/client/2_reaction_manager.js +7 -20
- package/script/client/2_translations_manager.js +98 -108
- package/script/client/2_update_manager.js +764 -759
- package/script/client/3_client_encrypted_pool.js +10 -26
- package/script/client/3_client_encrypted_pool_test.d.ts.map +1 -1
- package/script/client/3_message_manager.d.ts +1 -1
- package/script/client/3_message_manager.js +441 -448
- package/script/client/3_message_manager_test.d.ts.map +1 -1
- package/script/client/3_video_chat_manager.d.ts +1 -1
- package/script/client/3_video_chat_manager.js +57 -68
- package/script/client/4_callback_query_manager.js +18 -30
- package/script/client/4_chat_list_manager.js +322 -318
- package/script/client/4_chat_manager.js +118 -131
- package/script/client/4_forum_manager.js +67 -73
- package/script/client/4_gift_manager.js +16 -29
- package/script/client/4_inline_query_manager.js +16 -28
- package/script/client/4_link_preview_manager.js +6 -19
- package/script/client/4_poll_manager.js +44 -57
- package/script/client/4_story_manager.js +41 -53
- package/script/client/5_client.d.ts +7 -0
- package/script/client/5_client.d.ts.map +1 -1
- package/script/client/5_client.js +1271 -1290
- package/script/connection/1_connection_tcp.node.js +48 -65
- package/script/connection/1_connection_web_socket.js +92 -98
- package/script/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
- package/script/deps/jsr.io/@std/assert/1.0.13/equal.js +17 -7
- package/script/deps/jsr.io/@std/assert/1.0.13/equals.js +4 -4
- package/script/deps/jsr.io/@std/async/1.0.13/delay.js +17 -7
- package/script/deps/jsr.io/@std/async/1.0.13/mux_async_iterator.js +31 -47
- package/script/deps/jsr.io/@std/async/1.0.13/tee.js +11 -34
- package/script/deps/jsr.io/@std/datetime/0.225.5/_date_time_formatter.js +4 -17
- package/script/deps/jsr.io/@std/internal/1.0.10/build_message.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/diff.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/diff_str.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/format.d.ts +29 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/format.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/format.js +106 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/styles.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.js +17 -7
- package/script/deps/jsr.io/@std/internal/1.0.10/types.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.0/_os.js +17 -7
- package/script/mod.js +19 -19
- package/script/session/0_session_state.js +12 -38
- package/script/session/1_session.js +66 -79
- package/script/session/2_session_encrypted.js +325 -321
- package/script/storage/1_utilities_test.d.ts.map +1 -1
- package/script/storage/2_storage_indexed_db.js +26 -44
- package/script/storage/2_storage_local_storage.node.js +12 -25
- package/script/storage/2_storage_memory.js +24 -41
- package/script/storage/2_storage_session_storage.js +3 -16
- package/script/tl/0_utilities_test.d.ts.map +1 -1
- package/script/tl/1_tl_reader.js +81 -89
- package/script/tl/1_tl_reader_test.d.ts.map +1 -1
- package/script/tl/1_tl_writer.js +156 -165
- package/script/tl/1_tl_writer_test.d.ts.map +1 -1
- package/script/tl/2_telegram.d.ts +9 -10
- package/script/tl/2_telegram.d.ts.map +1 -1
- package/script/tl/2_telegram.js +32 -10
- package/script/transport/0_obfuscation.js +17 -7
- package/script/transport/0_transport.js +1 -8
- package/script/transport/1_transport_abridged.js +11 -24
- package/script/transport/1_transport_intermediate.js +10 -23
- package/{esm/transport/2_transport_provider.d.ts → script/transport/1_transport_provider.d.ts} +1 -1
- package/script/transport/{2_transport_provider.d.ts.map → 1_transport_provider.d.ts.map} +1 -1
- package/{esm/transport/3_transport_provider_tcp.d.ts → script/transport/2_transport_provider_tcp.d.ts} +2 -2
- package/script/transport/{3_transport_provider_tcp.d.ts.map → 2_transport_provider_tcp.d.ts.map} +1 -1
- package/script/transport/{3_transport_provider_tcp.js → 2_transport_provider_tcp.js} +3 -3
- package/script/transport/{3_transport_provider_web_socket.d.ts → 2_transport_provider_web_socket.d.ts} +2 -2
- package/script/transport/2_transport_provider_web_socket.d.ts.map +1 -0
- package/script/transport/{3_transport_provider_web_socket.js → 2_transport_provider_web_socket.js} +2 -2
- package/script/types/0_upload_progress.d.ts +29 -0
- package/script/types/0_upload_progress.d.ts.map +1 -0
- package/script/types/0_upload_progress.js +21 -0
- package/script/types/{2_inline_keyboard_button.d.ts → 1_inline_keyboard_button.d.ts} +1 -1
- package/script/types/{2_inline_keyboard_button.d.ts.map → 1_inline_keyboard_button.d.ts.map} +1 -1
- package/script/types/1_sticker.d.ts +1 -1
- package/script/types/1_sticker.d.ts.map +1 -1
- package/script/types/2_chat.d.ts.map +1 -1
- package/script/types/2_poll_answer.d.ts +19 -0
- package/script/types/2_poll_answer.d.ts.map +1 -1
- package/script/types/2_poll_answer.js +19 -0
- package/script/types/2_pre_checkout_query.d.ts.map +1 -1
- package/script/types/{3_reply_markup.d.ts → 2_reply_markup.d.ts} +2 -2
- package/script/types/{3_reply_markup.d.ts.map → 2_reply_markup.d.ts.map} +1 -1
- package/script/types/{3_reply_markup.js → 2_reply_markup.js} +3 -3
- package/script/types/2_story_interactive_area.d.ts.map +1 -1
- package/script/types/3_chat_member_updated.d.ts.map +1 -1
- package/script/types/3_story.d.ts.map +1 -1
- package/script/types/5_message.d.ts +1 -1
- package/script/types/5_message.d.ts.map +1 -1
- package/script/types/5_message.js +2 -2
- package/script/types/6_inline_query_result.d.ts +1 -1
- package/script/types/6_inline_query_result.js +4 -4
- package/script/types/7_update.d.ts +21 -2
- package/script/types/7_update.d.ts.map +1 -1
- package/script/utilities/0_bigint.js +17 -7
- package/script/utilities/0_bigint_test.d.ts.map +1 -1
- package/script/utilities/0_buffer.d.ts +1 -1
- package/script/utilities/0_buffer.d.ts.map +1 -1
- package/script/utilities/0_buffer_test.d.ts.map +1 -1
- package/script/utilities/0_env.js +17 -7
- package/script/utilities/0_hash.d.ts +2 -2
- package/script/utilities/0_hash.d.ts.map +1 -1
- package/script/utilities/0_hash.js +17 -7
- package/script/utilities/0_misc.js +17 -7
- package/script/utilities/0_mutex.js +4 -19
- package/script/utilities/0_part_stream.js +11 -25
- package/script/utilities/0_part_stream_test.d.ts.map +1 -1
- package/script/utilities/0_rle.d.ts +2 -2
- package/script/utilities/0_rle.d.ts.map +1 -1
- package/script/utilities/0_rle_test.d.ts.map +1 -1
- package/script/utilities/0_text.d.ts +20 -1
- package/script/utilities/0_text.d.ts.map +1 -1
- package/script/utilities/0_text.js +19 -0
- package/script/utilities/1_auth.d.ts +1 -1
- package/script/utilities/1_auth.d.ts.map +1 -1
- package/script/utilities/1_auth.js +17 -7
- package/script/utilities/1_base64.d.ts +1 -1
- package/script/utilities/1_base64.d.ts.map +1 -1
- package/script/utilities/1_base64_test.d.ts.map +1 -1
- package/script/utilities/1_crypto.js +60 -61
- package/script/utilities/1_crypto_test.d.ts.map +1 -1
- package/script/utilities/1_logger.d.ts +2 -2
- package/script/utilities/1_math_test.d.ts.map +1 -1
- package/script/utilities/2_queue.js +30 -48
- package/esm/deps/jsr.io/@std/internal/1.0.9/build_message.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/diff.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/diff_str.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/format.d.ts +0 -2
- package/esm/deps/jsr.io/@std/internal/1.0.9/format.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/format.js +0 -37
- package/esm/deps/jsr.io/@std/internal/1.0.9/styles.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/types.d.ts.map +0 -1
- package/esm/transport/3_transport_provider_web_socket.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/build_message.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/diff.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/diff_str.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/format.d.ts +0 -2
- package/script/deps/jsr.io/@std/internal/1.0.9/format.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/format.js +0 -63
- package/script/deps/jsr.io/@std/internal/1.0.9/styles.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/types.d.ts.map +0 -1
- package/script/transport/3_transport_provider_web_socket.d.ts.map +0 -1
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.js +0 -0
- /package/esm/transport/{2_transport_provider.js → 1_transport_provider.js} +0 -0
- /package/esm/types/{2_inline_keyboard_button.js → 1_inline_keyboard_button.js} +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.js +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.js +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.js +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.js +0 -0
- /package/script/transport/{2_transport_provider.js → 1_transport_provider.js} +0 -0
- /package/script/types/{2_inline_keyboard_button.js → 1_inline_keyboard_button.js} +0 -0
|
@@ -18,18 +18,6 @@
|
|
|
18
18
|
* You should have received a copy of the GNU Lesser General Public License
|
|
19
19
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
22
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
23
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
24
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
25
|
-
};
|
|
26
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
27
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
28
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
29
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
30
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
31
|
-
};
|
|
32
|
-
var _Client_instances, _Client_clients, _Client_downloadPools, _Client_uploadPools, _Client_guaranteeUpdateDelivery, _Client_accountManager, _Client_botInfoManager, _Client_businessConnectionManager, _Client_fileManager, _Client_networkStatisticsManager, _Client_paymentManager, _Client_reactionManager, _Client_translationsManager, _Client_updateManager, _Client_messageManager, _Client_videoChatManager, _Client_callbackQueryManager, _Client_chatListManager, _Client_chatManager, _Client_forumManager, _Client_giftManager, _Client_inlineQueryManager, _Client_linkPreviewManager, _Client_pollManager, _Client_storyManager, _Client_managers, _Client_storage_, _Client_messageStorage_, _Client_parseMode, _Client_apiId, _Client_apiHash, _Client_transportProvider, _Client_publicKeys, _Client_outgoingMessages, _Client_persistCache, _Client_disableUpdates, _Client_authString, _Client_initialDc, _Client_L, _Client_LsignIn, _Client_LupdateGapRecoveryLoop, _Client_LhandleMigrationError, _Client_Lmin, _Client_setMainClient, _Client_newClient, _Client_disconnectAllClients, _Client_client_get, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_stateChangeHandler, _Client_storageInited, _Client_initStorage, _Client_connectMutex, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_getSelfId, _Client_getIsPremium, _Client_lastUpdates, _Client_updateGapRecoveryLoopAbortController, _Client_startUpdateGapRecoveryLoop, _Client_updateGapRecoveryLoop, _Client_clientDisconnectionLoopAbortController, _Client_startClientDisconnectionLoop, _Client_clientDisconnectionLoop, _Client_getClient, _Client_getMainClientMutex, _Client_getMainClient, _Client_getDownloadClient, _Client_getUploadPoolSize, _Client_getUploadClient, _Client_setupClient, _Client_importAuthorization, _Client_invoke, _Client_handleInvokeError, _Client_authStringImported, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerChatId, _Client_getInputPeerInner, _Client_getMinInputPeer, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe, _Client_previouslyConnected, _Client_lastConnectionState, _Client_onConnectionStateChange;
|
|
33
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
22
|
exports.Client = exports.handleMigrationError = exports.restartAuth = exports.Composer = void 0;
|
|
35
23
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
@@ -83,615 +71,130 @@ const getEntity = Symbol();
|
|
|
83
71
|
* An MTKruto client.
|
|
84
72
|
*/
|
|
85
73
|
class Client extends Composer {
|
|
74
|
+
#clients = new Array();
|
|
75
|
+
#downloadPools = {};
|
|
76
|
+
#uploadPools = {};
|
|
77
|
+
#guaranteeUpdateDelivery;
|
|
78
|
+
// 2_
|
|
79
|
+
#accountManager;
|
|
80
|
+
#botInfoManager;
|
|
81
|
+
#businessConnectionManager;
|
|
82
|
+
#fileManager;
|
|
83
|
+
#networkStatisticsManager;
|
|
84
|
+
#paymentManager;
|
|
85
|
+
#reactionManager;
|
|
86
|
+
#translationsManager;
|
|
87
|
+
#updateManager;
|
|
88
|
+
// 3_
|
|
89
|
+
#messageManager;
|
|
90
|
+
#videoChatManager;
|
|
91
|
+
// 4_
|
|
92
|
+
#callbackQueryManager;
|
|
93
|
+
#chatListManager;
|
|
94
|
+
#chatManager;
|
|
95
|
+
#forumManager;
|
|
96
|
+
#giftManager;
|
|
97
|
+
#inlineQueryManager;
|
|
98
|
+
#linkPreviewManager;
|
|
99
|
+
#pollManager;
|
|
100
|
+
#storyManager;
|
|
101
|
+
// deno-lint-ignore no-explicit-any
|
|
102
|
+
#managers;
|
|
86
103
|
// deno-lint-ignore no-explicit-any
|
|
87
104
|
get managers() {
|
|
88
|
-
return
|
|
105
|
+
return this.#managers ?? (this.#managers ??= {
|
|
89
106
|
// 2_
|
|
90
|
-
accountManager:
|
|
91
|
-
botInfoManager:
|
|
92
|
-
businessConnectionManager:
|
|
93
|
-
fileManager:
|
|
94
|
-
networkStatisticsManager:
|
|
95
|
-
paymentManager:
|
|
96
|
-
reactionManager:
|
|
97
|
-
translationsManager:
|
|
98
|
-
updateManager:
|
|
107
|
+
accountManager: this.#accountManager,
|
|
108
|
+
botInfoManager: this.#botInfoManager,
|
|
109
|
+
businessConnectionManager: this.#businessConnectionManager,
|
|
110
|
+
fileManager: this.#fileManager,
|
|
111
|
+
networkStatisticsManager: this.#networkStatisticsManager,
|
|
112
|
+
paymentManager: this.#paymentManager,
|
|
113
|
+
reactionManager: this.#reactionManager,
|
|
114
|
+
translationsManager: this.#translationsManager,
|
|
115
|
+
updateManager: this.#updateManager,
|
|
99
116
|
// 3_
|
|
100
|
-
messageManager:
|
|
101
|
-
videoChatManager:
|
|
117
|
+
messageManager: this.#messageManager,
|
|
118
|
+
videoChatManager: this.#videoChatManager,
|
|
102
119
|
// 4_
|
|
103
|
-
callbackQueryManager:
|
|
104
|
-
chatListManager:
|
|
105
|
-
chatManager:
|
|
106
|
-
forumManager:
|
|
107
|
-
giftManager:
|
|
108
|
-
inlineQueryManager:
|
|
109
|
-
linkPreviewManager:
|
|
110
|
-
pollManager:
|
|
111
|
-
storyManager:
|
|
112
|
-
}
|
|
120
|
+
callbackQueryManager: this.#callbackQueryManager,
|
|
121
|
+
chatListManager: this.#chatListManager,
|
|
122
|
+
chatManager: this.#chatManager,
|
|
123
|
+
forumManager: this.#forumManager,
|
|
124
|
+
giftManager: this.#giftManager,
|
|
125
|
+
inlineQueryManager: this.#inlineQueryManager,
|
|
126
|
+
linkPreviewManager: this.#linkPreviewManager,
|
|
127
|
+
pollManager: this.#pollManager,
|
|
128
|
+
storyManager: this.#storyManager,
|
|
129
|
+
});
|
|
113
130
|
}
|
|
131
|
+
#storage_;
|
|
132
|
+
#messageStorage_;
|
|
133
|
+
storage;
|
|
134
|
+
messageStorage;
|
|
135
|
+
#parseMode;
|
|
136
|
+
#apiId;
|
|
137
|
+
#apiHash;
|
|
138
|
+
#transportProvider;
|
|
139
|
+
appVersion;
|
|
140
|
+
deviceModel;
|
|
141
|
+
language;
|
|
142
|
+
platform;
|
|
143
|
+
systemLangCode;
|
|
144
|
+
systemVersion;
|
|
145
|
+
#publicKeys;
|
|
146
|
+
#outgoingMessages;
|
|
147
|
+
#persistCache;
|
|
148
|
+
#disableUpdates;
|
|
149
|
+
#authString;
|
|
150
|
+
#initialDc;
|
|
151
|
+
#L;
|
|
152
|
+
#LsignIn;
|
|
153
|
+
#LupdateGapRecoveryLoop;
|
|
154
|
+
#LhandleMigrationError;
|
|
155
|
+
#Lmin;
|
|
114
156
|
/**
|
|
115
157
|
* Constructs the client.
|
|
116
158
|
*/
|
|
117
159
|
constructor(params) {
|
|
118
160
|
super();
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
_Client_businessConnectionManager.set(this, void 0);
|
|
128
|
-
_Client_fileManager.set(this, void 0);
|
|
129
|
-
_Client_networkStatisticsManager.set(this, void 0);
|
|
130
|
-
_Client_paymentManager.set(this, void 0);
|
|
131
|
-
_Client_reactionManager.set(this, void 0);
|
|
132
|
-
_Client_translationsManager.set(this, void 0);
|
|
133
|
-
_Client_updateManager.set(this, void 0);
|
|
134
|
-
// 3_
|
|
135
|
-
_Client_messageManager.set(this, void 0);
|
|
136
|
-
_Client_videoChatManager.set(this, void 0);
|
|
137
|
-
// 4_
|
|
138
|
-
_Client_callbackQueryManager.set(this, void 0);
|
|
139
|
-
_Client_chatListManager.set(this, void 0);
|
|
140
|
-
_Client_chatManager.set(this, void 0);
|
|
141
|
-
_Client_forumManager.set(this, void 0);
|
|
142
|
-
_Client_giftManager.set(this, void 0);
|
|
143
|
-
_Client_inlineQueryManager.set(this, void 0);
|
|
144
|
-
_Client_linkPreviewManager.set(this, void 0);
|
|
145
|
-
_Client_pollManager.set(this, void 0);
|
|
146
|
-
_Client_storyManager.set(this, void 0);
|
|
147
|
-
// deno-lint-ignore no-explicit-any
|
|
148
|
-
_Client_managers.set(this, void 0);
|
|
149
|
-
_Client_storage_.set(this, void 0);
|
|
150
|
-
_Client_messageStorage_.set(this, void 0);
|
|
151
|
-
Object.defineProperty(this, "storage", {
|
|
152
|
-
enumerable: true,
|
|
153
|
-
configurable: true,
|
|
154
|
-
writable: true,
|
|
155
|
-
value: void 0
|
|
156
|
-
});
|
|
157
|
-
Object.defineProperty(this, "messageStorage", {
|
|
158
|
-
enumerable: true,
|
|
159
|
-
configurable: true,
|
|
160
|
-
writable: true,
|
|
161
|
-
value: void 0
|
|
162
|
-
});
|
|
163
|
-
_Client_parseMode.set(this, void 0);
|
|
164
|
-
_Client_apiId.set(this, void 0);
|
|
165
|
-
_Client_apiHash.set(this, void 0);
|
|
166
|
-
_Client_transportProvider.set(this, void 0);
|
|
167
|
-
Object.defineProperty(this, "appVersion", {
|
|
168
|
-
enumerable: true,
|
|
169
|
-
configurable: true,
|
|
170
|
-
writable: true,
|
|
171
|
-
value: void 0
|
|
172
|
-
});
|
|
173
|
-
Object.defineProperty(this, "deviceModel", {
|
|
174
|
-
enumerable: true,
|
|
175
|
-
configurable: true,
|
|
176
|
-
writable: true,
|
|
177
|
-
value: void 0
|
|
178
|
-
});
|
|
179
|
-
Object.defineProperty(this, "language", {
|
|
180
|
-
enumerable: true,
|
|
181
|
-
configurable: true,
|
|
182
|
-
writable: true,
|
|
183
|
-
value: void 0
|
|
184
|
-
});
|
|
185
|
-
Object.defineProperty(this, "platform", {
|
|
186
|
-
enumerable: true,
|
|
187
|
-
configurable: true,
|
|
188
|
-
writable: true,
|
|
189
|
-
value: void 0
|
|
190
|
-
});
|
|
191
|
-
Object.defineProperty(this, "systemLangCode", {
|
|
192
|
-
enumerable: true,
|
|
193
|
-
configurable: true,
|
|
194
|
-
writable: true,
|
|
195
|
-
value: void 0
|
|
196
|
-
});
|
|
197
|
-
Object.defineProperty(this, "systemVersion", {
|
|
198
|
-
enumerable: true,
|
|
199
|
-
configurable: true,
|
|
200
|
-
writable: true,
|
|
201
|
-
value: void 0
|
|
202
|
-
});
|
|
203
|
-
_Client_publicKeys.set(this, void 0);
|
|
204
|
-
_Client_outgoingMessages.set(this, void 0);
|
|
205
|
-
_Client_persistCache.set(this, void 0);
|
|
206
|
-
_Client_disableUpdates.set(this, void 0);
|
|
207
|
-
_Client_authString.set(this, void 0);
|
|
208
|
-
_Client_initialDc.set(this, void 0);
|
|
209
|
-
_Client_L.set(this, void 0);
|
|
210
|
-
_Client_LsignIn.set(this, void 0);
|
|
211
|
-
_Client_LupdateGapRecoveryLoop.set(this, void 0);
|
|
212
|
-
_Client_LhandleMigrationError.set(this, void 0);
|
|
213
|
-
_Client_Lmin.set(this, void 0);
|
|
214
|
-
_Client_constructContext.set(this, async (update) => {
|
|
215
|
-
const msg = "message" in update ? update.message : "editedMessage" in update ? update.editedMessage : "scheduledMessage" in update ? update.scheduledMessage : "callbackQuery" in update ? update.callbackQuery.message : undefined;
|
|
216
|
-
const reactions = "messageInteractions" in update ? update.messageInteractions : undefined;
|
|
217
|
-
const mustGetMsg = () => {
|
|
218
|
-
if (msg !== undefined) {
|
|
219
|
-
return { chatId: msg.chat.id, messageId: msg.id, businessConnectionId: msg.businessConnectionId, senderId: msg.from?.id, userId: msg.from?.id };
|
|
220
|
-
}
|
|
221
|
-
else if (reactions !== undefined) {
|
|
222
|
-
return { chatId: reactions.chatId, messageId: reactions.messageId };
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
(0, _0_deps_js_1.unreachable)();
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
const mustGetUserId = () => {
|
|
229
|
-
if (msg?.from) {
|
|
230
|
-
return msg.from.id;
|
|
231
|
-
}
|
|
232
|
-
else if ("callbackQuery" in update) {
|
|
233
|
-
return update.callbackQuery.from.id;
|
|
234
|
-
}
|
|
235
|
-
else if ("chosenInlineResult" in update) {
|
|
236
|
-
return update.chosenInlineResult.from.id;
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
(0, _0_deps_js_1.unreachable)();
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
const mustGetInlineMsgId = () => {
|
|
243
|
-
if ("chosenInlineResult" in update) {
|
|
244
|
-
if (update.chosenInlineResult.inlineMessageId) {
|
|
245
|
-
return update.chosenInlineResult.inlineMessageId;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
else if ("callbackQuery" in update) {
|
|
249
|
-
if (update.callbackQuery.inlineMessageId) {
|
|
250
|
-
return update.callbackQuery.inlineMessageId;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
(0, _0_deps_js_1.unreachable)();
|
|
254
|
-
};
|
|
255
|
-
const chat_ = "messageReactions" in update ? update.messageReactions.chat : "messageReactionCount" in update ? update.messageReactionCount.chat : "chatMember" in update ? update.chatMember.chat : "myChatMember" in update ? update.myChatMember.chat : "joinRequest" in update ? update.joinRequest.chat : "story" in update ? update.story.chat : undefined;
|
|
256
|
-
const chat = chat_ ?? msg?.chat;
|
|
257
|
-
const from = "callbackQuery" in update ? update.callbackQuery.from : "inlineQuery" in update ? update.inlineQuery.from : "chatMember" in update ? update.chatMember.from : "myChatMember" in update ? update.myChatMember.from : "messageReactions" in update ? update.messageReactions.user : "preCheckoutQuery" in update ? update.preCheckoutQuery.from : "joinRequest" in update ? update.joinRequest.from : "businessConnection" in update ? update.businessConnection.user : "pollAnswer" in update ? update.pollAnswer.from : msg?.from ? msg.from : undefined;
|
|
258
|
-
const getReplyTo = (quote, chatId, messageId) => {
|
|
259
|
-
if ("story" in update) {
|
|
260
|
-
return { chatId: update.story.chat.id, storyId: update.story.id };
|
|
261
|
-
}
|
|
262
|
-
const isPrivate = chatId > 0;
|
|
263
|
-
const shouldQuote = quote === undefined ? !isPrivate : quote;
|
|
264
|
-
return shouldQuote ? { messageId } : undefined;
|
|
265
|
-
};
|
|
266
|
-
const me = "connectionState" in update ? __classPrivateFieldGet(this, _Client_lastGetMe, "f") : ("authorizationState" in update && !update.authorizationState.authorized) ? __classPrivateFieldGet(this, _Client_lastGetMe, "f") : await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getMe).call(this);
|
|
267
|
-
const context = {
|
|
268
|
-
...update,
|
|
269
|
-
client: this,
|
|
270
|
-
me: (me == null ? undefined : me),
|
|
271
|
-
msg: msg,
|
|
272
|
-
chat: chat,
|
|
273
|
-
from: from,
|
|
274
|
-
get toJSON() {
|
|
275
|
-
return () => update;
|
|
276
|
-
},
|
|
277
|
-
reply: (text, params) => {
|
|
278
|
-
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
279
|
-
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
280
|
-
return this.sendMessage(chatId, text, { ...params, replyTo, businessConnectionId });
|
|
281
|
-
},
|
|
282
|
-
replyPoll: (question, options, params) => {
|
|
283
|
-
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
284
|
-
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
285
|
-
return this.sendPoll(chatId, question, options, { ...params, replyTo, businessConnectionId });
|
|
286
|
-
},
|
|
287
|
-
replyPhoto: (photo, params) => {
|
|
288
|
-
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
289
|
-
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
290
|
-
return this.sendPhoto(chatId, photo, { ...params, replyTo, businessConnectionId });
|
|
291
|
-
},
|
|
292
|
-
replyMediaGroup: (media, params) => {
|
|
293
|
-
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
294
|
-
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
295
|
-
return this.sendMediaGroup(chatId, media, { ...params, replyTo, businessConnectionId });
|
|
296
|
-
},
|
|
297
|
-
replyInvoice: (title, description, payload, currency, prices, params) => {
|
|
298
|
-
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
299
|
-
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
300
|
-
return this.sendInvoice(chatId, title, description, payload, currency, prices, { ...params, replyTo, businessConnectionId });
|
|
301
|
-
},
|
|
302
|
-
replyDocument: (document, params) => {
|
|
303
|
-
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
304
|
-
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
305
|
-
return this.sendDocument(chatId, document, { ...params, replyTo, businessConnectionId });
|
|
306
|
-
},
|
|
307
|
-
replySticker: (sticker, params) => {
|
|
308
|
-
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
309
|
-
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
310
|
-
return this.sendSticker(chatId, sticker, { ...params, replyTo, businessConnectionId });
|
|
311
|
-
},
|
|
312
|
-
replyContact: (firstName, number, params) => {
|
|
313
|
-
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
314
|
-
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
315
|
-
return this.sendContact(chatId, firstName, number, { ...params, replyTo, businessConnectionId });
|
|
316
|
-
},
|
|
317
|
-
replyLocation: (latitude, longitude, params) => {
|
|
318
|
-
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
319
|
-
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
320
|
-
return this.sendLocation(chatId, latitude, longitude, { ...params, replyTo, businessConnectionId });
|
|
321
|
-
},
|
|
322
|
-
replyDice: (params) => {
|
|
323
|
-
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
324
|
-
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
325
|
-
return this.sendDice(chatId, { ...params, replyTo, businessConnectionId });
|
|
326
|
-
},
|
|
327
|
-
replyVenue: (latitude, longitude, title, address, params) => {
|
|
328
|
-
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
329
|
-
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
330
|
-
return this.sendVenue(chatId, latitude, longitude, title, address, { ...params, replyTo, businessConnectionId });
|
|
331
|
-
},
|
|
332
|
-
replyVideo: (video, params) => {
|
|
333
|
-
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
334
|
-
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
335
|
-
return this.sendVideo(chatId, video, { ...params, replyTo, businessConnectionId });
|
|
336
|
-
},
|
|
337
|
-
replyAnimation: (document, params) => {
|
|
338
|
-
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
339
|
-
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
340
|
-
return this.sendAnimation(chatId, document, { ...params, replyTo, businessConnectionId });
|
|
341
|
-
},
|
|
342
|
-
replyVoice: (document, params) => {
|
|
343
|
-
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
344
|
-
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
345
|
-
return this.sendVoice(chatId, document, { ...params, replyTo, businessConnectionId });
|
|
346
|
-
},
|
|
347
|
-
replyAudio: (document, params) => {
|
|
348
|
-
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
349
|
-
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
350
|
-
return this.sendAudio(chatId, document, { ...params, replyTo, businessConnectionId });
|
|
351
|
-
},
|
|
352
|
-
replyVideoNote: (videoNote, params) => {
|
|
353
|
-
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
354
|
-
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
355
|
-
return this.sendVideoNote(chatId, videoNote, { ...params, replyTo, businessConnectionId });
|
|
356
|
-
},
|
|
357
|
-
delete: () => {
|
|
358
|
-
const { chatId, messageId } = mustGetMsg();
|
|
359
|
-
return this.deleteMessage(chatId, messageId);
|
|
360
|
-
},
|
|
361
|
-
forward: (to, params) => {
|
|
362
|
-
const { chatId, messageId } = mustGetMsg();
|
|
363
|
-
return this.forwardMessage(chatId, to, messageId, params);
|
|
364
|
-
},
|
|
365
|
-
pin: (params) => {
|
|
366
|
-
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
367
|
-
return this.pinMessage(chatId, messageId, { ...params, businessConnectionId });
|
|
368
|
-
},
|
|
369
|
-
unpin: () => {
|
|
370
|
-
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
371
|
-
return this.unpinMessage(chatId, messageId, { businessConnectionId });
|
|
372
|
-
},
|
|
373
|
-
banSender: (params) => {
|
|
374
|
-
const { chatId, senderId } = mustGetMsg();
|
|
375
|
-
if (!senderId) {
|
|
376
|
-
(0, _0_deps_js_1.unreachable)();
|
|
377
|
-
}
|
|
378
|
-
return this.banChatMember(chatId, senderId, params);
|
|
379
|
-
},
|
|
380
|
-
kickSender: () => {
|
|
381
|
-
const { chatId, senderId } = mustGetMsg();
|
|
382
|
-
if (!senderId) {
|
|
383
|
-
(0, _0_deps_js_1.unreachable)();
|
|
384
|
-
}
|
|
385
|
-
return this.kickChatMember(chatId, senderId);
|
|
386
|
-
},
|
|
387
|
-
setSenderRights: (params) => {
|
|
388
|
-
const { chatId, senderId } = mustGetMsg();
|
|
389
|
-
if (!senderId) {
|
|
390
|
-
(0, _0_deps_js_1.unreachable)();
|
|
391
|
-
}
|
|
392
|
-
return this.setChatMemberRights(chatId, senderId, params);
|
|
393
|
-
},
|
|
394
|
-
getChatAdministrators: () => {
|
|
395
|
-
const { chatId } = mustGetMsg();
|
|
396
|
-
return this.getChatAdministrators(chatId);
|
|
397
|
-
},
|
|
398
|
-
react: (reactions, params) => {
|
|
399
|
-
const { chatId, messageId } = mustGetMsg();
|
|
400
|
-
return this.setReactions(chatId, messageId, reactions, params);
|
|
401
|
-
},
|
|
402
|
-
answerCallbackQuery: (params) => {
|
|
403
|
-
if (!("callbackQuery" in update)) {
|
|
404
|
-
(0, _0_deps_js_1.unreachable)();
|
|
405
|
-
}
|
|
406
|
-
return this.answerCallbackQuery(update.callbackQuery.id, params);
|
|
407
|
-
},
|
|
408
|
-
answerInlineQuery: (results, params) => {
|
|
409
|
-
if (!("inlineQuery" in update)) {
|
|
410
|
-
(0, _0_deps_js_1.unreachable)();
|
|
411
|
-
}
|
|
412
|
-
return this.answerInlineQuery(update.inlineQuery.id, results, params);
|
|
413
|
-
},
|
|
414
|
-
sendChatAction: (chatAction, params) => {
|
|
415
|
-
const { chatId } = mustGetMsg();
|
|
416
|
-
return this.sendChatAction(chatId, chatAction, params);
|
|
417
|
-
},
|
|
418
|
-
editInlineMessageText: (text, params) => {
|
|
419
|
-
const inlineMessageId = mustGetInlineMsgId();
|
|
420
|
-
return this.editInlineMessageText(inlineMessageId, text, params);
|
|
421
|
-
},
|
|
422
|
-
editInlineMessageMedia: (media, params) => {
|
|
423
|
-
const inlineMessageId = mustGetInlineMsgId();
|
|
424
|
-
return this.editInlineMessageMedia(inlineMessageId, media, params);
|
|
425
|
-
},
|
|
426
|
-
editInlineMessageCaption: (params) => {
|
|
427
|
-
const inlineMessageId = mustGetInlineMsgId();
|
|
428
|
-
return this.editInlineMessageCaption(inlineMessageId, params);
|
|
429
|
-
},
|
|
430
|
-
editInlineMessageLiveLocation: (latitude, longitude, params) => {
|
|
431
|
-
const inlineMessageId = mustGetInlineMsgId();
|
|
432
|
-
return this.editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params);
|
|
433
|
-
},
|
|
434
|
-
editInlineMessageReplyMarkup: (params) => {
|
|
435
|
-
const inlineMessageId = mustGetInlineMsgId();
|
|
436
|
-
return this.editInlineMessageReplyMarkup(inlineMessageId, params);
|
|
437
|
-
},
|
|
438
|
-
editMessageText: (messageId, text, params) => {
|
|
439
|
-
const { chatId } = mustGetMsg();
|
|
440
|
-
return this.editMessageText(chatId, messageId, text, params);
|
|
441
|
-
},
|
|
442
|
-
editMessageCaption: (messageId, params) => {
|
|
443
|
-
const { chatId } = mustGetMsg();
|
|
444
|
-
return this.editMessageCaption(chatId, messageId, params);
|
|
445
|
-
},
|
|
446
|
-
editMessageMedia: (messageId, media, params) => {
|
|
447
|
-
const { chatId } = mustGetMsg();
|
|
448
|
-
return this.editMessageMedia(chatId, messageId, media, params);
|
|
449
|
-
},
|
|
450
|
-
editMessageLiveLocation: (messageId, latitude, longitude, params) => {
|
|
451
|
-
const { chatId } = mustGetMsg();
|
|
452
|
-
return this.editMessageLiveLocation(chatId, messageId, latitude, longitude, params);
|
|
453
|
-
},
|
|
454
|
-
editMessageReplyMarkup: (messageId, params) => {
|
|
455
|
-
const { chatId } = mustGetMsg();
|
|
456
|
-
return this.editMessageReplyMarkup(chatId, messageId, params);
|
|
457
|
-
},
|
|
458
|
-
getMessage: (messageId) => {
|
|
459
|
-
const { chatId } = mustGetMsg();
|
|
460
|
-
return this.getMessage(chatId, messageId);
|
|
461
|
-
},
|
|
462
|
-
getMessages: (messageIds) => {
|
|
463
|
-
const { chatId } = mustGetMsg();
|
|
464
|
-
return this.getMessages(chatId, messageIds);
|
|
465
|
-
},
|
|
466
|
-
forwardMessage: (to, messageId, params) => {
|
|
467
|
-
const { chatId } = mustGetMsg();
|
|
468
|
-
return this.forwardMessage(chatId, to, messageId, params);
|
|
469
|
-
},
|
|
470
|
-
forwardMessages: (to, messageIds, params) => {
|
|
471
|
-
const { chatId } = mustGetMsg();
|
|
472
|
-
return this.forwardMessages(chatId, to, messageIds, params);
|
|
473
|
-
},
|
|
474
|
-
deleteMessage: (messageId, params) => {
|
|
475
|
-
const { chatId } = mustGetMsg();
|
|
476
|
-
return this.deleteMessage(chatId, messageId, params);
|
|
477
|
-
},
|
|
478
|
-
deleteMessages: (messageIds, params) => {
|
|
479
|
-
const { chatId } = mustGetMsg();
|
|
480
|
-
return this.deleteMessages(chatId, messageIds, params);
|
|
481
|
-
},
|
|
482
|
-
pinMessage: (messageId, params) => {
|
|
483
|
-
const { chatId } = mustGetMsg();
|
|
484
|
-
return this.pinMessage(chatId, messageId, params);
|
|
485
|
-
},
|
|
486
|
-
unpinMessage: (messageId) => {
|
|
487
|
-
const { chatId } = mustGetMsg();
|
|
488
|
-
return this.unpinMessage(chatId, messageId);
|
|
489
|
-
},
|
|
490
|
-
unpinMessages: () => {
|
|
491
|
-
const { chatId } = mustGetMsg();
|
|
492
|
-
return this.unpinMessages(chatId);
|
|
493
|
-
},
|
|
494
|
-
setAvailableReactions: (availableReactions) => {
|
|
495
|
-
const { chatId } = mustGetMsg();
|
|
496
|
-
return this.setAvailableReactions(chatId, availableReactions);
|
|
497
|
-
},
|
|
498
|
-
addReaction: (messageId, reaction, params) => {
|
|
499
|
-
const { chatId } = mustGetMsg();
|
|
500
|
-
return this.addReaction(chatId, messageId, reaction, params);
|
|
501
|
-
},
|
|
502
|
-
removeReaction: (messageId, reaction) => {
|
|
503
|
-
const { chatId } = mustGetMsg();
|
|
504
|
-
return this.removeReaction(chatId, messageId, reaction);
|
|
505
|
-
},
|
|
506
|
-
setReactions: (messageId, reactions, params) => {
|
|
507
|
-
const { chatId } = mustGetMsg();
|
|
508
|
-
return this.setReactions(chatId, messageId, reactions, params);
|
|
509
|
-
},
|
|
510
|
-
read: () => {
|
|
511
|
-
const { chatId, messageId } = mustGetMsg();
|
|
512
|
-
return this.readMessages(chatId, messageId);
|
|
513
|
-
},
|
|
514
|
-
setChatPhoto: (photo, params) => {
|
|
515
|
-
const { chatId } = mustGetMsg();
|
|
516
|
-
return this.setChatPhoto(chatId, photo, params);
|
|
517
|
-
},
|
|
518
|
-
deleteChatPhoto: () => {
|
|
519
|
-
const { chatId } = mustGetMsg();
|
|
520
|
-
return this.deleteChatPhoto(chatId);
|
|
521
|
-
},
|
|
522
|
-
banChatMember: (memberId, params) => {
|
|
523
|
-
const { chatId } = mustGetMsg();
|
|
524
|
-
return this.banChatMember(chatId, memberId, params);
|
|
525
|
-
},
|
|
526
|
-
unbanChatMember: (memberId) => {
|
|
527
|
-
const { chatId } = mustGetMsg();
|
|
528
|
-
return this.unbanChatMember(chatId, memberId);
|
|
529
|
-
},
|
|
530
|
-
kickChatMember: (memberId) => {
|
|
531
|
-
const { chatId } = mustGetMsg();
|
|
532
|
-
return this.kickChatMember(chatId, memberId);
|
|
533
|
-
},
|
|
534
|
-
setChatMemberRights: (memberId, params) => {
|
|
535
|
-
const { chatId } = mustGetMsg();
|
|
536
|
-
return this.setChatMemberRights(chatId, memberId, params);
|
|
537
|
-
},
|
|
538
|
-
deleteChatMemberMessages: (userId) => {
|
|
539
|
-
const { chatId } = mustGetMsg();
|
|
540
|
-
return this.deleteChatMemberMessages(chatId, userId);
|
|
541
|
-
},
|
|
542
|
-
searchMessages: (query, params) => {
|
|
543
|
-
const { chatId } = mustGetMsg();
|
|
544
|
-
return this.searchMessages(chatId, query, params);
|
|
545
|
-
},
|
|
546
|
-
setBoostsRequiredToCircumventRestrictions: (boosts) => {
|
|
547
|
-
const { chatId } = mustGetMsg();
|
|
548
|
-
return this.setBoostsRequiredToCircumventRestrictions(chatId, boosts);
|
|
549
|
-
},
|
|
550
|
-
createInviteLink: (params) => {
|
|
551
|
-
const { chatId } = mustGetMsg();
|
|
552
|
-
return this.createInviteLink(chatId, params);
|
|
553
|
-
},
|
|
554
|
-
getCreatedInviteLinks: (params) => {
|
|
555
|
-
const { chatId } = mustGetMsg();
|
|
556
|
-
return this.getCreatedInviteLinks(chatId, params);
|
|
557
|
-
},
|
|
558
|
-
leave: () => {
|
|
559
|
-
const { chatId } = mustGetMsg();
|
|
560
|
-
return this.leaveChat(chatId);
|
|
561
|
-
},
|
|
562
|
-
block: () => {
|
|
563
|
-
return this.blockUser(mustGetUserId());
|
|
564
|
-
},
|
|
565
|
-
unblock: () => {
|
|
566
|
-
return this.unblockUser(mustGetUserId());
|
|
567
|
-
},
|
|
568
|
-
getChatMember: (userId) => {
|
|
569
|
-
const { chatId } = mustGetMsg();
|
|
570
|
-
return this.getChatMember(chatId, userId);
|
|
571
|
-
},
|
|
572
|
-
getChatMembers: (params) => {
|
|
573
|
-
const { chatId } = mustGetMsg();
|
|
574
|
-
return this.getChatMembers(chatId, params);
|
|
575
|
-
},
|
|
576
|
-
setChatStickerSet: (setName) => {
|
|
577
|
-
const { chatId } = mustGetMsg();
|
|
578
|
-
return this.setChatStickerSet(chatId, setName);
|
|
579
|
-
},
|
|
580
|
-
deleteChatStickerSet: () => {
|
|
581
|
-
const { chatId } = mustGetMsg();
|
|
582
|
-
return this.deleteChatStickerSet(chatId);
|
|
583
|
-
},
|
|
584
|
-
getBusinessConnection: () => {
|
|
585
|
-
const { businessConnectionId } = mustGetMsg();
|
|
586
|
-
if (!businessConnectionId) {
|
|
587
|
-
(0, _0_deps_js_1.unreachable)();
|
|
588
|
-
}
|
|
589
|
-
return this.getBusinessConnection(businessConnectionId);
|
|
590
|
-
},
|
|
591
|
-
answerPreCheckoutQuery: (ok, params) => {
|
|
592
|
-
if (!("preCheckoutQuery" in update)) {
|
|
593
|
-
(0, _0_deps_js_1.unreachable)();
|
|
594
|
-
}
|
|
595
|
-
return this.answerPreCheckoutQuery(update.preCheckoutQuery.id, ok, params);
|
|
596
|
-
},
|
|
597
|
-
approveJoinRequest: () => {
|
|
598
|
-
const { chatId, userId } = mustGetMsg();
|
|
599
|
-
if (!userId) {
|
|
600
|
-
(0, _0_deps_js_1.unreachable)();
|
|
601
|
-
}
|
|
602
|
-
return this.approveJoinRequest(chatId, userId);
|
|
603
|
-
},
|
|
604
|
-
declineJoinRequest: () => {
|
|
605
|
-
const { chatId, userId } = mustGetMsg();
|
|
606
|
-
if (!userId) {
|
|
607
|
-
(0, _0_deps_js_1.unreachable)();
|
|
608
|
-
}
|
|
609
|
-
return this.declineJoinRequest(chatId, userId);
|
|
610
|
-
},
|
|
611
|
-
};
|
|
612
|
-
return (0, _1_utilities_js_1.cleanObject)(context);
|
|
613
|
-
});
|
|
614
|
-
_Client_lastPropagatedConnectionState.set(this, null);
|
|
615
|
-
_Client_stateChangeHandler.set(this, ((connected) => {
|
|
616
|
-
const connectionState = connected ? "ready" : "notConnected";
|
|
617
|
-
if (__classPrivateFieldGet(this, _Client_lastPropagatedConnectionState, "f") != connectionState) {
|
|
618
|
-
__classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateConnectionState).call(this, connectionState);
|
|
619
|
-
}
|
|
620
|
-
}).bind(this));
|
|
621
|
-
_Client_storageInited.set(this, false);
|
|
622
|
-
_Client_connectMutex.set(this, new _1_utilities_js_1.Mutex());
|
|
623
|
-
_Client_lastPropagatedAuthorizationState.set(this, null);
|
|
624
|
-
_Client_lastUpdates.set(this, new Date());
|
|
625
|
-
_Client_updateGapRecoveryLoopAbortController.set(this, void 0);
|
|
626
|
-
_Client_clientDisconnectionLoopAbortController.set(this, void 0);
|
|
627
|
-
_Client_getMainClientMutex.set(this, new _1_utilities_js_1.Mutex());
|
|
628
|
-
_Client_handleInvokeError.set(this, skipInvoke());
|
|
629
|
-
/**
|
|
630
|
-
* Invokes a function waiting and returning its reply if the second parameter is not `true`. Requires the client
|
|
631
|
-
* to be connected.
|
|
632
|
-
*
|
|
633
|
-
* @param function_ The function to invoke.
|
|
634
|
-
*/
|
|
635
|
-
Object.defineProperty(this, "invoke", {
|
|
636
|
-
enumerable: true,
|
|
637
|
-
configurable: true,
|
|
638
|
-
writable: true,
|
|
639
|
-
value: Object.assign(__classPrivateFieldGet(this, _Client_instances, "m", _Client_invoke), {
|
|
640
|
-
use: (handler) => {
|
|
641
|
-
const handle = __classPrivateFieldGet(this, _Client_handleInvokeError, "f");
|
|
642
|
-
__classPrivateFieldSet(this, _Client_handleInvokeError, async (ctx, next) => {
|
|
643
|
-
let result = null;
|
|
644
|
-
return await handle(ctx, async () => {
|
|
645
|
-
if (result != null)
|
|
646
|
-
return result;
|
|
647
|
-
result = await handler(ctx, next);
|
|
648
|
-
return result;
|
|
649
|
-
});
|
|
650
|
-
}, "f");
|
|
651
|
-
},
|
|
652
|
-
})
|
|
653
|
-
});
|
|
654
|
-
_Client_authStringImported.set(this, false);
|
|
655
|
-
_Client_lastGetMe.set(this, null);
|
|
656
|
-
_Client_previouslyConnected.set(this, false);
|
|
657
|
-
_Client_lastConnectionState.set(this, false);
|
|
658
|
-
__classPrivateFieldSet(this, _Client_apiId, params?.apiId ?? 0, "f");
|
|
659
|
-
__classPrivateFieldSet(this, _Client_apiHash, params?.apiHash ?? "", "f");
|
|
660
|
-
__classPrivateFieldSet(this, _Client_transportProvider, params?.transportProvider, "f");
|
|
661
|
-
__classPrivateFieldSet(this, _Client_initialDc, params?.initialDc ?? _4_constants_js_1.INITIAL_DC, "f");
|
|
662
|
-
__classPrivateFieldSet(this, _Client_storage_, params?.storage || new _2_storage_js_1.StorageMemory(), "f");
|
|
663
|
-
__classPrivateFieldSet(this, _Client_persistCache, params?.persistCache ?? false, "f");
|
|
664
|
-
if (!__classPrivateFieldGet(this, _Client_persistCache, "f")) {
|
|
665
|
-
__classPrivateFieldSet(this, _Client_messageStorage_, new _2_storage_js_1.StorageMemory(), "f");
|
|
161
|
+
this.#apiId = params?.apiId ?? 0;
|
|
162
|
+
this.#apiHash = params?.apiHash ?? "";
|
|
163
|
+
this.#transportProvider = params?.transportProvider;
|
|
164
|
+
this.#initialDc = params?.initialDc ?? _4_constants_js_1.INITIAL_DC;
|
|
165
|
+
this.#storage_ = params?.storage || new _2_storage_js_1.StorageMemory();
|
|
166
|
+
this.#persistCache = params?.persistCache ?? false;
|
|
167
|
+
if (!this.#persistCache) {
|
|
168
|
+
this.#messageStorage_ = new _2_storage_js_1.StorageMemory();
|
|
666
169
|
}
|
|
667
170
|
else {
|
|
668
|
-
|
|
171
|
+
this.#messageStorage_ = this.#storage_;
|
|
669
172
|
}
|
|
670
|
-
this.storage = new _0_storage_operations_js_1.StorageOperations(
|
|
671
|
-
this.messageStorage = new _0_storage_operations_js_1.StorageOperations(
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
173
|
+
this.storage = new _0_storage_operations_js_1.StorageOperations(this.#storage_);
|
|
174
|
+
this.messageStorage = new _0_storage_operations_js_1.StorageOperations(this.#messageStorage_);
|
|
175
|
+
this.#parseMode = params?.parseMode ?? null;
|
|
176
|
+
this.#disableUpdates = params?.disableUpdates ?? false;
|
|
177
|
+
this.#authString = params?.authString;
|
|
675
178
|
this.appVersion = params?.appVersion ?? _4_constants_js_1.APP_VERSION;
|
|
676
179
|
this.deviceModel = params?.deviceModel ?? _4_constants_js_1.DEVICE_MODEL;
|
|
677
180
|
this.language = params?.language ?? _4_constants_js_1.LANG_CODE;
|
|
678
181
|
this.platform = params?.platform ?? _4_constants_js_1.LANG_PACK;
|
|
679
182
|
this.systemLangCode = params?.systemLangCode ?? _4_constants_js_1.SYSTEM_LANG_CODE;
|
|
680
183
|
this.systemVersion = params?.systemVersion ?? _4_constants_js_1.SYSTEM_VERSION;
|
|
681
|
-
|
|
682
|
-
|
|
184
|
+
this.#publicKeys = params?.publicKeys;
|
|
185
|
+
this.#outgoingMessages = params?.outgoingMessages ?? null;
|
|
683
186
|
if (params?.prefixes) {
|
|
684
187
|
this.prefixes = params?.prefixes;
|
|
685
188
|
}
|
|
686
|
-
|
|
687
|
-
const L =
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
189
|
+
this.#guaranteeUpdateDelivery = params?.guaranteeUpdateDelivery ?? false;
|
|
190
|
+
const L = this.#L = (0, _1_utilities_js_1.getLogger)("Client").client(id++);
|
|
191
|
+
this.#LsignIn = L.branch("signIn");
|
|
192
|
+
this.#LupdateGapRecoveryLoop = L.branch("updateGapRecoveryLoop");
|
|
193
|
+
this.#LhandleMigrationError = L.branch("[handleMigrationError]");
|
|
194
|
+
this.#Lmin = L.branch("min");
|
|
692
195
|
const c = {
|
|
693
196
|
id,
|
|
694
|
-
getUploadPoolSize:
|
|
197
|
+
getUploadPoolSize: this.#getUploadPoolSize.bind(this),
|
|
695
198
|
invoke: async (function_, params) => {
|
|
696
199
|
if (params?.businessConnectionId) {
|
|
697
200
|
if (_2_tl_js_1.Mtproto.is("ping", function_)) {
|
|
@@ -705,48 +208,48 @@ class Client extends Composer {
|
|
|
705
208
|
},
|
|
706
209
|
storage: this.storage,
|
|
707
210
|
messageStorage: this.messageStorage,
|
|
708
|
-
guaranteeUpdateDelivery:
|
|
709
|
-
setConnectionState:
|
|
710
|
-
resetConnectionState: () =>
|
|
711
|
-
getSelfId:
|
|
712
|
-
getIsPremium:
|
|
211
|
+
guaranteeUpdateDelivery: this.#guaranteeUpdateDelivery,
|
|
212
|
+
setConnectionState: this.#propagateConnectionState.bind(this),
|
|
213
|
+
resetConnectionState: () => this.#stateChangeHandler(this.connected),
|
|
214
|
+
getSelfId: this.#getSelfId.bind(this),
|
|
215
|
+
getIsPremium: this.#getIsPremium.bind(this),
|
|
713
216
|
getInputPeer: this.getInputPeer.bind(this),
|
|
714
217
|
getInputChannel: this.getInputChannel.bind(this),
|
|
715
218
|
getInputUser: this.getInputUser.bind(this),
|
|
716
|
-
getInputPeerChatId:
|
|
219
|
+
getInputPeerChatId: this.#getInputPeerChatId.bind(this),
|
|
717
220
|
getEntity: this[getEntity].bind(this),
|
|
718
|
-
handleUpdate:
|
|
719
|
-
parseMode:
|
|
720
|
-
outgoingMessages:
|
|
221
|
+
handleUpdate: this.#queueHandleCtxUpdate.bind(this),
|
|
222
|
+
parseMode: this.#parseMode,
|
|
223
|
+
outgoingMessages: this.#outgoingMessages,
|
|
721
224
|
dropPendingUpdates: params?.dropPendingUpdates,
|
|
722
225
|
disconnected: () => this.disconnected,
|
|
723
226
|
langPack: this.platform,
|
|
724
227
|
langCode: this.language,
|
|
725
228
|
};
|
|
726
229
|
// 2_
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
const fileManager =
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
230
|
+
this.#accountManager = new _2_account_manager_js_1.AccountManager(c);
|
|
231
|
+
this.#botInfoManager = new _2_bot_info_manager_js_1.BotInfoManager(c);
|
|
232
|
+
this.#businessConnectionManager = new _2_business_connection_manager_js_1.BusinessConnectionManager(c);
|
|
233
|
+
const fileManager = this.#fileManager = new _2_file_manager_js_1.FileManager(c);
|
|
234
|
+
this.#networkStatisticsManager = new _2_network_statistics_manager_js_1.NetworkStatisticsManager(c);
|
|
235
|
+
this.#paymentManager = new _2_payment_manager_js_1.PaymentManager(c);
|
|
236
|
+
this.#reactionManager = new _2_reaction_manager_js_1.ReactionManager(c);
|
|
237
|
+
this.#translationsManager = new _2_translations_manager_js_1.TranslationsManager(c);
|
|
238
|
+
this.#updateManager = new _2_update_manager_js_1.UpdateManager(c);
|
|
736
239
|
// 3_
|
|
737
|
-
const messageManager =
|
|
738
|
-
|
|
240
|
+
const messageManager = this.#messageManager = new _3_message_manager_js_1.MessageManager({ ...c, fileManager });
|
|
241
|
+
this.#videoChatManager = new _3_video_chat_manager_js_1.VideoChatManager({ ...c, fileManager });
|
|
739
242
|
// 4_
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
243
|
+
this.#callbackQueryManager = new _4_callback_query_manager_js_1.CallbackQueryManager({ ...c, messageManager });
|
|
244
|
+
this.#chatListManager = new _4_chat_list_manager_js_1.ChatListManager({ ...c, fileManager, messageManager });
|
|
245
|
+
this.#chatManager = new _4_chat_manager_js_1.ChatManager({ ...c, fileManager, messageManager });
|
|
246
|
+
this.#forumManager = new _4_forum_manager_js_1.ForumManager({ ...c, messageManager });
|
|
247
|
+
this.#giftManager = new _4_gift_manager_js_1.GiftManager({ ...c, messageManager });
|
|
248
|
+
this.#inlineQueryManager = new _4_inline_query_manager_js_1.InlineQueryManager({ ...c, messageManager });
|
|
249
|
+
this.#linkPreviewManager = new _4_link_preview_manager_js_1.LinkPreviewManager({ ...c, messageManager });
|
|
250
|
+
this.#pollManager = new _4_poll_manager_js_1.PollManager({ ...c, messageManager });
|
|
251
|
+
this.#storyManager = new _4_story_manager_js_1.StoryManager({ ...c, fileManager, messageManager });
|
|
252
|
+
this.#updateManager.setUpdateHandler(this.#handleUpdate.bind(this));
|
|
750
253
|
if (params?.defaultHandlers ?? true) {
|
|
751
254
|
this.invoke.use(async ({ error }, next) => {
|
|
752
255
|
if (error instanceof _4_errors_js_1.FloodWait && error.seconds <= 10) {
|
|
@@ -760,123 +263,622 @@ class Client extends Composer {
|
|
|
760
263
|
});
|
|
761
264
|
}
|
|
762
265
|
}
|
|
266
|
+
#setMainClient(client) {
|
|
267
|
+
this.#disconnectAllClients();
|
|
268
|
+
this.#clients = [client];
|
|
269
|
+
client.handlers.onUpdate = (updates) => {
|
|
270
|
+
this.#updateManager.processUpdates(updates, true, null);
|
|
271
|
+
this.#lastUpdates = new Date();
|
|
272
|
+
};
|
|
273
|
+
client.handlers.onDeserializationError = async () => {
|
|
274
|
+
await this.#updateManager.recoverUpdateGap("deserialization error");
|
|
275
|
+
};
|
|
276
|
+
client.handlers.onNewServerSalt = async (serverSalt) => {
|
|
277
|
+
await this.storage.setServerSalt(serverSalt);
|
|
278
|
+
};
|
|
279
|
+
client.onConnectionStateChange = this.#onConnectionStateChange.bind(this);
|
|
280
|
+
}
|
|
281
|
+
#newClient(dc, main, cdn) {
|
|
282
|
+
const client = new _2_client_encrypted_js_1.ClientEncrypted(dc, this.#apiId, {
|
|
283
|
+
appVersion: this.appVersion,
|
|
284
|
+
deviceModel: this.deviceModel,
|
|
285
|
+
langCode: this.language,
|
|
286
|
+
langPack: this.platform,
|
|
287
|
+
systemLangCode: this.systemLangCode,
|
|
288
|
+
systemVersion: this.systemVersion,
|
|
289
|
+
transportProvider: this.#transportProvider,
|
|
290
|
+
cdn,
|
|
291
|
+
disableUpdates: !main || cdn,
|
|
292
|
+
publicKeys: this.#publicKeys,
|
|
293
|
+
});
|
|
294
|
+
client.connectionCallback = this.#networkStatisticsManager.getTransportReadWriteCallback(cdn);
|
|
295
|
+
return client;
|
|
296
|
+
}
|
|
297
|
+
#disconnectAllClients() {
|
|
298
|
+
for (const client of this.#clients) {
|
|
299
|
+
client.disconnect();
|
|
300
|
+
}
|
|
301
|
+
for (const pool of Object.values(this.#downloadPools)) {
|
|
302
|
+
pool.disconnect();
|
|
303
|
+
}
|
|
304
|
+
for (const pool of Object.values(this.#uploadPools)) {
|
|
305
|
+
pool.disconnect();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
get #client() {
|
|
309
|
+
return this.#clients[0];
|
|
310
|
+
}
|
|
763
311
|
// direct ClientEncrypted property proxies
|
|
764
312
|
get connected() {
|
|
765
|
-
return
|
|
313
|
+
return this.#client?.connected ?? false;
|
|
766
314
|
}
|
|
767
315
|
get disconnected() {
|
|
768
|
-
return
|
|
316
|
+
return this.#client?.disconnected ?? true;
|
|
317
|
+
}
|
|
318
|
+
#constructContext = async (update) => {
|
|
319
|
+
const msg = "message" in update ? update.message : "editedMessage" in update ? update.editedMessage : "scheduledMessage" in update ? update.scheduledMessage : "callbackQuery" in update ? update.callbackQuery.message : undefined;
|
|
320
|
+
const reactions = "messageInteractions" in update ? update.messageInteractions : undefined;
|
|
321
|
+
const mustGetMsg = () => {
|
|
322
|
+
if (msg !== undefined) {
|
|
323
|
+
return { chatId: msg.chat.id, messageId: msg.id, businessConnectionId: msg.businessConnectionId, senderId: msg.from?.id, userId: msg.from?.id };
|
|
324
|
+
}
|
|
325
|
+
else if (reactions !== undefined) {
|
|
326
|
+
return { chatId: reactions.chatId, messageId: reactions.messageId };
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
(0, _0_deps_js_1.unreachable)();
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
const mustGetUserId = () => {
|
|
333
|
+
if (msg?.from) {
|
|
334
|
+
return msg.from.id;
|
|
335
|
+
}
|
|
336
|
+
else if ("callbackQuery" in update) {
|
|
337
|
+
return update.callbackQuery.from.id;
|
|
338
|
+
}
|
|
339
|
+
else if ("chosenInlineResult" in update) {
|
|
340
|
+
return update.chosenInlineResult.from.id;
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
(0, _0_deps_js_1.unreachable)();
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
const mustGetInlineMsgId = () => {
|
|
347
|
+
if ("chosenInlineResult" in update) {
|
|
348
|
+
if (update.chosenInlineResult.inlineMessageId) {
|
|
349
|
+
return update.chosenInlineResult.inlineMessageId;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
else if ("callbackQuery" in update) {
|
|
353
|
+
if (update.callbackQuery.inlineMessageId) {
|
|
354
|
+
return update.callbackQuery.inlineMessageId;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
(0, _0_deps_js_1.unreachable)();
|
|
358
|
+
};
|
|
359
|
+
const chat_ = "messageReactions" in update ? update.messageReactions.chat : "messageReactionCount" in update ? update.messageReactionCount.chat : "chatMember" in update ? update.chatMember.chat : "myChatMember" in update ? update.myChatMember.chat : "joinRequest" in update ? update.joinRequest.chat : "story" in update ? update.story.chat : undefined;
|
|
360
|
+
const chat = chat_ ?? msg?.chat;
|
|
361
|
+
const from = "callbackQuery" in update ? update.callbackQuery.from : "inlineQuery" in update ? update.inlineQuery.from : "chatMember" in update ? update.chatMember.from : "myChatMember" in update ? update.myChatMember.from : "messageReactions" in update ? update.messageReactions.user : "preCheckoutQuery" in update ? update.preCheckoutQuery.from : "joinRequest" in update ? update.joinRequest.from : "businessConnection" in update ? update.businessConnection.user : "pollAnswer" in update ? update.pollAnswer.from : msg?.from ? msg.from : undefined;
|
|
362
|
+
const getReplyTo = (quote, chatId, messageId) => {
|
|
363
|
+
if ("story" in update) {
|
|
364
|
+
return { chatId: update.story.chat.id, storyId: update.story.id };
|
|
365
|
+
}
|
|
366
|
+
const isPrivate = chatId > 0;
|
|
367
|
+
const shouldQuote = quote === undefined ? !isPrivate : quote;
|
|
368
|
+
return shouldQuote ? { messageId } : undefined;
|
|
369
|
+
};
|
|
370
|
+
const me = "connectionState" in update ? this.#lastGetMe : ("authorizationState" in update && !update.authorizationState.authorized) ? this.#lastGetMe : await this.#getMe();
|
|
371
|
+
const context = {
|
|
372
|
+
...update,
|
|
373
|
+
client: this,
|
|
374
|
+
me: (me == null ? undefined : me),
|
|
375
|
+
msg: msg,
|
|
376
|
+
chat: chat,
|
|
377
|
+
from: from,
|
|
378
|
+
get toJSON() {
|
|
379
|
+
return () => update;
|
|
380
|
+
},
|
|
381
|
+
reply: (text, params) => {
|
|
382
|
+
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
383
|
+
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
384
|
+
return this.sendMessage(chatId, text, { ...params, replyTo, businessConnectionId });
|
|
385
|
+
},
|
|
386
|
+
replyPoll: (question, options, params) => {
|
|
387
|
+
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
388
|
+
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
389
|
+
return this.sendPoll(chatId, question, options, { ...params, replyTo, businessConnectionId });
|
|
390
|
+
},
|
|
391
|
+
replyPhoto: (photo, params) => {
|
|
392
|
+
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
393
|
+
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
394
|
+
return this.sendPhoto(chatId, photo, { ...params, replyTo, businessConnectionId });
|
|
395
|
+
},
|
|
396
|
+
replyMediaGroup: (media, params) => {
|
|
397
|
+
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
398
|
+
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
399
|
+
return this.sendMediaGroup(chatId, media, { ...params, replyTo, businessConnectionId });
|
|
400
|
+
},
|
|
401
|
+
replyInvoice: (title, description, payload, currency, prices, params) => {
|
|
402
|
+
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
403
|
+
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
404
|
+
return this.sendInvoice(chatId, title, description, payload, currency, prices, { ...params, replyTo, businessConnectionId });
|
|
405
|
+
},
|
|
406
|
+
replyDocument: (document, params) => {
|
|
407
|
+
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
408
|
+
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
409
|
+
return this.sendDocument(chatId, document, { ...params, replyTo, businessConnectionId });
|
|
410
|
+
},
|
|
411
|
+
replySticker: (sticker, params) => {
|
|
412
|
+
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
413
|
+
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
414
|
+
return this.sendSticker(chatId, sticker, { ...params, replyTo, businessConnectionId });
|
|
415
|
+
},
|
|
416
|
+
replyContact: (firstName, number, params) => {
|
|
417
|
+
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
418
|
+
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
419
|
+
return this.sendContact(chatId, firstName, number, { ...params, replyTo, businessConnectionId });
|
|
420
|
+
},
|
|
421
|
+
replyLocation: (latitude, longitude, params) => {
|
|
422
|
+
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
423
|
+
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
424
|
+
return this.sendLocation(chatId, latitude, longitude, { ...params, replyTo, businessConnectionId });
|
|
425
|
+
},
|
|
426
|
+
replyDice: (params) => {
|
|
427
|
+
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
428
|
+
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
429
|
+
return this.sendDice(chatId, { ...params, replyTo, businessConnectionId });
|
|
430
|
+
},
|
|
431
|
+
replyVenue: (latitude, longitude, title, address, params) => {
|
|
432
|
+
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
433
|
+
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
434
|
+
return this.sendVenue(chatId, latitude, longitude, title, address, { ...params, replyTo, businessConnectionId });
|
|
435
|
+
},
|
|
436
|
+
replyVideo: (video, params) => {
|
|
437
|
+
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
438
|
+
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
439
|
+
return this.sendVideo(chatId, video, { ...params, replyTo, businessConnectionId });
|
|
440
|
+
},
|
|
441
|
+
replyAnimation: (document, params) => {
|
|
442
|
+
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
443
|
+
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
444
|
+
return this.sendAnimation(chatId, document, { ...params, replyTo, businessConnectionId });
|
|
445
|
+
},
|
|
446
|
+
replyVoice: (document, params) => {
|
|
447
|
+
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
448
|
+
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
449
|
+
return this.sendVoice(chatId, document, { ...params, replyTo, businessConnectionId });
|
|
450
|
+
},
|
|
451
|
+
replyAudio: (document, params) => {
|
|
452
|
+
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
453
|
+
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
454
|
+
return this.sendAudio(chatId, document, { ...params, replyTo, businessConnectionId });
|
|
455
|
+
},
|
|
456
|
+
replyVideoNote: (videoNote, params) => {
|
|
457
|
+
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
458
|
+
const replyTo = getReplyTo(params?.quote, chatId, messageId);
|
|
459
|
+
return this.sendVideoNote(chatId, videoNote, { ...params, replyTo, businessConnectionId });
|
|
460
|
+
},
|
|
461
|
+
delete: () => {
|
|
462
|
+
const { chatId, messageId } = mustGetMsg();
|
|
463
|
+
return this.deleteMessage(chatId, messageId);
|
|
464
|
+
},
|
|
465
|
+
forward: (to, params) => {
|
|
466
|
+
const { chatId, messageId } = mustGetMsg();
|
|
467
|
+
return this.forwardMessage(chatId, to, messageId, params);
|
|
468
|
+
},
|
|
469
|
+
pin: (params) => {
|
|
470
|
+
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
471
|
+
return this.pinMessage(chatId, messageId, { ...params, businessConnectionId });
|
|
472
|
+
},
|
|
473
|
+
unpin: () => {
|
|
474
|
+
const { chatId, messageId, businessConnectionId } = mustGetMsg();
|
|
475
|
+
return this.unpinMessage(chatId, messageId, { businessConnectionId });
|
|
476
|
+
},
|
|
477
|
+
banSender: (params) => {
|
|
478
|
+
const { chatId, senderId } = mustGetMsg();
|
|
479
|
+
if (!senderId) {
|
|
480
|
+
(0, _0_deps_js_1.unreachable)();
|
|
481
|
+
}
|
|
482
|
+
return this.banChatMember(chatId, senderId, params);
|
|
483
|
+
},
|
|
484
|
+
kickSender: () => {
|
|
485
|
+
const { chatId, senderId } = mustGetMsg();
|
|
486
|
+
if (!senderId) {
|
|
487
|
+
(0, _0_deps_js_1.unreachable)();
|
|
488
|
+
}
|
|
489
|
+
return this.kickChatMember(chatId, senderId);
|
|
490
|
+
},
|
|
491
|
+
setSenderRights: (params) => {
|
|
492
|
+
const { chatId, senderId } = mustGetMsg();
|
|
493
|
+
if (!senderId) {
|
|
494
|
+
(0, _0_deps_js_1.unreachable)();
|
|
495
|
+
}
|
|
496
|
+
return this.setChatMemberRights(chatId, senderId, params);
|
|
497
|
+
},
|
|
498
|
+
getChatAdministrators: () => {
|
|
499
|
+
const { chatId } = mustGetMsg();
|
|
500
|
+
return this.getChatAdministrators(chatId);
|
|
501
|
+
},
|
|
502
|
+
react: (reactions, params) => {
|
|
503
|
+
const { chatId, messageId } = mustGetMsg();
|
|
504
|
+
return this.setReactions(chatId, messageId, reactions, params);
|
|
505
|
+
},
|
|
506
|
+
answerCallbackQuery: (params) => {
|
|
507
|
+
if (!("callbackQuery" in update)) {
|
|
508
|
+
(0, _0_deps_js_1.unreachable)();
|
|
509
|
+
}
|
|
510
|
+
return this.answerCallbackQuery(update.callbackQuery.id, params);
|
|
511
|
+
},
|
|
512
|
+
answerInlineQuery: (results, params) => {
|
|
513
|
+
if (!("inlineQuery" in update)) {
|
|
514
|
+
(0, _0_deps_js_1.unreachable)();
|
|
515
|
+
}
|
|
516
|
+
return this.answerInlineQuery(update.inlineQuery.id, results, params);
|
|
517
|
+
},
|
|
518
|
+
sendChatAction: (chatAction, params) => {
|
|
519
|
+
const { chatId } = mustGetMsg();
|
|
520
|
+
return this.sendChatAction(chatId, chatAction, params);
|
|
521
|
+
},
|
|
522
|
+
editInlineMessageText: (text, params) => {
|
|
523
|
+
const inlineMessageId = mustGetInlineMsgId();
|
|
524
|
+
return this.editInlineMessageText(inlineMessageId, text, params);
|
|
525
|
+
},
|
|
526
|
+
editInlineMessageMedia: (media, params) => {
|
|
527
|
+
const inlineMessageId = mustGetInlineMsgId();
|
|
528
|
+
return this.editInlineMessageMedia(inlineMessageId, media, params);
|
|
529
|
+
},
|
|
530
|
+
editInlineMessageCaption: (params) => {
|
|
531
|
+
const inlineMessageId = mustGetInlineMsgId();
|
|
532
|
+
return this.editInlineMessageCaption(inlineMessageId, params);
|
|
533
|
+
},
|
|
534
|
+
editInlineMessageLiveLocation: (latitude, longitude, params) => {
|
|
535
|
+
const inlineMessageId = mustGetInlineMsgId();
|
|
536
|
+
return this.editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params);
|
|
537
|
+
},
|
|
538
|
+
editInlineMessageReplyMarkup: (params) => {
|
|
539
|
+
const inlineMessageId = mustGetInlineMsgId();
|
|
540
|
+
return this.editInlineMessageReplyMarkup(inlineMessageId, params);
|
|
541
|
+
},
|
|
542
|
+
editMessageText: (messageId, text, params) => {
|
|
543
|
+
const { chatId } = mustGetMsg();
|
|
544
|
+
return this.editMessageText(chatId, messageId, text, params);
|
|
545
|
+
},
|
|
546
|
+
editMessageCaption: (messageId, params) => {
|
|
547
|
+
const { chatId } = mustGetMsg();
|
|
548
|
+
return this.editMessageCaption(chatId, messageId, params);
|
|
549
|
+
},
|
|
550
|
+
editMessageMedia: (messageId, media, params) => {
|
|
551
|
+
const { chatId } = mustGetMsg();
|
|
552
|
+
return this.editMessageMedia(chatId, messageId, media, params);
|
|
553
|
+
},
|
|
554
|
+
editMessageLiveLocation: (messageId, latitude, longitude, params) => {
|
|
555
|
+
const { chatId } = mustGetMsg();
|
|
556
|
+
return this.editMessageLiveLocation(chatId, messageId, latitude, longitude, params);
|
|
557
|
+
},
|
|
558
|
+
editMessageReplyMarkup: (messageId, params) => {
|
|
559
|
+
const { chatId } = mustGetMsg();
|
|
560
|
+
return this.editMessageReplyMarkup(chatId, messageId, params);
|
|
561
|
+
},
|
|
562
|
+
getMessage: (messageId) => {
|
|
563
|
+
const { chatId } = mustGetMsg();
|
|
564
|
+
return this.getMessage(chatId, messageId);
|
|
565
|
+
},
|
|
566
|
+
getMessages: (messageIds) => {
|
|
567
|
+
const { chatId } = mustGetMsg();
|
|
568
|
+
return this.getMessages(chatId, messageIds);
|
|
569
|
+
},
|
|
570
|
+
forwardMessage: (to, messageId, params) => {
|
|
571
|
+
const { chatId } = mustGetMsg();
|
|
572
|
+
return this.forwardMessage(chatId, to, messageId, params);
|
|
573
|
+
},
|
|
574
|
+
forwardMessages: (to, messageIds, params) => {
|
|
575
|
+
const { chatId } = mustGetMsg();
|
|
576
|
+
return this.forwardMessages(chatId, to, messageIds, params);
|
|
577
|
+
},
|
|
578
|
+
deleteMessage: (messageId, params) => {
|
|
579
|
+
const { chatId } = mustGetMsg();
|
|
580
|
+
return this.deleteMessage(chatId, messageId, params);
|
|
581
|
+
},
|
|
582
|
+
deleteMessages: (messageIds, params) => {
|
|
583
|
+
const { chatId } = mustGetMsg();
|
|
584
|
+
return this.deleteMessages(chatId, messageIds, params);
|
|
585
|
+
},
|
|
586
|
+
pinMessage: (messageId, params) => {
|
|
587
|
+
const { chatId } = mustGetMsg();
|
|
588
|
+
return this.pinMessage(chatId, messageId, params);
|
|
589
|
+
},
|
|
590
|
+
unpinMessage: (messageId) => {
|
|
591
|
+
const { chatId } = mustGetMsg();
|
|
592
|
+
return this.unpinMessage(chatId, messageId);
|
|
593
|
+
},
|
|
594
|
+
unpinMessages: () => {
|
|
595
|
+
const { chatId } = mustGetMsg();
|
|
596
|
+
return this.unpinMessages(chatId);
|
|
597
|
+
},
|
|
598
|
+
setAvailableReactions: (availableReactions) => {
|
|
599
|
+
const { chatId } = mustGetMsg();
|
|
600
|
+
return this.setAvailableReactions(chatId, availableReactions);
|
|
601
|
+
},
|
|
602
|
+
addReaction: (messageId, reaction, params) => {
|
|
603
|
+
const { chatId } = mustGetMsg();
|
|
604
|
+
return this.addReaction(chatId, messageId, reaction, params);
|
|
605
|
+
},
|
|
606
|
+
removeReaction: (messageId, reaction) => {
|
|
607
|
+
const { chatId } = mustGetMsg();
|
|
608
|
+
return this.removeReaction(chatId, messageId, reaction);
|
|
609
|
+
},
|
|
610
|
+
setReactions: (messageId, reactions, params) => {
|
|
611
|
+
const { chatId } = mustGetMsg();
|
|
612
|
+
return this.setReactions(chatId, messageId, reactions, params);
|
|
613
|
+
},
|
|
614
|
+
read: () => {
|
|
615
|
+
const { chatId, messageId } = mustGetMsg();
|
|
616
|
+
return this.readMessages(chatId, messageId);
|
|
617
|
+
},
|
|
618
|
+
setChatPhoto: (photo, params) => {
|
|
619
|
+
const { chatId } = mustGetMsg();
|
|
620
|
+
return this.setChatPhoto(chatId, photo, params);
|
|
621
|
+
},
|
|
622
|
+
deleteChatPhoto: () => {
|
|
623
|
+
const { chatId } = mustGetMsg();
|
|
624
|
+
return this.deleteChatPhoto(chatId);
|
|
625
|
+
},
|
|
626
|
+
banChatMember: (memberId, params) => {
|
|
627
|
+
const { chatId } = mustGetMsg();
|
|
628
|
+
return this.banChatMember(chatId, memberId, params);
|
|
629
|
+
},
|
|
630
|
+
unbanChatMember: (memberId) => {
|
|
631
|
+
const { chatId } = mustGetMsg();
|
|
632
|
+
return this.unbanChatMember(chatId, memberId);
|
|
633
|
+
},
|
|
634
|
+
kickChatMember: (memberId) => {
|
|
635
|
+
const { chatId } = mustGetMsg();
|
|
636
|
+
return this.kickChatMember(chatId, memberId);
|
|
637
|
+
},
|
|
638
|
+
setChatMemberRights: (memberId, params) => {
|
|
639
|
+
const { chatId } = mustGetMsg();
|
|
640
|
+
return this.setChatMemberRights(chatId, memberId, params);
|
|
641
|
+
},
|
|
642
|
+
deleteChatMemberMessages: (userId) => {
|
|
643
|
+
const { chatId } = mustGetMsg();
|
|
644
|
+
return this.deleteChatMemberMessages(chatId, userId);
|
|
645
|
+
},
|
|
646
|
+
searchMessages: (query, params) => {
|
|
647
|
+
const { chatId } = mustGetMsg();
|
|
648
|
+
return this.searchMessages(chatId, query, params);
|
|
649
|
+
},
|
|
650
|
+
setBoostsRequiredToCircumventRestrictions: (boosts) => {
|
|
651
|
+
const { chatId } = mustGetMsg();
|
|
652
|
+
return this.setBoostsRequiredToCircumventRestrictions(chatId, boosts);
|
|
653
|
+
},
|
|
654
|
+
createInviteLink: (params) => {
|
|
655
|
+
const { chatId } = mustGetMsg();
|
|
656
|
+
return this.createInviteLink(chatId, params);
|
|
657
|
+
},
|
|
658
|
+
getCreatedInviteLinks: (params) => {
|
|
659
|
+
const { chatId } = mustGetMsg();
|
|
660
|
+
return this.getCreatedInviteLinks(chatId, params);
|
|
661
|
+
},
|
|
662
|
+
leave: () => {
|
|
663
|
+
const { chatId } = mustGetMsg();
|
|
664
|
+
return this.leaveChat(chatId);
|
|
665
|
+
},
|
|
666
|
+
block: () => {
|
|
667
|
+
return this.blockUser(mustGetUserId());
|
|
668
|
+
},
|
|
669
|
+
unblock: () => {
|
|
670
|
+
return this.unblockUser(mustGetUserId());
|
|
671
|
+
},
|
|
672
|
+
getChatMember: (userId) => {
|
|
673
|
+
const { chatId } = mustGetMsg();
|
|
674
|
+
return this.getChatMember(chatId, userId);
|
|
675
|
+
},
|
|
676
|
+
getChatMembers: (params) => {
|
|
677
|
+
const { chatId } = mustGetMsg();
|
|
678
|
+
return this.getChatMembers(chatId, params);
|
|
679
|
+
},
|
|
680
|
+
setChatStickerSet: (setName) => {
|
|
681
|
+
const { chatId } = mustGetMsg();
|
|
682
|
+
return this.setChatStickerSet(chatId, setName);
|
|
683
|
+
},
|
|
684
|
+
deleteChatStickerSet: () => {
|
|
685
|
+
const { chatId } = mustGetMsg();
|
|
686
|
+
return this.deleteChatStickerSet(chatId);
|
|
687
|
+
},
|
|
688
|
+
getBusinessConnection: () => {
|
|
689
|
+
const { businessConnectionId } = mustGetMsg();
|
|
690
|
+
if (!businessConnectionId) {
|
|
691
|
+
(0, _0_deps_js_1.unreachable)();
|
|
692
|
+
}
|
|
693
|
+
return this.getBusinessConnection(businessConnectionId);
|
|
694
|
+
},
|
|
695
|
+
answerPreCheckoutQuery: (ok, params) => {
|
|
696
|
+
if (!("preCheckoutQuery" in update)) {
|
|
697
|
+
(0, _0_deps_js_1.unreachable)();
|
|
698
|
+
}
|
|
699
|
+
return this.answerPreCheckoutQuery(update.preCheckoutQuery.id, ok, params);
|
|
700
|
+
},
|
|
701
|
+
approveJoinRequest: () => {
|
|
702
|
+
const { chatId, userId } = mustGetMsg();
|
|
703
|
+
if (!userId) {
|
|
704
|
+
(0, _0_deps_js_1.unreachable)();
|
|
705
|
+
}
|
|
706
|
+
return this.approveJoinRequest(chatId, userId);
|
|
707
|
+
},
|
|
708
|
+
declineJoinRequest: () => {
|
|
709
|
+
const { chatId, userId } = mustGetMsg();
|
|
710
|
+
if (!userId) {
|
|
711
|
+
(0, _0_deps_js_1.unreachable)();
|
|
712
|
+
}
|
|
713
|
+
return this.declineJoinRequest(chatId, userId);
|
|
714
|
+
},
|
|
715
|
+
};
|
|
716
|
+
return (0, _1_utilities_js_1.cleanObject)(context);
|
|
717
|
+
};
|
|
718
|
+
#propagateConnectionState(connectionState) {
|
|
719
|
+
this.#queueHandleCtxUpdate({ connectionState });
|
|
720
|
+
this.#lastPropagatedConnectionState = connectionState;
|
|
721
|
+
}
|
|
722
|
+
#lastPropagatedConnectionState = null;
|
|
723
|
+
#stateChangeHandler = ((connected) => {
|
|
724
|
+
const connectionState = connected ? "ready" : "notConnected";
|
|
725
|
+
if (this.#lastPropagatedConnectionState != connectionState) {
|
|
726
|
+
this.#propagateConnectionState(connectionState);
|
|
727
|
+
}
|
|
728
|
+
}).bind(this);
|
|
729
|
+
#storageInited = false;
|
|
730
|
+
async #initStorage() {
|
|
731
|
+
if (!this.#storageInited) {
|
|
732
|
+
await this.storage.initialize();
|
|
733
|
+
if (!this.#guaranteeUpdateDelivery) {
|
|
734
|
+
await this.storage.deleteUpdates();
|
|
735
|
+
}
|
|
736
|
+
this.#storageInited = true;
|
|
737
|
+
}
|
|
769
738
|
}
|
|
739
|
+
#connectMutex = new _1_utilities_js_1.Mutex();
|
|
770
740
|
/**
|
|
771
741
|
* Loads the session if `setDc` was not called, initializes and connnects
|
|
772
742
|
* a `ClientPlain` to generate auth key if there was none, and connects the client.
|
|
773
743
|
* Before establishing the connection, the session is saved.
|
|
774
744
|
*/
|
|
775
745
|
async connect() {
|
|
776
|
-
const unlock = await
|
|
746
|
+
const unlock = await this.#connectMutex.lock();
|
|
777
747
|
try {
|
|
778
748
|
if (this.connected) {
|
|
779
749
|
return;
|
|
780
750
|
}
|
|
781
|
-
await
|
|
782
|
-
if (
|
|
783
|
-
await this.importAuthString(
|
|
751
|
+
await this.#initStorage();
|
|
752
|
+
if (this.#authString && !this.#authStringImported) {
|
|
753
|
+
await this.importAuthString(this.#authString);
|
|
784
754
|
}
|
|
785
755
|
const [authKey, dc] = await Promise.all([this.storage.getAuthKey(), this.storage.getDc()]);
|
|
786
756
|
if (authKey != null && dc != null) {
|
|
787
|
-
if (!
|
|
788
|
-
|
|
789
|
-
|
|
757
|
+
if (!this.#client || this.#client.dc != dc) {
|
|
758
|
+
this.#client?.disconnect();
|
|
759
|
+
this.#setMainClient(this.#newClient(dc, true, false));
|
|
790
760
|
}
|
|
791
|
-
await
|
|
792
|
-
if (
|
|
793
|
-
|
|
761
|
+
await this.#client.setAuthKey(authKey);
|
|
762
|
+
if (this.#client.serverSalt == 0n) {
|
|
763
|
+
this.#client.serverSalt = await this.storage.getServerSalt() ?? 0n;
|
|
794
764
|
}
|
|
795
765
|
}
|
|
796
766
|
else {
|
|
797
|
-
const dc = await this.storage.getDc() ??
|
|
798
|
-
if (!
|
|
799
|
-
|
|
800
|
-
|
|
767
|
+
const dc = await this.storage.getDc() ?? this.#initialDc;
|
|
768
|
+
if (!this.#client || this.#client.dc != dc) {
|
|
769
|
+
this.#client?.disconnect();
|
|
770
|
+
this.#setMainClient(this.#newClient(dc, true, false));
|
|
801
771
|
}
|
|
802
772
|
}
|
|
803
|
-
await
|
|
804
|
-
await Promise.all([this.storage.setAuthKey(
|
|
805
|
-
|
|
806
|
-
|
|
773
|
+
await this.#client.connect();
|
|
774
|
+
await Promise.all([this.storage.setAuthKey(this.#client.authKey), this.storage.setDc(this.#client.dc), this.storage.setServerSalt(this.#client.serverSalt)]);
|
|
775
|
+
this.#startUpdateGapRecoveryLoop();
|
|
776
|
+
this.#startClientDisconnectionLoop();
|
|
807
777
|
}
|
|
808
778
|
finally {
|
|
809
779
|
unlock();
|
|
810
780
|
}
|
|
811
781
|
}
|
|
812
|
-
async [(
|
|
813
|
-
__classPrivateFieldGet(this, _Client_instances, "m", _Client_disconnectAllClients).call(this);
|
|
814
|
-
__classPrivateFieldSet(this, _Client_clients, [client], "f");
|
|
815
|
-
client.handlers.onUpdate = (updates) => {
|
|
816
|
-
__classPrivateFieldGet(this, _Client_updateManager, "f").processUpdates(updates, true, null);
|
|
817
|
-
__classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
|
|
818
|
-
};
|
|
819
|
-
client.handlers.onDeserializationError = async () => {
|
|
820
|
-
await __classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("deserialization error");
|
|
821
|
-
};
|
|
822
|
-
client.handlers.onNewServerSalt = async (serverSalt) => {
|
|
823
|
-
await this.storage.setServerSalt(serverSalt);
|
|
824
|
-
};
|
|
825
|
-
client.onConnectionStateChange = __classPrivateFieldGet(this, _Client_instances, "m", _Client_onConnectionStateChange).bind(this);
|
|
826
|
-
}, _Client_newClient = function _Client_newClient(dc, main, cdn) {
|
|
827
|
-
const client = new _2_client_encrypted_js_1.ClientEncrypted(dc, __classPrivateFieldGet(this, _Client_apiId, "f"), {
|
|
828
|
-
appVersion: this.appVersion,
|
|
829
|
-
deviceModel: this.deviceModel,
|
|
830
|
-
langCode: this.language,
|
|
831
|
-
langPack: this.platform,
|
|
832
|
-
systemLangCode: this.systemLangCode,
|
|
833
|
-
systemVersion: this.systemVersion,
|
|
834
|
-
transportProvider: __classPrivateFieldGet(this, _Client_transportProvider, "f"),
|
|
835
|
-
cdn,
|
|
836
|
-
disableUpdates: !main || cdn,
|
|
837
|
-
publicKeys: __classPrivateFieldGet(this, _Client_publicKeys, "f"),
|
|
838
|
-
});
|
|
839
|
-
client.connectionCallback = __classPrivateFieldGet(this, _Client_networkStatisticsManager, "f").getTransportReadWriteCallback(cdn);
|
|
840
|
-
return client;
|
|
841
|
-
}, _Client_disconnectAllClients = function _Client_disconnectAllClients() {
|
|
842
|
-
for (const client of __classPrivateFieldGet(this, _Client_clients, "f")) {
|
|
843
|
-
client.disconnect();
|
|
844
|
-
}
|
|
845
|
-
for (const pool of Object.values(__classPrivateFieldGet(this, _Client_downloadPools, "f"))) {
|
|
846
|
-
pool.disconnect();
|
|
847
|
-
}
|
|
848
|
-
for (const pool of Object.values(__classPrivateFieldGet(this, _Client_uploadPools, "f"))) {
|
|
849
|
-
pool.disconnect();
|
|
850
|
-
}
|
|
851
|
-
}, _Client_client_get = function _Client_client_get() {
|
|
852
|
-
return __classPrivateFieldGet(this, _Client_clients, "f")[0];
|
|
853
|
-
}, _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
|
|
854
|
-
__classPrivateFieldGet(this, _Client_instances, "m", _Client_queueHandleCtxUpdate).call(this, { connectionState });
|
|
855
|
-
__classPrivateFieldSet(this, _Client_lastPropagatedConnectionState, connectionState, "f");
|
|
856
|
-
}, _Client_initStorage = async function _Client_initStorage() {
|
|
857
|
-
if (!__classPrivateFieldGet(this, _Client_storageInited, "f")) {
|
|
858
|
-
await this.storage.initialize();
|
|
859
|
-
if (!__classPrivateFieldGet(this, _Client_guaranteeUpdateDelivery, "f")) {
|
|
860
|
-
await this.storage.deleteUpdates();
|
|
861
|
-
}
|
|
862
|
-
__classPrivateFieldSet(this, _Client_storageInited, true, "f");
|
|
863
|
-
}
|
|
864
|
-
}, exports.handleMigrationError)](err) {
|
|
782
|
+
async [exports.handleMigrationError](err) {
|
|
865
783
|
let newDc = String(err.dc);
|
|
866
|
-
if (Math.abs((0, _3_transport_js_1.getDcId)(
|
|
784
|
+
if (Math.abs((0, _3_transport_js_1.getDcId)(this.#client.dc, this.#client.cdn)) >= 10_000) {
|
|
867
785
|
newDc += "-test";
|
|
868
786
|
}
|
|
869
787
|
this.disconnect();
|
|
870
788
|
await this.storage.setDc(newDc);
|
|
871
789
|
await this.storage.setAuthKey(null);
|
|
872
790
|
await this.connect();
|
|
873
|
-
|
|
791
|
+
this.#LhandleMigrationError.debug(`migrated to DC${newDc}`);
|
|
874
792
|
}
|
|
875
793
|
disconnect() {
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
794
|
+
this.#disconnectAllClients();
|
|
795
|
+
this.#clientDisconnectionLoopAbortController?.abort();
|
|
796
|
+
this.#updateGapRecoveryLoopAbortController?.abort();
|
|
797
|
+
this.#updateManager.closeAllChats();
|
|
798
|
+
}
|
|
799
|
+
#lastPropagatedAuthorizationState = null;
|
|
800
|
+
async #propagateAuthorizationState(authorized) {
|
|
801
|
+
if (this.#lastPropagatedAuthorizationState != authorized) {
|
|
802
|
+
await this.#handleCtxUpdate({ authorizationState: { authorized } });
|
|
803
|
+
this.#lastPropagatedAuthorizationState = authorized;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
async #getSelfId() {
|
|
807
|
+
const id = await this.storage.getAccountId();
|
|
808
|
+
if (id == null) {
|
|
809
|
+
throw new Error("Unauthorized");
|
|
810
|
+
}
|
|
811
|
+
return id;
|
|
812
|
+
}
|
|
813
|
+
async #getIsPremium() {
|
|
814
|
+
const maybeIsPremium = await this.storage.getIsPremium();
|
|
815
|
+
if (maybeIsPremium != null) {
|
|
816
|
+
return maybeIsPremium;
|
|
817
|
+
}
|
|
818
|
+
return this.#lastGetMe?.isPremium ?? false;
|
|
819
|
+
}
|
|
820
|
+
#lastUpdates = new Date();
|
|
821
|
+
#updateGapRecoveryLoopAbortController;
|
|
822
|
+
#startUpdateGapRecoveryLoop() {
|
|
823
|
+
(0, _1_utilities_js_1.drop)(this.#updateGapRecoveryLoop());
|
|
824
|
+
}
|
|
825
|
+
async #updateGapRecoveryLoop() {
|
|
826
|
+
this.#updateGapRecoveryLoopAbortController?.abort();
|
|
827
|
+
const controller = this.#updateGapRecoveryLoopAbortController = new AbortController();
|
|
828
|
+
while (this.connected) {
|
|
829
|
+
try {
|
|
830
|
+
await (0, _0_deps_js_1.delay)(60 * _0_deps_js_1.SECOND, { signal: controller.signal });
|
|
831
|
+
if (!this.connected) {
|
|
832
|
+
break;
|
|
833
|
+
}
|
|
834
|
+
controller.signal.throwIfAborted();
|
|
835
|
+
if (Date.now() - this.#lastUpdates.getTime() >= 15 * _0_deps_js_1.MINUTE) {
|
|
836
|
+
(0, _1_utilities_js_1.drop)(this.#updateManager.recoverUpdateGap("lastUpdates").then(() => {
|
|
837
|
+
this.#lastUpdates = new Date();
|
|
838
|
+
}));
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
catch (err) {
|
|
842
|
+
if (err instanceof DOMException && err.name == "AbortError") {
|
|
843
|
+
break;
|
|
844
|
+
}
|
|
845
|
+
else if (!this.connected) {
|
|
846
|
+
break;
|
|
847
|
+
}
|
|
848
|
+
this.#LupdateGapRecoveryLoop.error(err);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
#clientDisconnectionLoopAbortController;
|
|
853
|
+
#startClientDisconnectionLoop() {
|
|
854
|
+
(0, _1_utilities_js_1.drop)(this.#clientDisconnectionLoop());
|
|
855
|
+
}
|
|
856
|
+
async #clientDisconnectionLoop() {
|
|
857
|
+
const controller = this.#clientDisconnectionLoopAbortController = new AbortController();
|
|
858
|
+
while (this.connected) {
|
|
859
|
+
try {
|
|
860
|
+
await (0, _0_deps_js_1.delay)(60 * _0_deps_js_1.SECOND, { signal: controller.signal });
|
|
861
|
+
if (!this.connected) {
|
|
862
|
+
break;
|
|
863
|
+
}
|
|
864
|
+
controller.signal.throwIfAborted();
|
|
865
|
+
const now = Date.now();
|
|
866
|
+
const disconnectAfter = 5 * _0_deps_js_1.MINUTE;
|
|
867
|
+
this.#clients.map((client, i) => {
|
|
868
|
+
if (i > 0 && !client.disconnected && client.lastRequest && now - client.lastRequest.getTime() >= disconnectAfter) {
|
|
869
|
+
client?.disconnect();
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
catch (err) {
|
|
874
|
+
if (err instanceof DOMException && err.name == "AbortError") {
|
|
875
|
+
break;
|
|
876
|
+
}
|
|
877
|
+
else if (!this.connected) {
|
|
878
|
+
break;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
}
|
|
880
882
|
}
|
|
881
883
|
/**
|
|
882
884
|
* Signs in using the provided parameters if not already signed in.
|
|
@@ -888,10 +890,10 @@ class Client extends Composer {
|
|
|
888
890
|
*/
|
|
889
891
|
async signIn(params) {
|
|
890
892
|
try {
|
|
891
|
-
await
|
|
892
|
-
await
|
|
893
|
-
(0, _1_utilities_js_1.drop)(
|
|
894
|
-
|
|
893
|
+
await this.#updateManager.fetchState("signIn");
|
|
894
|
+
await this.#propagateAuthorizationState(true);
|
|
895
|
+
(0, _1_utilities_js_1.drop)(this.#updateManager.recoverUpdateGap("signIn"));
|
|
896
|
+
this.#LsignIn.debug("already signed in");
|
|
895
897
|
return;
|
|
896
898
|
}
|
|
897
899
|
catch (err) {
|
|
@@ -899,10 +901,10 @@ class Client extends Composer {
|
|
|
899
901
|
throw err;
|
|
900
902
|
}
|
|
901
903
|
}
|
|
902
|
-
if (!
|
|
904
|
+
if (!this.#apiId) {
|
|
903
905
|
throw new _0_errors_js_1.InputError("apiId not set");
|
|
904
906
|
}
|
|
905
|
-
if (!
|
|
907
|
+
if (!this.#apiHash) {
|
|
906
908
|
throw new _0_errors_js_1.InputError("apiHash not set");
|
|
907
909
|
}
|
|
908
910
|
if (typeof params === "undefined") {
|
|
@@ -914,11 +916,11 @@ class Client extends Composer {
|
|
|
914
916
|
params = { phone: () => (0, _1_utilities_js_1.mustPrompt)("Phone number:"), code: () => (0, _1_utilities_js_1.mustPrompt)("Verification code:"), password: () => (0, _1_utilities_js_1.mustPrompt)("Password:") };
|
|
915
917
|
}
|
|
916
918
|
}
|
|
917
|
-
|
|
919
|
+
this.#LsignIn.debug("authorizing with", typeof params === "string" ? "bot token" : _2_tl_js_1.Api.is("auth.exportedAuthorization", params) ? "exported authorization" : "AuthorizeUserParams");
|
|
918
920
|
if (params && "botToken" in params) {
|
|
919
921
|
while (true) {
|
|
920
922
|
try {
|
|
921
|
-
const auth = await this.invoke({ _: "auth.importBotAuthorization", api_id:
|
|
923
|
+
const auth = await this.invoke({ _: "auth.importBotAuthorization", api_id: this.#apiId, api_hash: this.#apiHash, bot_auth_token: params.botToken, flags: 0 });
|
|
922
924
|
await this.storage.setAccountId(Number(_2_tl_js_1.Api.as("auth.authorization", auth).user.id));
|
|
923
925
|
await this.storage.setAccountType("bot");
|
|
924
926
|
break;
|
|
@@ -933,9 +935,9 @@ class Client extends Composer {
|
|
|
933
935
|
}
|
|
934
936
|
}
|
|
935
937
|
}
|
|
936
|
-
|
|
937
|
-
await
|
|
938
|
-
await
|
|
938
|
+
this.#LsignIn.debug("authorized as bot");
|
|
939
|
+
await this.#propagateAuthorizationState(true);
|
|
940
|
+
await this.#updateManager.fetchState("authorize");
|
|
939
941
|
return;
|
|
940
942
|
}
|
|
941
943
|
auth: while (true) {
|
|
@@ -948,8 +950,8 @@ class Client extends Composer {
|
|
|
948
950
|
const sendCode = () => this.invoke({
|
|
949
951
|
_: "auth.sendCode",
|
|
950
952
|
phone_number: phone,
|
|
951
|
-
api_id:
|
|
952
|
-
api_hash:
|
|
953
|
+
api_id: this.#apiId,
|
|
954
|
+
api_hash: this.#apiHash,
|
|
953
955
|
settings: { _: "codeSettings" },
|
|
954
956
|
}).then((v) => _2_tl_js_1.Api.as("auth.sentCode", v));
|
|
955
957
|
try {
|
|
@@ -969,281 +971,150 @@ class Client extends Composer {
|
|
|
969
971
|
catch (err) {
|
|
970
972
|
if (err instanceof _4_errors_js_1.PhoneNumberInvalid) {
|
|
971
973
|
continue;
|
|
972
|
-
}
|
|
973
|
-
else {
|
|
974
|
-
throw err;
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
__classPrivateFieldGet(this, _Client_LsignIn, "f").debug("verification code sent");
|
|
979
|
-
let err;
|
|
980
|
-
code: while (true) {
|
|
981
|
-
const code = typeof params.code === "string" ? params.code : await params.code();
|
|
982
|
-
try {
|
|
983
|
-
const auth = await this.invoke({
|
|
984
|
-
_: "auth.signIn",
|
|
985
|
-
phone_number: phone,
|
|
986
|
-
phone_code: code,
|
|
987
|
-
phone_code_hash: sentCode.phone_code_hash,
|
|
988
|
-
});
|
|
989
|
-
await this.storage.setAccountId(Number(_2_tl_js_1.Api.as("auth.authorization", auth).user.id));
|
|
990
|
-
await this.storage.setAccountType("user");
|
|
991
|
-
__classPrivateFieldGet(this, _Client_LsignIn, "f").debug("signed in as user");
|
|
992
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
|
|
993
|
-
await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("signIn");
|
|
994
|
-
return;
|
|
995
|
-
}
|
|
996
|
-
catch (err_) {
|
|
997
|
-
if (err_ instanceof _4_errors_js_2.PhoneCodeInvalid) {
|
|
998
|
-
continue code;
|
|
999
|
-
}
|
|
1000
|
-
else {
|
|
1001
|
-
err = err_;
|
|
1002
|
-
break code;
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
if (!(err instanceof _4_errors_js_1.SessionPasswordNeeded)) {
|
|
1007
|
-
throw err;
|
|
1008
|
-
}
|
|
1009
|
-
password: while (true) {
|
|
1010
|
-
const ap = await this.invoke({ _: "account.getPassword" });
|
|
1011
|
-
if (!(_2_tl_js_1.Api.is("passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow", ap.current_algo))) {
|
|
1012
|
-
throw new Error(`Handling ${ap.current_algo?._} not implemented`);
|
|
1013
|
-
}
|
|
1014
|
-
try {
|
|
1015
|
-
const password = typeof params.password === "string" ? params.password : await params.password(ap.hint ?? null);
|
|
1016
|
-
const input = await (0, _0_password_js_1.checkPassword)(password, ap);
|
|
1017
|
-
const auth = await this.invoke({ _: "auth.checkPassword", password: input });
|
|
1018
|
-
await this.storage.setAccountId(Number(_2_tl_js_1.Api.as("auth.authorization", auth).user.id));
|
|
1019
|
-
await this.storage.setAccountType("user");
|
|
1020
|
-
__classPrivateFieldGet(this, _Client_LsignIn, "f").debug("signed in as user");
|
|
1021
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
|
|
1022
|
-
await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("signIn");
|
|
1023
|
-
return;
|
|
1024
|
-
}
|
|
1025
|
-
catch (err) {
|
|
1026
|
-
if (err instanceof _4_errors_js_1.PasswordHashInvalid) {
|
|
1027
|
-
continue password;
|
|
1028
|
-
}
|
|
1029
|
-
else {
|
|
1030
|
-
throw err;
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
catch (err) {
|
|
1036
|
-
if (err == exports.restartAuth) {
|
|
1037
|
-
continue auth;
|
|
1038
|
-
}
|
|
1039
|
-
else {
|
|
1040
|
-
throw err;
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
async signOut() {
|
|
1046
|
-
try {
|
|
1047
|
-
await Promise.all([
|
|
1048
|
-
this.storage.reset(),
|
|
1049
|
-
this.invoke({ _: "auth.logOut" }).then(() => {
|
|
1050
|
-
__classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, false);
|
|
1051
|
-
}),
|
|
1052
|
-
]);
|
|
1053
|
-
}
|
|
1054
|
-
finally {
|
|
1055
|
-
__classPrivateFieldSet(this, _Client_lastGetMe, null, "f");
|
|
1056
|
-
this.disconnect();
|
|
1057
|
-
await this.connect();
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
/**
|
|
1061
|
-
* Same as calling `.connect()` followed by `.signIn(params)`.
|
|
1062
|
-
*/
|
|
1063
|
-
async start(params) {
|
|
1064
|
-
await this.connect();
|
|
1065
|
-
await this.signIn(params);
|
|
1066
|
-
}
|
|
1067
|
-
exportAuthString() {
|
|
1068
|
-
return this.storage.exportAuthString(__classPrivateFieldGet(this, _Client_apiId, "f"));
|
|
1069
|
-
}
|
|
1070
|
-
async importAuthString(authString) {
|
|
1071
|
-
if (this.connected) {
|
|
1072
|
-
throw new Error("Cannot import auth string while the client is connected");
|
|
1073
|
-
}
|
|
1074
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initStorage).call(this);
|
|
1075
|
-
await this.storage.importAuthString(authString);
|
|
1076
|
-
__classPrivateFieldSet(this, _Client_authStringImported, true, "f");
|
|
1077
|
-
if (!__classPrivateFieldGet(this, _Client_apiId, "f")) {
|
|
1078
|
-
__classPrivateFieldSet(this, _Client_apiId, await this.storage.getApiId() ?? 0, "f");
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
/**
|
|
1082
|
-
* Get a chat's inputPeer. Useful when calling API functions directly.
|
|
1083
|
-
*
|
|
1084
|
-
* @param id The identifier of a chat.
|
|
1085
|
-
*/
|
|
1086
|
-
async getInputPeer(id) {
|
|
1087
|
-
if (id === "me" || id == await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getSelfId).call(this)) {
|
|
1088
|
-
return { _: "inputPeerSelf" };
|
|
1089
|
-
}
|
|
1090
|
-
const inputPeer = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getInputPeerInner).call(this, id);
|
|
1091
|
-
if (((_2_tl_js_1.Api.is("inputPeerUser", inputPeer) || _2_tl_js_1.Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash == 0n) && await this.storage.getAccountType() == "user") {
|
|
1092
|
-
if ("channel_id" in inputPeer) {
|
|
1093
|
-
inputPeer.access_hash = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChannelAccessHash).call(this, inputPeer.channel_id);
|
|
1094
|
-
}
|
|
1095
|
-
else {
|
|
1096
|
-
inputPeer.access_hash = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getUserAccessHash).call(this, inputPeer.user_id);
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
if ((_2_tl_js_1.Api.is("inputPeerUser", inputPeer) || _2_tl_js_1.Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash == 0n && await this.storage.getAccountType() == "user") {
|
|
1100
|
-
throw new _0_errors_js_1.AccessError(`Cannot access the chat ${id} because there is no access hash for it.`);
|
|
1101
|
-
}
|
|
1102
|
-
return inputPeer;
|
|
1103
|
-
}
|
|
1104
|
-
/**
|
|
1105
|
-
* Get a channel or a supergroup's inputChannel. Useful when calling API functions directly.
|
|
1106
|
-
*
|
|
1107
|
-
* @param id The identifier of the channel or the supergroup.
|
|
1108
|
-
*/
|
|
1109
|
-
async getInputChannel(id) {
|
|
1110
|
-
const inputPeer = await this.getInputPeer(id);
|
|
1111
|
-
if (!(0, _0_utilities_js_1.canBeInputChannel)(inputPeer)) {
|
|
1112
|
-
throw new TypeError(`The chat ${id} is not a channel neither a supergroup.`);
|
|
1113
|
-
}
|
|
1114
|
-
return (0, _0_utilities_js_1.toInputChannel)(inputPeer);
|
|
1115
|
-
}
|
|
1116
|
-
/**
|
|
1117
|
-
* Get a user's inputUser. Useful when calling API functions directly.
|
|
1118
|
-
*
|
|
1119
|
-
* @param id The identifier of the user.
|
|
1120
|
-
*/
|
|
1121
|
-
async getInputUser(id) {
|
|
1122
|
-
const inputPeer = await this.getInputPeer(id);
|
|
1123
|
-
if (!(0, _0_utilities_js_1.canBeInputUser)(inputPeer)) {
|
|
1124
|
-
throw new TypeError(`The chat ${id} is not a private chat.`);
|
|
1125
|
-
}
|
|
1126
|
-
return (0, _0_utilities_js_1.toInputUser)(inputPeer);
|
|
1127
|
-
}
|
|
1128
|
-
async [(_Client_propagateAuthorizationState = async function _Client_propagateAuthorizationState(authorized) {
|
|
1129
|
-
if (__classPrivateFieldGet(this, _Client_lastPropagatedAuthorizationState, "f") != authorized) {
|
|
1130
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, { authorizationState: { authorized } });
|
|
1131
|
-
__classPrivateFieldSet(this, _Client_lastPropagatedAuthorizationState, authorized, "f");
|
|
1132
|
-
}
|
|
1133
|
-
}, _Client_getSelfId = async function _Client_getSelfId() {
|
|
1134
|
-
const id = await this.storage.getAccountId();
|
|
1135
|
-
if (id == null) {
|
|
1136
|
-
throw new Error("Unauthorized");
|
|
1137
|
-
}
|
|
1138
|
-
return id;
|
|
1139
|
-
}, _Client_getIsPremium = async function _Client_getIsPremium() {
|
|
1140
|
-
const maybeIsPremium = await this.storage.getIsPremium();
|
|
1141
|
-
if (maybeIsPremium != null) {
|
|
1142
|
-
return maybeIsPremium;
|
|
1143
|
-
}
|
|
1144
|
-
return __classPrivateFieldGet(this, _Client_lastGetMe, "f")?.isPremium ?? false;
|
|
1145
|
-
}, _Client_startUpdateGapRecoveryLoop = function _Client_startUpdateGapRecoveryLoop() {
|
|
1146
|
-
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_instances, "m", _Client_updateGapRecoveryLoop).call(this));
|
|
1147
|
-
}, _Client_updateGapRecoveryLoop = async function _Client_updateGapRecoveryLoop() {
|
|
1148
|
-
__classPrivateFieldGet(this, _Client_updateGapRecoveryLoopAbortController, "f")?.abort();
|
|
1149
|
-
const controller = __classPrivateFieldSet(this, _Client_updateGapRecoveryLoopAbortController, new AbortController(), "f");
|
|
1150
|
-
while (this.connected) {
|
|
1151
|
-
try {
|
|
1152
|
-
await (0, _0_deps_js_1.delay)(60 * _0_deps_js_1.SECOND, { signal: controller.signal });
|
|
1153
|
-
if (!this.connected) {
|
|
1154
|
-
break;
|
|
1155
|
-
}
|
|
1156
|
-
controller.signal.throwIfAborted();
|
|
1157
|
-
if (Date.now() - __classPrivateFieldGet(this, _Client_lastUpdates, "f").getTime() >= 15 * _0_deps_js_1.MINUTE) {
|
|
1158
|
-
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("lastUpdates").then(() => {
|
|
1159
|
-
__classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
|
|
1160
|
-
}));
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1163
|
-
catch (err) {
|
|
1164
|
-
if (err instanceof DOMException && err.name == "AbortError") {
|
|
1165
|
-
break;
|
|
974
|
+
}
|
|
975
|
+
else {
|
|
976
|
+
throw err;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
1166
979
|
}
|
|
1167
|
-
|
|
1168
|
-
|
|
980
|
+
this.#LsignIn.debug("verification code sent");
|
|
981
|
+
let err;
|
|
982
|
+
code: while (true) {
|
|
983
|
+
const code = typeof params.code === "string" ? params.code : await params.code();
|
|
984
|
+
try {
|
|
985
|
+
const auth = await this.invoke({
|
|
986
|
+
_: "auth.signIn",
|
|
987
|
+
phone_number: phone,
|
|
988
|
+
phone_code: code,
|
|
989
|
+
phone_code_hash: sentCode.phone_code_hash,
|
|
990
|
+
});
|
|
991
|
+
await this.storage.setAccountId(Number(_2_tl_js_1.Api.as("auth.authorization", auth).user.id));
|
|
992
|
+
await this.storage.setAccountType("user");
|
|
993
|
+
this.#LsignIn.debug("signed in as user");
|
|
994
|
+
await this.#propagateAuthorizationState(true);
|
|
995
|
+
await this.#updateManager.fetchState("signIn");
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
catch (err_) {
|
|
999
|
+
if (err_ instanceof _4_errors_js_2.PhoneCodeInvalid) {
|
|
1000
|
+
continue code;
|
|
1001
|
+
}
|
|
1002
|
+
else {
|
|
1003
|
+
err = err_;
|
|
1004
|
+
break code;
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1169
1007
|
}
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
}
|
|
1173
|
-
}, _Client_startClientDisconnectionLoop = function _Client_startClientDisconnectionLoop() {
|
|
1174
|
-
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_instances, "m", _Client_clientDisconnectionLoop).call(this));
|
|
1175
|
-
}, _Client_clientDisconnectionLoop = async function _Client_clientDisconnectionLoop() {
|
|
1176
|
-
const controller = __classPrivateFieldSet(this, _Client_clientDisconnectionLoopAbortController, new AbortController(), "f");
|
|
1177
|
-
while (this.connected) {
|
|
1178
|
-
try {
|
|
1179
|
-
await (0, _0_deps_js_1.delay)(60 * _0_deps_js_1.SECOND, { signal: controller.signal });
|
|
1180
|
-
if (!this.connected) {
|
|
1181
|
-
break;
|
|
1008
|
+
if (!(err instanceof _4_errors_js_1.SessionPasswordNeeded)) {
|
|
1009
|
+
throw err;
|
|
1182
1010
|
}
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
if (i > 0 && !client.disconnected && client.lastRequest && now - client.lastRequest.getTime() >= disconnectAfter) {
|
|
1188
|
-
client?.disconnect();
|
|
1011
|
+
password: while (true) {
|
|
1012
|
+
const ap = await this.invoke({ _: "account.getPassword" });
|
|
1013
|
+
if (!(_2_tl_js_1.Api.is("passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow", ap.current_algo))) {
|
|
1014
|
+
throw new Error(`Handling ${ap.current_algo?._} not implemented`);
|
|
1189
1015
|
}
|
|
1190
|
-
|
|
1016
|
+
try {
|
|
1017
|
+
const password = typeof params.password === "string" ? params.password : await params.password(ap.hint ?? null);
|
|
1018
|
+
const input = await (0, _0_password_js_1.checkPassword)(password, ap);
|
|
1019
|
+
const auth = await this.invoke({ _: "auth.checkPassword", password: input });
|
|
1020
|
+
await this.storage.setAccountId(Number(_2_tl_js_1.Api.as("auth.authorization", auth).user.id));
|
|
1021
|
+
await this.storage.setAccountType("user");
|
|
1022
|
+
this.#LsignIn.debug("signed in as user");
|
|
1023
|
+
await this.#propagateAuthorizationState(true);
|
|
1024
|
+
await this.#updateManager.fetchState("signIn");
|
|
1025
|
+
return;
|
|
1026
|
+
}
|
|
1027
|
+
catch (err) {
|
|
1028
|
+
if (err instanceof _4_errors_js_1.PasswordHashInvalid) {
|
|
1029
|
+
continue password;
|
|
1030
|
+
}
|
|
1031
|
+
else {
|
|
1032
|
+
throw err;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1191
1036
|
}
|
|
1192
1037
|
catch (err) {
|
|
1193
|
-
if (err
|
|
1194
|
-
|
|
1038
|
+
if (err == exports.restartAuth) {
|
|
1039
|
+
continue auth;
|
|
1195
1040
|
}
|
|
1196
|
-
else
|
|
1197
|
-
|
|
1041
|
+
else {
|
|
1042
|
+
throw err;
|
|
1198
1043
|
}
|
|
1199
1044
|
}
|
|
1200
1045
|
}
|
|
1201
|
-
}
|
|
1046
|
+
}
|
|
1047
|
+
async signOut() {
|
|
1048
|
+
try {
|
|
1049
|
+
await Promise.all([
|
|
1050
|
+
this.storage.reset(),
|
|
1051
|
+
this.invoke({ _: "auth.logOut" }).then(() => {
|
|
1052
|
+
this.#propagateAuthorizationState(false);
|
|
1053
|
+
}),
|
|
1054
|
+
]);
|
|
1055
|
+
}
|
|
1056
|
+
finally {
|
|
1057
|
+
this.#lastGetMe = null;
|
|
1058
|
+
this.disconnect();
|
|
1059
|
+
await this.connect();
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
/**
|
|
1063
|
+
* Same as calling `.connect()` followed by `.signIn(params)`.
|
|
1064
|
+
*/
|
|
1065
|
+
async start(params) {
|
|
1066
|
+
await this.connect();
|
|
1067
|
+
await this.signIn(params);
|
|
1068
|
+
}
|
|
1069
|
+
async #getClient(params) {
|
|
1202
1070
|
let client;
|
|
1203
1071
|
switch (params.type) {
|
|
1204
1072
|
case undefined:
|
|
1205
|
-
client = await
|
|
1073
|
+
client = await this.#getMainClient(params.dc);
|
|
1206
1074
|
break;
|
|
1207
1075
|
case "download":
|
|
1208
|
-
client = await
|
|
1076
|
+
client = await this.#getDownloadClient(params.dc);
|
|
1209
1077
|
break;
|
|
1210
1078
|
case "upload":
|
|
1211
|
-
client = await
|
|
1079
|
+
client = await this.#getUploadClient();
|
|
1212
1080
|
break;
|
|
1213
1081
|
}
|
|
1214
|
-
if (client !==
|
|
1082
|
+
if (client !== this.#client && !this.disconnected && client.disconnected) {
|
|
1215
1083
|
await client.connect();
|
|
1216
1084
|
}
|
|
1217
1085
|
return client;
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
|
|
1086
|
+
}
|
|
1087
|
+
#getMainClientMutex = new _1_utilities_js_1.Mutex();
|
|
1088
|
+
async #getMainClient(dc) {
|
|
1089
|
+
if (dc === undefined || dc == this.#client?.dc) {
|
|
1090
|
+
return this.#client;
|
|
1221
1091
|
}
|
|
1222
|
-
let client =
|
|
1092
|
+
let client = this.#clients.find((v) => v.dc == dc);
|
|
1223
1093
|
if (client) {
|
|
1224
1094
|
return client;
|
|
1225
1095
|
}
|
|
1226
|
-
const unlock = await
|
|
1227
|
-
client =
|
|
1096
|
+
const unlock = await this.#getMainClientMutex.lock();
|
|
1097
|
+
client = this.#clients.find((v) => v.dc == dc);
|
|
1228
1098
|
if (client) {
|
|
1229
1099
|
return client;
|
|
1230
1100
|
}
|
|
1231
1101
|
try {
|
|
1232
|
-
client =
|
|
1233
|
-
await
|
|
1234
|
-
|
|
1102
|
+
client = this.#newClient(dc, false, false);
|
|
1103
|
+
await this.#setupClient(client);
|
|
1104
|
+
this.#clients.push(client);
|
|
1235
1105
|
return client;
|
|
1236
1106
|
}
|
|
1237
1107
|
finally {
|
|
1238
1108
|
unlock();
|
|
1239
1109
|
}
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
|
|
1110
|
+
}
|
|
1111
|
+
async #getDownloadClient(dc) {
|
|
1112
|
+
dc ??= this.#client.dc;
|
|
1113
|
+
const pool = this.#downloadPools[dc] ??= new _3_client_encrypted_pool_js_1.ClientEncryptedPool();
|
|
1243
1114
|
if (!pool.size) {
|
|
1244
1115
|
if (!pool.size) {
|
|
1245
1116
|
for (let i = 0; i < _0_utilities_js_1.DOWNLOAD_POOL_SIZE; ++i) {
|
|
1246
|
-
pool.add(
|
|
1117
|
+
pool.add(this.#newClient(dc, false, true));
|
|
1247
1118
|
}
|
|
1248
1119
|
}
|
|
1249
1120
|
}
|
|
@@ -1251,28 +1122,31 @@ class Client extends Composer {
|
|
|
1251
1122
|
if (client.authKey.length) {
|
|
1252
1123
|
return client;
|
|
1253
1124
|
}
|
|
1254
|
-
await
|
|
1125
|
+
await this.#setupClient(client);
|
|
1255
1126
|
return client;
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
const
|
|
1127
|
+
}
|
|
1128
|
+
async #getUploadPoolSize() {
|
|
1129
|
+
const dc = this.#client.dc;
|
|
1130
|
+
return (dc != "2" && dc != "4") || await this.#getIsPremium() ? 8 : 4;
|
|
1131
|
+
}
|
|
1132
|
+
async #getUploadClient() {
|
|
1133
|
+
const dc = this.#client.dc;
|
|
1134
|
+
const poolSize = await this.#getUploadPoolSize();
|
|
1135
|
+
const pool = this.#uploadPools[dc] ??= new _3_client_encrypted_pool_js_1.ClientEncryptedPool();
|
|
1263
1136
|
if (!pool.size) {
|
|
1264
1137
|
for (let i = 0; i < poolSize; ++i) {
|
|
1265
|
-
pool.add(await
|
|
1138
|
+
pool.add(await this.#newClient(dc, false, true));
|
|
1266
1139
|
}
|
|
1267
1140
|
}
|
|
1268
1141
|
const client = pool.nextClient();
|
|
1269
1142
|
if (client.authKey.length) {
|
|
1270
1143
|
return client;
|
|
1271
1144
|
}
|
|
1272
|
-
await
|
|
1145
|
+
await this.#setupClient(client);
|
|
1273
1146
|
return client;
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1147
|
+
}
|
|
1148
|
+
async #setupClient(client) {
|
|
1149
|
+
const storage = client.dc == this.#client.dc ? this.storage : new _0_storage_operations_js_1.StorageOperations(this.storage.provider.branch(client.dc + (client.cdn ? "_cdn" : "")));
|
|
1276
1150
|
const [authKey, serverSalt] = await Promise.all([storage.getAuthKey(), storage.getServerSalt()]);
|
|
1277
1151
|
if (authKey) {
|
|
1278
1152
|
await client.setAuthKey(authKey);
|
|
@@ -1282,17 +1156,18 @@ class Client extends Composer {
|
|
|
1282
1156
|
}
|
|
1283
1157
|
await client.connect();
|
|
1284
1158
|
if (!authKey) {
|
|
1285
|
-
await
|
|
1159
|
+
await this.#importAuthorization(client);
|
|
1286
1160
|
}
|
|
1287
1161
|
await storage.setAuthKey(client.authKey);
|
|
1288
|
-
if (client.dc !==
|
|
1162
|
+
if (client.dc !== this.#client.dc) {
|
|
1289
1163
|
await storage.setServerSalt(client.serverSalt);
|
|
1290
1164
|
client.handlers.onNewServerSalt = async (serverSalt) => {
|
|
1291
1165
|
await storage.setServerSalt(serverSalt);
|
|
1292
1166
|
};
|
|
1293
1167
|
}
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1168
|
+
}
|
|
1169
|
+
async #importAuthorization(client) {
|
|
1170
|
+
if (this.#client.dc == client.dc && this.#client.cdn == client.cdn) {
|
|
1296
1171
|
const [authKey, serverSalt] = await Promise.all([this.storage.getAuthKey(), this.storage.getServerSalt()]);
|
|
1297
1172
|
if (authKey) {
|
|
1298
1173
|
await client.setAuthKey(authKey);
|
|
@@ -1302,29 +1177,30 @@ class Client extends Composer {
|
|
|
1302
1177
|
}
|
|
1303
1178
|
return;
|
|
1304
1179
|
}
|
|
1305
|
-
const exportedAuthorization = await
|
|
1180
|
+
const exportedAuthorization = await this.#client.invoke({ _: "auth.exportAuthorization", dc_id: (0, _3_transport_js_1.getDcId)(client.dc, client.cdn) });
|
|
1306
1181
|
await client.invoke({ ...exportedAuthorization, _: "auth.importAuthorization" });
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1182
|
+
}
|
|
1183
|
+
async #invoke(function_, params) {
|
|
1184
|
+
if (!this.#client) {
|
|
1309
1185
|
throw new _0_errors_js_1.ConnectionError("Not connected.");
|
|
1310
1186
|
}
|
|
1311
1187
|
let n = 1;
|
|
1312
1188
|
let client;
|
|
1313
1189
|
while (true) {
|
|
1314
|
-
client = params ? await
|
|
1315
|
-
const main = client ===
|
|
1190
|
+
client = params ? await this.#getClient(params) : this.#client;
|
|
1191
|
+
const main = client === this.#client;
|
|
1316
1192
|
try {
|
|
1317
1193
|
const result = await client.invoke(function_);
|
|
1318
1194
|
if (main) {
|
|
1319
1195
|
try {
|
|
1320
|
-
await
|
|
1196
|
+
await this.#updateManager.processResult(result);
|
|
1321
1197
|
}
|
|
1322
1198
|
catch (err) {
|
|
1323
|
-
|
|
1199
|
+
this.#L.error("failed to process result:", err);
|
|
1324
1200
|
}
|
|
1325
1201
|
if (_2_tl_js_1.Api.isOfEnum("Update", result) || _2_tl_js_1.Api.isOfEnum("Updates", result)) {
|
|
1326
1202
|
return new Promise((resolve) => {
|
|
1327
|
-
|
|
1203
|
+
this.#updateManager.processUpdates(result, true, _2_tl_js_1.Mtproto.is("ping", function_) ? null : function_, () => resolve(result));
|
|
1328
1204
|
});
|
|
1329
1205
|
}
|
|
1330
1206
|
}
|
|
@@ -1332,13 +1208,13 @@ class Client extends Composer {
|
|
|
1332
1208
|
}
|
|
1333
1209
|
catch (err) {
|
|
1334
1210
|
if (err instanceof _4_errors_js_1.AuthKeyUnregistered && !main) {
|
|
1335
|
-
await
|
|
1211
|
+
await this.#importAuthorization(client);
|
|
1336
1212
|
continue;
|
|
1337
1213
|
}
|
|
1338
1214
|
else if (err instanceof _0_errors_js_1.ConnectionError && !main && !this.disconnected) {
|
|
1339
1215
|
continue;
|
|
1340
1216
|
}
|
|
1341
|
-
else if (await
|
|
1217
|
+
else if (await this.#handleInvokeError(Object.freeze({ client: this, error: err, function: function_, n: n++ }), () => Promise.resolve(false))) {
|
|
1342
1218
|
continue;
|
|
1343
1219
|
}
|
|
1344
1220
|
else {
|
|
@@ -1346,23 +1222,85 @@ class Client extends Composer {
|
|
|
1346
1222
|
}
|
|
1347
1223
|
}
|
|
1348
1224
|
}
|
|
1349
|
-
}
|
|
1225
|
+
}
|
|
1226
|
+
#handleInvokeError = skipInvoke();
|
|
1227
|
+
/**
|
|
1228
|
+
* Invokes a function waiting and returning its reply if the second parameter is not `true`. Requires the client
|
|
1229
|
+
* to be connected.
|
|
1230
|
+
*
|
|
1231
|
+
* @param function_ The function to invoke.
|
|
1232
|
+
*/
|
|
1233
|
+
invoke = Object.assign(this.#invoke, {
|
|
1234
|
+
use: (handler) => {
|
|
1235
|
+
const handle = this.#handleInvokeError;
|
|
1236
|
+
this.#handleInvokeError = async (ctx, next) => {
|
|
1237
|
+
let result = null;
|
|
1238
|
+
return await handle(ctx, async () => {
|
|
1239
|
+
if (result != null)
|
|
1240
|
+
return result;
|
|
1241
|
+
result = await handler(ctx, next);
|
|
1242
|
+
return result;
|
|
1243
|
+
});
|
|
1244
|
+
};
|
|
1245
|
+
},
|
|
1246
|
+
});
|
|
1247
|
+
exportAuthString() {
|
|
1248
|
+
return this.storage.exportAuthString(this.#apiId);
|
|
1249
|
+
}
|
|
1250
|
+
#authStringImported = false;
|
|
1251
|
+
async importAuthString(authString) {
|
|
1252
|
+
if (this.connected) {
|
|
1253
|
+
throw new Error("Cannot import auth string while the client is connected");
|
|
1254
|
+
}
|
|
1255
|
+
await this.#initStorage();
|
|
1256
|
+
await this.storage.importAuthString(authString);
|
|
1257
|
+
this.#authStringImported = true;
|
|
1258
|
+
if (!this.#apiId) {
|
|
1259
|
+
this.#apiId = await this.storage.getApiId() ?? 0;
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
async #getUserAccessHash(userId) {
|
|
1350
1263
|
const users = await this.invoke({ _: "users.getUsers", id: [{ _: "inputUser", user_id: userId, access_hash: 0n }] });
|
|
1351
1264
|
const user = _2_tl_js_1.Api.is("user", users[0]) ? users[0] : undefined;
|
|
1352
1265
|
if (user) {
|
|
1353
1266
|
await this.messageStorage.setEntity(user);
|
|
1354
1267
|
}
|
|
1355
1268
|
return user?.access_hash ?? 0n;
|
|
1356
|
-
}
|
|
1269
|
+
}
|
|
1270
|
+
async #getChannelAccessHash(channelId) {
|
|
1357
1271
|
const channels = await this.invoke({ _: "channels.getChannels", id: [{ _: "inputChannel", channel_id: channelId, access_hash: 0n }] });
|
|
1358
1272
|
const channel = _2_tl_js_1.Api.is("channel", channels.chats[0]) ? channels.chats[0] : undefined;
|
|
1359
1273
|
if (channel) {
|
|
1360
1274
|
await this.messageStorage.setEntity(channel);
|
|
1361
1275
|
}
|
|
1362
1276
|
return channel?.access_hash ?? 0n;
|
|
1363
|
-
}
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Get a chat's inputPeer. Useful when calling API functions directly.
|
|
1280
|
+
*
|
|
1281
|
+
* @param id The identifier of a chat.
|
|
1282
|
+
*/
|
|
1283
|
+
async getInputPeer(id) {
|
|
1284
|
+
if (id === "me" || id == await this.#getSelfId()) {
|
|
1285
|
+
return { _: "inputPeerSelf" };
|
|
1286
|
+
}
|
|
1287
|
+
const inputPeer = await this.#getInputPeerInner(id);
|
|
1288
|
+
if (((_2_tl_js_1.Api.is("inputPeerUser", inputPeer) || _2_tl_js_1.Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash == 0n) && await this.storage.getAccountType() == "bot") {
|
|
1289
|
+
if ("channel_id" in inputPeer) {
|
|
1290
|
+
inputPeer.access_hash = await this.#getChannelAccessHash(inputPeer.channel_id);
|
|
1291
|
+
}
|
|
1292
|
+
else {
|
|
1293
|
+
inputPeer.access_hash = await this.#getUserAccessHash(inputPeer.user_id);
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
if ((_2_tl_js_1.Api.is("inputPeerUser", inputPeer) || _2_tl_js_1.Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash == 0n) {
|
|
1297
|
+
throw new _0_errors_js_1.AccessError(`Cannot access the chat ${id} because there is no access hash for it.`);
|
|
1298
|
+
}
|
|
1299
|
+
return inputPeer;
|
|
1300
|
+
}
|
|
1301
|
+
async #getInputPeerChatId(inputPeer) {
|
|
1364
1302
|
if (_2_tl_js_1.Api.isOneOf(["inputPeerSelf", "inputUserSelf"], inputPeer)) {
|
|
1365
|
-
return await
|
|
1303
|
+
return await this.#getSelfId();
|
|
1366
1304
|
}
|
|
1367
1305
|
else if (_2_tl_js_1.Api.isOneOf(["inputPeerEmpty", "inputUserEmpty", "inputChannelEmpty"], inputPeer)) {
|
|
1368
1306
|
(0, _0_deps_js_1.unreachable)();
|
|
@@ -1370,7 +1308,32 @@ class Client extends Composer {
|
|
|
1370
1308
|
else {
|
|
1371
1309
|
return _2_tl_js_1.Api.peerToChatId(inputPeer);
|
|
1372
1310
|
}
|
|
1373
|
-
}
|
|
1311
|
+
}
|
|
1312
|
+
/**
|
|
1313
|
+
* Get a channel or a supergroup's inputChannel. Useful when calling API functions directly.
|
|
1314
|
+
*
|
|
1315
|
+
* @param id The identifier of the channel or the supergroup.
|
|
1316
|
+
*/
|
|
1317
|
+
async getInputChannel(id) {
|
|
1318
|
+
const inputPeer = await this.getInputPeer(id);
|
|
1319
|
+
if (!(0, _0_utilities_js_1.canBeInputChannel)(inputPeer)) {
|
|
1320
|
+
throw new TypeError(`The chat ${id} is not a channel neither a supergroup.`);
|
|
1321
|
+
}
|
|
1322
|
+
return (0, _0_utilities_js_1.toInputChannel)(inputPeer);
|
|
1323
|
+
}
|
|
1324
|
+
/**
|
|
1325
|
+
* Get a user's inputUser. Useful when calling API functions directly.
|
|
1326
|
+
*
|
|
1327
|
+
* @param id The identifier of the user.
|
|
1328
|
+
*/
|
|
1329
|
+
async getInputUser(id) {
|
|
1330
|
+
const inputPeer = await this.getInputPeer(id);
|
|
1331
|
+
if (!(0, _0_utilities_js_1.canBeInputUser)(inputPeer)) {
|
|
1332
|
+
throw new TypeError(`The chat ${id} is not a private chat.`);
|
|
1333
|
+
}
|
|
1334
|
+
return (0, _0_utilities_js_1.toInputUser)(inputPeer);
|
|
1335
|
+
}
|
|
1336
|
+
async #getInputPeerInner(id) {
|
|
1374
1337
|
const idn = Number(id);
|
|
1375
1338
|
if (!isNaN(idn)) {
|
|
1376
1339
|
id = idn;
|
|
@@ -1386,8 +1349,8 @@ class Client extends Composer {
|
|
|
1386
1349
|
}
|
|
1387
1350
|
else {
|
|
1388
1351
|
const resolved = await this.invoke({ _: "contacts.resolveUsername", username: id });
|
|
1389
|
-
await
|
|
1390
|
-
await
|
|
1352
|
+
await this.#updateManager.processChats(resolved.chats, resolved);
|
|
1353
|
+
await this.#updateManager.processUsers(resolved.users, resolved);
|
|
1391
1354
|
if (_2_tl_js_1.Api.is("peerUser", resolved.peer)) {
|
|
1392
1355
|
resolvedId = _2_tl_js_1.Api.peerToChatId(resolved.peer);
|
|
1393
1356
|
}
|
|
@@ -1429,15 +1392,16 @@ class Client extends Composer {
|
|
|
1429
1392
|
const chatId = _2_tl_js_1.Api.peerToChatId(peer);
|
|
1430
1393
|
const minPeerReference = await this.messageStorage.getLastMinPeerReference(chatId);
|
|
1431
1394
|
if (minPeerReference) {
|
|
1432
|
-
const minInputPeer = await
|
|
1395
|
+
const minInputPeer = await this.#getMinInputPeer((0, _0_utilities_js_1.canBeInputChannel)(peer) ? "channel" : "user", { ...minPeerReference, senderId: chatId });
|
|
1433
1396
|
if (minInputPeer) {
|
|
1434
|
-
|
|
1397
|
+
this.#Lmin.debug("resolved input min peer", minInputPeer);
|
|
1435
1398
|
peer = minInputPeer;
|
|
1436
1399
|
}
|
|
1437
1400
|
}
|
|
1438
1401
|
}
|
|
1439
1402
|
return peer;
|
|
1440
|
-
}
|
|
1403
|
+
}
|
|
1404
|
+
async #getMinInputPeer(type, reference) {
|
|
1441
1405
|
const entity = await this.messageStorage.getEntity(reference.chatId);
|
|
1442
1406
|
if (_2_tl_js_1.Api.isOneOf(["channel", "channelForbidden"], entity) && entity.access_hash) {
|
|
1443
1407
|
const peer = { _: "inputPeerChannel", channel_id: entity.id, access_hash: entity.access_hash };
|
|
@@ -1451,7 +1415,8 @@ class Client extends Composer {
|
|
|
1451
1415
|
else {
|
|
1452
1416
|
return null;
|
|
1453
1417
|
}
|
|
1454
|
-
}
|
|
1418
|
+
}
|
|
1419
|
+
async [getEntity](peer) {
|
|
1455
1420
|
const id = _2_tl_js_1.Api.peerToChatId(peer);
|
|
1456
1421
|
const entity = await this.messageStorage.getEntity(id);
|
|
1457
1422
|
if (entity == null && await this.storage.getAccountType() == "bot" && _2_tl_js_1.Api.is("peerUser", peer) || _2_tl_js_1.Api.is("peerChannel", peer)) {
|
|
@@ -1462,6 +1427,131 @@ class Client extends Composer {
|
|
|
1462
1427
|
}
|
|
1463
1428
|
return await this.messageStorage.getEntity(id);
|
|
1464
1429
|
}
|
|
1430
|
+
async #handleCtxUpdate(update) {
|
|
1431
|
+
if (this.#disableUpdates && !("authorizationState" in update) && !("connectionState" in update)) {
|
|
1432
|
+
return;
|
|
1433
|
+
}
|
|
1434
|
+
try {
|
|
1435
|
+
await this.middleware()(await this.#constructContext(update), _0_utilities_js_1.resolve);
|
|
1436
|
+
}
|
|
1437
|
+
catch (err) {
|
|
1438
|
+
this.#L.error("Failed to handle update:", err);
|
|
1439
|
+
throw err;
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
#queueHandleCtxUpdate(update) {
|
|
1443
|
+
this.#updateManager.getHandleUpdateQueue(_2_update_manager_js_1.UpdateManager.MAIN_BOX_ID).add(async () => {
|
|
1444
|
+
await this.#handleCtxUpdate(update);
|
|
1445
|
+
});
|
|
1446
|
+
}
|
|
1447
|
+
async #handleUpdate(update) {
|
|
1448
|
+
const promises = new Array();
|
|
1449
|
+
if (_2_tl_js_1.Api.is("updateUserName", update)) {
|
|
1450
|
+
await this.messageStorage.updateUsernames(Number(update.user_id), update.usernames.map((v) => v.username));
|
|
1451
|
+
const peer = { ...update, _: "peerUser" };
|
|
1452
|
+
const entity = await this[getEntity](peer);
|
|
1453
|
+
if (entity != null) {
|
|
1454
|
+
entity.usernames = update.usernames;
|
|
1455
|
+
entity.first_name = update.first_name;
|
|
1456
|
+
entity.last_name = update.last_name;
|
|
1457
|
+
await this.messageStorage.setEntity(entity);
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
if (this.#messageManager.canHandleUpdate(update)) {
|
|
1461
|
+
promises.push(() => this.#messageManager.handleUpdate(update));
|
|
1462
|
+
}
|
|
1463
|
+
if (this.#chatManager.canHandleUpdate(update)) {
|
|
1464
|
+
promises.push(() => this.#chatManager.handleUpdate(update));
|
|
1465
|
+
}
|
|
1466
|
+
if (this.#pollManager.canHandleUpdate(update)) {
|
|
1467
|
+
promises.push(() => this.#pollManager.handleUpdate(update));
|
|
1468
|
+
}
|
|
1469
|
+
if (this.#videoChatManager.canHandleUpdate(update)) {
|
|
1470
|
+
promises.push(() => this.#videoChatManager.handleUpdate(update));
|
|
1471
|
+
}
|
|
1472
|
+
if (this.#callbackQueryManager.canHandleUpdate(update)) {
|
|
1473
|
+
promises.push(() => this.#callbackQueryManager.handleUpdate(update));
|
|
1474
|
+
}
|
|
1475
|
+
if (this.#inlineQueryManager.canHandleUpdate(update)) {
|
|
1476
|
+
promises.push(() => this.#inlineQueryManager.handleUpdate(update));
|
|
1477
|
+
}
|
|
1478
|
+
if (this.#linkPreviewManager.canHandleUpdate(update)) {
|
|
1479
|
+
promises.push(() => this.#linkPreviewManager.handleUpdate(update));
|
|
1480
|
+
}
|
|
1481
|
+
if (this.#reactionManager.canHandleUpdate(update)) {
|
|
1482
|
+
promises.push(() => this.#reactionManager.handleUpdate(update));
|
|
1483
|
+
}
|
|
1484
|
+
if (this.#chatListManager.canHandleUpdate(update)) {
|
|
1485
|
+
promises.push(() => this.#chatListManager.handleUpdate(update));
|
|
1486
|
+
}
|
|
1487
|
+
if (this.#storyManager.canHandleUpdate(update)) {
|
|
1488
|
+
promises.push(() => this.#storyManager.handleUpdate(update));
|
|
1489
|
+
}
|
|
1490
|
+
if (this.#businessConnectionManager.canHandleUpdate(update)) {
|
|
1491
|
+
promises.push(() => this.#businessConnectionManager.handleUpdate(update));
|
|
1492
|
+
}
|
|
1493
|
+
if (this.#storyManager.canHandleUpdate(update)) {
|
|
1494
|
+
promises.push(() => this.#storyManager.handleUpdate(update));
|
|
1495
|
+
}
|
|
1496
|
+
if (this.#paymentManager.canHandleUpdate(update)) {
|
|
1497
|
+
promises.push(() => this.#paymentManager.handleUpdate(update));
|
|
1498
|
+
}
|
|
1499
|
+
if (this.#translationsManager.canHandleUpdate(update)) {
|
|
1500
|
+
promises.push(() => this.#translationsManager.handleUpdate(update));
|
|
1501
|
+
}
|
|
1502
|
+
return () => Promise.resolve().then(async () => {
|
|
1503
|
+
const updates = new Array();
|
|
1504
|
+
for (const promise of promises) {
|
|
1505
|
+
try {
|
|
1506
|
+
const update = await promise();
|
|
1507
|
+
if (update) {
|
|
1508
|
+
updates.push(update);
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
catch (err) {
|
|
1512
|
+
this.#L.error("failed to construct update:", err);
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
for (const update of updates) {
|
|
1516
|
+
try {
|
|
1517
|
+
await this.#handleCtxUpdate(update);
|
|
1518
|
+
}
|
|
1519
|
+
finally {
|
|
1520
|
+
if ("deletedMessages" in update) {
|
|
1521
|
+
for (const { chatId, messageId } of update.deletedMessages) {
|
|
1522
|
+
await this.messageStorage.setMessage(chatId, messageId, null);
|
|
1523
|
+
await this.#chatListManager.reassignChatLastMessage(chatId);
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
});
|
|
1529
|
+
}
|
|
1530
|
+
#lastGetMe = null;
|
|
1531
|
+
async #getMe() {
|
|
1532
|
+
if (this.#lastGetMe != null) {
|
|
1533
|
+
return this.#lastGetMe;
|
|
1534
|
+
}
|
|
1535
|
+
else {
|
|
1536
|
+
const user = await this.getMe();
|
|
1537
|
+
this.#lastGetMe = user;
|
|
1538
|
+
return user;
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
#previouslyConnected = false;
|
|
1542
|
+
#lastConnectionState = false;
|
|
1543
|
+
#onConnectionStateChange(connected) {
|
|
1544
|
+
if (this.#lastConnectionState != connected) {
|
|
1545
|
+
if (connected) {
|
|
1546
|
+
if (this.#previouslyConnected) {
|
|
1547
|
+
(0, _1_utilities_js_1.drop)(this.#updateManager.recoverUpdateGap("reconnect"));
|
|
1548
|
+
}
|
|
1549
|
+
this.#previouslyConnected = true;
|
|
1550
|
+
}
|
|
1551
|
+
const connectionState = connected ? "ready" : "notConnected";
|
|
1552
|
+
this.#queueHandleCtxUpdate({ connectionState });
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1465
1555
|
//
|
|
1466
1556
|
// ========================= ACCOUNT ========================= //
|
|
1467
1557
|
//
|
|
@@ -1471,7 +1561,7 @@ class Client extends Composer {
|
|
|
1471
1561
|
* @method ac
|
|
1472
1562
|
*/
|
|
1473
1563
|
async getMe() {
|
|
1474
|
-
let user_ = await this[getEntity]({ _: "peerUser", user_id: BigInt(await
|
|
1564
|
+
let user_ = await this[getEntity]({ _: "peerUser", user_id: BigInt(await this.#getSelfId()) });
|
|
1475
1565
|
if (user_ == null) {
|
|
1476
1566
|
const users = await this.invoke({ _: "users.getUsers", id: [{ _: "inputUserSelf" }] });
|
|
1477
1567
|
user_ = _2_tl_js_1.Api.as("user", users[0]);
|
|
@@ -1479,7 +1569,7 @@ class Client extends Composer {
|
|
|
1479
1569
|
await this.storage.setIsPremium(user_.premium ?? false);
|
|
1480
1570
|
}
|
|
1481
1571
|
const user = (0, _3_types_js_1.constructUser)(user_);
|
|
1482
|
-
|
|
1572
|
+
this.#lastGetMe = user;
|
|
1483
1573
|
return user;
|
|
1484
1574
|
}
|
|
1485
1575
|
/**
|
|
@@ -1490,7 +1580,7 @@ class Client extends Composer {
|
|
|
1490
1580
|
* @param username The username to show.
|
|
1491
1581
|
*/
|
|
1492
1582
|
async showUsername(id, username) {
|
|
1493
|
-
await
|
|
1583
|
+
await this.#accountManager.showUsername(id, username);
|
|
1494
1584
|
}
|
|
1495
1585
|
/**
|
|
1496
1586
|
* Hide a username from the current account, a bot account, a supergroup, or a channel's profile. User-only.
|
|
@@ -1500,7 +1590,7 @@ class Client extends Composer {
|
|
|
1500
1590
|
* @param username The username to hide.
|
|
1501
1591
|
*/
|
|
1502
1592
|
async hideUsername(id, username) {
|
|
1503
|
-
await
|
|
1593
|
+
await this.#accountManager.hideUsername(id, username);
|
|
1504
1594
|
}
|
|
1505
1595
|
/**
|
|
1506
1596
|
* Reorder the usernames of the current account, a bot account, a supergroup, or a channel's profile. User-only.
|
|
@@ -1511,7 +1601,7 @@ class Client extends Composer {
|
|
|
1511
1601
|
* @returns Whether the order was changed.
|
|
1512
1602
|
*/
|
|
1513
1603
|
async reorderUsernames(id, order) {
|
|
1514
|
-
return await
|
|
1604
|
+
return await this.#accountManager.reorderUsernames(id, order);
|
|
1515
1605
|
}
|
|
1516
1606
|
/**
|
|
1517
1607
|
* Hide all usernames from a supergroup or a channel's profile. User-only.
|
|
@@ -1520,7 +1610,7 @@ class Client extends Composer {
|
|
|
1520
1610
|
* @param id A supergroup ID or a channel ID.
|
|
1521
1611
|
*/
|
|
1522
1612
|
async hideUsernames(id) {
|
|
1523
|
-
return await
|
|
1613
|
+
return await this.#accountManager.hideUsernames(id);
|
|
1524
1614
|
}
|
|
1525
1615
|
/**
|
|
1526
1616
|
* Get a business connection. Bot-only.
|
|
@@ -1530,7 +1620,7 @@ class Client extends Composer {
|
|
|
1530
1620
|
* @cache
|
|
1531
1621
|
*/
|
|
1532
1622
|
async getBusinessConnection(id) {
|
|
1533
|
-
return await
|
|
1623
|
+
return await this.#businessConnectionManager.getBusinessConnection(id);
|
|
1534
1624
|
}
|
|
1535
1625
|
/**
|
|
1536
1626
|
* Set the current account's online status. User-only.
|
|
@@ -1539,7 +1629,7 @@ class Client extends Composer {
|
|
|
1539
1629
|
* @param online The new online status.
|
|
1540
1630
|
*/
|
|
1541
1631
|
async setOnline(online) {
|
|
1542
|
-
await
|
|
1632
|
+
await this.#accountManager.setOnline(online);
|
|
1543
1633
|
}
|
|
1544
1634
|
/**
|
|
1545
1635
|
* Set the current account's emoji status. User-only.
|
|
@@ -1548,7 +1638,7 @@ class Client extends Composer {
|
|
|
1548
1638
|
* @param id The identifier of the emoji to be used as the new status.
|
|
1549
1639
|
*/
|
|
1550
1640
|
async setEmojiStatus(id, params) {
|
|
1551
|
-
await
|
|
1641
|
+
await this.#accountManager.setEmojiStatus(id, params);
|
|
1552
1642
|
}
|
|
1553
1643
|
/**
|
|
1554
1644
|
* Set the emoji status of a bot's user. Bot-only.
|
|
@@ -1558,7 +1648,7 @@ class Client extends Composer {
|
|
|
1558
1648
|
* @param id The identifier of the emoji to be used as the new status.
|
|
1559
1649
|
*/
|
|
1560
1650
|
async setUserEmojiStatus(userId, id, params) {
|
|
1561
|
-
await
|
|
1651
|
+
await this.#accountManager.setUserEmojiStatus(userId, id, params);
|
|
1562
1652
|
}
|
|
1563
1653
|
/**
|
|
1564
1654
|
* Update the profile of the current user. At least one parameter must be specified. User-only.
|
|
@@ -1566,7 +1656,7 @@ class Client extends Composer {
|
|
|
1566
1656
|
* @method ac
|
|
1567
1657
|
*/
|
|
1568
1658
|
async updateProfile(params) {
|
|
1569
|
-
await
|
|
1659
|
+
await this.#accountManager.updateProfile(params);
|
|
1570
1660
|
}
|
|
1571
1661
|
/**
|
|
1572
1662
|
* Set the birthday of the current user. User-only.
|
|
@@ -1574,7 +1664,7 @@ class Client extends Composer {
|
|
|
1574
1664
|
* @method ac
|
|
1575
1665
|
*/
|
|
1576
1666
|
async setBirthday(params) {
|
|
1577
|
-
await
|
|
1667
|
+
await this.#accountManager.setBirthday(params);
|
|
1578
1668
|
}
|
|
1579
1669
|
/**
|
|
1580
1670
|
* Set the personal channel of the current user. User-only.
|
|
@@ -1582,7 +1672,7 @@ class Client extends Composer {
|
|
|
1582
1672
|
* @method ac
|
|
1583
1673
|
*/
|
|
1584
1674
|
async setPersonalChannel(params) {
|
|
1585
|
-
await
|
|
1675
|
+
await this.#accountManager.setPersonalChannel(params);
|
|
1586
1676
|
}
|
|
1587
1677
|
/**
|
|
1588
1678
|
* Set the name color of the current user. User-only.
|
|
@@ -1591,7 +1681,7 @@ class Client extends Composer {
|
|
|
1591
1681
|
* @param color The identifier of the color to set.
|
|
1592
1682
|
*/
|
|
1593
1683
|
async setNameColor(color, params) {
|
|
1594
|
-
await
|
|
1684
|
+
await this.#accountManager.setNameColor(color, params);
|
|
1595
1685
|
}
|
|
1596
1686
|
/**
|
|
1597
1687
|
* Set the profile color of the current user. User-only.
|
|
@@ -1600,7 +1690,7 @@ class Client extends Composer {
|
|
|
1600
1690
|
* @param color The identifier of the color to set.
|
|
1601
1691
|
*/
|
|
1602
1692
|
async setProfileColor(color, params) {
|
|
1603
|
-
await
|
|
1693
|
+
await this.#accountManager.setProfileColor(color, params);
|
|
1604
1694
|
}
|
|
1605
1695
|
/**
|
|
1606
1696
|
* Set the location of the current user. User-only.
|
|
@@ -1608,7 +1698,7 @@ class Client extends Composer {
|
|
|
1608
1698
|
* @method ac
|
|
1609
1699
|
*/
|
|
1610
1700
|
async setLocation(params) {
|
|
1611
|
-
await
|
|
1701
|
+
await this.#accountManager.setLocation(params);
|
|
1612
1702
|
}
|
|
1613
1703
|
//
|
|
1614
1704
|
// ========================= MESSAGES ========================= //
|
|
@@ -1622,7 +1712,7 @@ class Client extends Composer {
|
|
|
1622
1712
|
* @returns The sent text message.
|
|
1623
1713
|
*/
|
|
1624
1714
|
async sendMessage(chatId, text, params) {
|
|
1625
|
-
return await
|
|
1715
|
+
return await this.#messageManager.sendMessage(chatId, text, params);
|
|
1626
1716
|
}
|
|
1627
1717
|
/**
|
|
1628
1718
|
* Send a photo.
|
|
@@ -1633,7 +1723,7 @@ class Client extends Composer {
|
|
|
1633
1723
|
* @returns The sent photo.
|
|
1634
1724
|
*/
|
|
1635
1725
|
async sendPhoto(chatId, photo, params) {
|
|
1636
|
-
return await
|
|
1726
|
+
return await this.#messageManager.sendPhoto(chatId, photo, params);
|
|
1637
1727
|
}
|
|
1638
1728
|
/**
|
|
1639
1729
|
* Send a document.
|
|
@@ -1644,7 +1734,7 @@ class Client extends Composer {
|
|
|
1644
1734
|
* @returns The sent document.
|
|
1645
1735
|
*/
|
|
1646
1736
|
async sendDocument(chatId, document, params) {
|
|
1647
|
-
return await
|
|
1737
|
+
return await this.#messageManager.sendDocument(chatId, document, params);
|
|
1648
1738
|
}
|
|
1649
1739
|
/**
|
|
1650
1740
|
* Send a sticker.
|
|
@@ -1655,7 +1745,7 @@ class Client extends Composer {
|
|
|
1655
1745
|
* @returns The sent sticker.
|
|
1656
1746
|
*/
|
|
1657
1747
|
async sendSticker(chatId, sticker, params) {
|
|
1658
|
-
return await
|
|
1748
|
+
return await this.#messageManager.sendSticker(chatId, sticker, params);
|
|
1659
1749
|
}
|
|
1660
1750
|
/**
|
|
1661
1751
|
* Send a video.
|
|
@@ -1666,7 +1756,7 @@ class Client extends Composer {
|
|
|
1666
1756
|
* @returns The sent video.
|
|
1667
1757
|
*/
|
|
1668
1758
|
async sendVideo(chatId, video, params) {
|
|
1669
|
-
return await
|
|
1759
|
+
return await this.#messageManager.sendVideo(chatId, video, params);
|
|
1670
1760
|
}
|
|
1671
1761
|
/**
|
|
1672
1762
|
* Send an animation.
|
|
@@ -1677,7 +1767,7 @@ class Client extends Composer {
|
|
|
1677
1767
|
* @returns The sent animation.
|
|
1678
1768
|
*/
|
|
1679
1769
|
async sendAnimation(chatId, animation, params) {
|
|
1680
|
-
return await
|
|
1770
|
+
return await this.#messageManager.sendAnimation(chatId, animation, params);
|
|
1681
1771
|
}
|
|
1682
1772
|
/**
|
|
1683
1773
|
* Send a voice message.
|
|
@@ -1688,7 +1778,7 @@ class Client extends Composer {
|
|
|
1688
1778
|
* @returns The sent voice message.
|
|
1689
1779
|
*/
|
|
1690
1780
|
async sendVoice(chatId, voice, params) {
|
|
1691
|
-
return await
|
|
1781
|
+
return await this.#messageManager.sendVoice(chatId, voice, params);
|
|
1692
1782
|
}
|
|
1693
1783
|
/**
|
|
1694
1784
|
* Send an audio file.
|
|
@@ -1699,7 +1789,7 @@ class Client extends Composer {
|
|
|
1699
1789
|
* @returns The sent audio filr.
|
|
1700
1790
|
*/
|
|
1701
1791
|
async sendAudio(chatId, audio, params) {
|
|
1702
|
-
return await
|
|
1792
|
+
return await this.#messageManager.sendAudio(chatId, audio, params);
|
|
1703
1793
|
}
|
|
1704
1794
|
/**
|
|
1705
1795
|
* Send a media group.
|
|
@@ -1710,7 +1800,7 @@ class Client extends Composer {
|
|
|
1710
1800
|
* @returns The sent messages.
|
|
1711
1801
|
*/
|
|
1712
1802
|
async sendMediaGroup(chatId, media, params) {
|
|
1713
|
-
return await
|
|
1803
|
+
return await this.#messageManager.sendMediaGroup(chatId, media, params);
|
|
1714
1804
|
}
|
|
1715
1805
|
/**
|
|
1716
1806
|
* Send a video note.
|
|
@@ -1721,7 +1811,7 @@ class Client extends Composer {
|
|
|
1721
1811
|
* @returns The sent video note.
|
|
1722
1812
|
*/
|
|
1723
1813
|
async sendVideoNote(chatId, videoNote, params) {
|
|
1724
|
-
return await
|
|
1814
|
+
return await this.#messageManager.sendVideoNote(chatId, videoNote, params);
|
|
1725
1815
|
}
|
|
1726
1816
|
/**
|
|
1727
1817
|
* Send a location.
|
|
@@ -1733,7 +1823,7 @@ class Client extends Composer {
|
|
|
1733
1823
|
* @returns The sent location.
|
|
1734
1824
|
*/
|
|
1735
1825
|
async sendLocation(chatId, latitude, longitude, params) {
|
|
1736
|
-
return await
|
|
1826
|
+
return await this.#messageManager.sendLocation(chatId, latitude, longitude, params);
|
|
1737
1827
|
}
|
|
1738
1828
|
/**
|
|
1739
1829
|
* Send a contact.
|
|
@@ -1745,7 +1835,7 @@ class Client extends Composer {
|
|
|
1745
1835
|
* @returns The sent contact.
|
|
1746
1836
|
*/
|
|
1747
1837
|
async sendContact(chatId, firstName, number, params) {
|
|
1748
|
-
return await
|
|
1838
|
+
return await this.#messageManager.sendContact(chatId, firstName, number, params);
|
|
1749
1839
|
}
|
|
1750
1840
|
/**
|
|
1751
1841
|
* Send a dice.
|
|
@@ -1755,7 +1845,7 @@ class Client extends Composer {
|
|
|
1755
1845
|
* @returns The sent dice.
|
|
1756
1846
|
*/
|
|
1757
1847
|
async sendDice(chatId, params) {
|
|
1758
|
-
return await
|
|
1848
|
+
return await this.#messageManager.sendDice(chatId, params);
|
|
1759
1849
|
}
|
|
1760
1850
|
/**
|
|
1761
1851
|
* Send a venue.
|
|
@@ -1769,7 +1859,7 @@ class Client extends Composer {
|
|
|
1769
1859
|
* @returns The sent venue.
|
|
1770
1860
|
*/
|
|
1771
1861
|
async sendVenue(chatId, latitude, longitude, title, address, params) {
|
|
1772
|
-
return await
|
|
1862
|
+
return await this.#messageManager.sendVenue(chatId, latitude, longitude, title, address, params);
|
|
1773
1863
|
}
|
|
1774
1864
|
/**
|
|
1775
1865
|
* Send a poll.
|
|
@@ -1781,7 +1871,7 @@ class Client extends Composer {
|
|
|
1781
1871
|
* @returns The sent poll.
|
|
1782
1872
|
*/
|
|
1783
1873
|
async sendPoll(chatId, question, options, params) {
|
|
1784
|
-
return await
|
|
1874
|
+
return await this.#messageManager.sendPoll(chatId, question, options, params);
|
|
1785
1875
|
}
|
|
1786
1876
|
/**
|
|
1787
1877
|
* Send an invoice. Bot-only.
|
|
@@ -1796,7 +1886,7 @@ class Client extends Composer {
|
|
|
1796
1886
|
* @returns The sent invoice.
|
|
1797
1887
|
*/
|
|
1798
1888
|
async sendInvoice(chatId, title, description, payload, currency, prices, params) {
|
|
1799
|
-
return await
|
|
1889
|
+
return await this.#messageManager.sendInvoice(chatId, title, description, payload, currency, prices, params);
|
|
1800
1890
|
}
|
|
1801
1891
|
/**
|
|
1802
1892
|
* Edit a message's text.
|
|
@@ -1808,7 +1898,7 @@ class Client extends Composer {
|
|
|
1808
1898
|
* @returns The edited text message.
|
|
1809
1899
|
*/
|
|
1810
1900
|
async editMessageText(chatId, messageId, text, params) {
|
|
1811
|
-
return await
|
|
1901
|
+
return await this.#messageManager.editMessageText(chatId, messageId, text, params);
|
|
1812
1902
|
}
|
|
1813
1903
|
/**
|
|
1814
1904
|
* Edit a message's caption.
|
|
@@ -1820,7 +1910,7 @@ class Client extends Composer {
|
|
|
1820
1910
|
* @returns The edited message.
|
|
1821
1911
|
*/
|
|
1822
1912
|
async editMessageCaption(chatId, messageId, params) {
|
|
1823
|
-
return await
|
|
1913
|
+
return await this.#messageManager.editMessageCaption(chatId, messageId, params);
|
|
1824
1914
|
}
|
|
1825
1915
|
/**
|
|
1826
1916
|
* Edit a message's media.
|
|
@@ -1832,7 +1922,7 @@ class Client extends Composer {
|
|
|
1832
1922
|
* @returns The edited message.
|
|
1833
1923
|
*/
|
|
1834
1924
|
async editMessageMedia(chatId, messageId, media, params) {
|
|
1835
|
-
return await
|
|
1925
|
+
return await this.#messageManager.editMessageMedia(chatId, messageId, media, params);
|
|
1836
1926
|
}
|
|
1837
1927
|
/**
|
|
1838
1928
|
* Edit an inline message's media.
|
|
@@ -1842,7 +1932,7 @@ class Client extends Composer {
|
|
|
1842
1932
|
* @param media The new media of the message.
|
|
1843
1933
|
*/
|
|
1844
1934
|
async editInlineMessageMedia(inlineMessageId, media, params) {
|
|
1845
|
-
await
|
|
1935
|
+
await this.#messageManager.editInlineMessageMedia(inlineMessageId, media, params);
|
|
1846
1936
|
}
|
|
1847
1937
|
/**
|
|
1848
1938
|
* Edit an inline message's text. Bot-only.
|
|
@@ -1852,7 +1942,7 @@ class Client extends Composer {
|
|
|
1852
1942
|
* @param text The new text of the message.
|
|
1853
1943
|
*/
|
|
1854
1944
|
async editInlineMessageText(inlineMessageId, text, params) {
|
|
1855
|
-
await
|
|
1945
|
+
await this.#messageManager.editInlineMessageText(inlineMessageId, text, params);
|
|
1856
1946
|
}
|
|
1857
1947
|
/**
|
|
1858
1948
|
* Edit an inline message's caption. Bot-only.
|
|
@@ -1861,7 +1951,7 @@ class Client extends Composer {
|
|
|
1861
1951
|
* @param inlineMessageId The identifier of the inline message.
|
|
1862
1952
|
*/
|
|
1863
1953
|
async editInlineMessageCaption(inlineMessageId, params) {
|
|
1864
|
-
await
|
|
1954
|
+
await this.#messageManager.editInlineMessageCaption(inlineMessageId, params);
|
|
1865
1955
|
}
|
|
1866
1956
|
/**
|
|
1867
1957
|
* Edit a message's reply markup.
|
|
@@ -1872,7 +1962,7 @@ class Client extends Composer {
|
|
|
1872
1962
|
* @returns The edited message.
|
|
1873
1963
|
*/
|
|
1874
1964
|
async editMessageReplyMarkup(chatId, messageId, params) {
|
|
1875
|
-
return await
|
|
1965
|
+
return await this.#messageManager.editMessageReplyMarkup(chatId, messageId, params);
|
|
1876
1966
|
}
|
|
1877
1967
|
/**
|
|
1878
1968
|
* Edit an inline message's reply markup. Bot-only.
|
|
@@ -1881,7 +1971,7 @@ class Client extends Composer {
|
|
|
1881
1971
|
* @param inlineMessageId The identifier of the inline message.
|
|
1882
1972
|
*/
|
|
1883
1973
|
async editInlineMessageReplyMarkup(inlineMessageId, params) {
|
|
1884
|
-
await
|
|
1974
|
+
await this.#messageManager.editInlineMessageReplyMarkup(inlineMessageId, params);
|
|
1885
1975
|
}
|
|
1886
1976
|
/**
|
|
1887
1977
|
* Edit a message's live location.
|
|
@@ -1894,7 +1984,7 @@ class Client extends Composer {
|
|
|
1894
1984
|
* @returns The edited location message.
|
|
1895
1985
|
*/
|
|
1896
1986
|
async editMessageLiveLocation(chatId, messageId, latitude, longitude, params) {
|
|
1897
|
-
return await
|
|
1987
|
+
return await this.#messageManager.editMessageLiveLocation(chatId, messageId, latitude, longitude, params);
|
|
1898
1988
|
}
|
|
1899
1989
|
/**
|
|
1900
1990
|
* Edit an inline message's live location. Bot-only.
|
|
@@ -1906,7 +1996,7 @@ class Client extends Composer {
|
|
|
1906
1996
|
* @returns The edited location message.
|
|
1907
1997
|
*/
|
|
1908
1998
|
async editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params) {
|
|
1909
|
-
await
|
|
1999
|
+
await this.#messageManager.editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params);
|
|
1910
2000
|
}
|
|
1911
2001
|
/**
|
|
1912
2002
|
* Retrieve multiple messages.
|
|
@@ -1921,7 +2011,7 @@ class Client extends Composer {
|
|
|
1921
2011
|
* @cache
|
|
1922
2012
|
*/
|
|
1923
2013
|
async getMessages(chatId, messageIds) {
|
|
1924
|
-
return await
|
|
2014
|
+
return await this.#messageManager.getMessages(chatId, messageIds);
|
|
1925
2015
|
}
|
|
1926
2016
|
/**
|
|
1927
2017
|
* Retrieve a single message.
|
|
@@ -1936,7 +2026,7 @@ class Client extends Composer {
|
|
|
1936
2026
|
* @cache
|
|
1937
2027
|
*/
|
|
1938
2028
|
async getMessage(chatId, messageId) {
|
|
1939
|
-
return await
|
|
2029
|
+
return await this.#messageManager.getMessage(chatId, messageId);
|
|
1940
2030
|
}
|
|
1941
2031
|
/**
|
|
1942
2032
|
* Retrieve a message using its link.
|
|
@@ -1949,7 +2039,7 @@ class Client extends Composer {
|
|
|
1949
2039
|
* @returns The message that was linked to.
|
|
1950
2040
|
*/
|
|
1951
2041
|
async resolveMessageLink(link) {
|
|
1952
|
-
return await
|
|
2042
|
+
return await this.#messageManager.resolveMessageLink(link);
|
|
1953
2043
|
}
|
|
1954
2044
|
/**
|
|
1955
2045
|
* Delete multiple messages.
|
|
@@ -1959,7 +2049,7 @@ class Client extends Composer {
|
|
|
1959
2049
|
* @param messageIds The identifiers of the messages to delete.
|
|
1960
2050
|
*/
|
|
1961
2051
|
async deleteMessages(chatId, messageIds, params) {
|
|
1962
|
-
await
|
|
2052
|
+
await this.#messageManager.deleteMessages(chatId, messageIds, params);
|
|
1963
2053
|
}
|
|
1964
2054
|
/**
|
|
1965
2055
|
* Delete a single message.
|
|
@@ -1969,7 +2059,7 @@ class Client extends Composer {
|
|
|
1969
2059
|
* @param messageId The identifier of the message to delete.
|
|
1970
2060
|
*/
|
|
1971
2061
|
async deleteMessage(chatId, messageId, params) {
|
|
1972
|
-
await
|
|
2062
|
+
await this.#messageManager.deleteMessages(chatId, [messageId], params);
|
|
1973
2063
|
}
|
|
1974
2064
|
/**
|
|
1975
2065
|
* Delete all messages sent by a specific member of a chat. User-only.
|
|
@@ -1979,7 +2069,7 @@ class Client extends Composer {
|
|
|
1979
2069
|
* @param memberId The identifier of the member.
|
|
1980
2070
|
*/
|
|
1981
2071
|
async deleteChatMemberMessages(chatId, memberId) {
|
|
1982
|
-
await
|
|
2072
|
+
await this.#messageManager.deleteChatMemberMessages(chatId, memberId);
|
|
1983
2073
|
}
|
|
1984
2074
|
/**
|
|
1985
2075
|
* Delete multiple scheduled messages.
|
|
@@ -1989,7 +2079,7 @@ class Client extends Composer {
|
|
|
1989
2079
|
* @param messageIds The identifiers of the scheduled messages to delete.
|
|
1990
2080
|
*/
|
|
1991
2081
|
async deleteScheduledMessages(chatId, messageIds) {
|
|
1992
|
-
await
|
|
2082
|
+
await this.#messageManager.deleteScheduledMessages(chatId, messageIds);
|
|
1993
2083
|
}
|
|
1994
2084
|
/**
|
|
1995
2085
|
* Delete a scheduled message.
|
|
@@ -1999,7 +2089,7 @@ class Client extends Composer {
|
|
|
1999
2089
|
* @param messageId The identifier of the scheduled message to delete.
|
|
2000
2090
|
*/
|
|
2001
2091
|
async deleteScheduledMessage(chatId, messageId) {
|
|
2002
|
-
await
|
|
2092
|
+
await this.#messageManager.deleteScheduledMessage(chatId, messageId);
|
|
2003
2093
|
}
|
|
2004
2094
|
/**
|
|
2005
2095
|
* Send multiple scheduled messages before their schedule.
|
|
@@ -2009,7 +2099,7 @@ class Client extends Composer {
|
|
|
2009
2099
|
* @param messageIds The identifiers of the scheduled messages to send.
|
|
2010
2100
|
*/
|
|
2011
2101
|
async sendScheduledMessages(chatId, messageIds) {
|
|
2012
|
-
return await
|
|
2102
|
+
return await this.#messageManager.sendScheduledMessages(chatId, messageIds);
|
|
2013
2103
|
}
|
|
2014
2104
|
/**
|
|
2015
2105
|
* Send a scheduled message before its schedule.
|
|
@@ -2019,7 +2109,7 @@ class Client extends Composer {
|
|
|
2019
2109
|
* @param messageId The identifier of the scheduled message to send.
|
|
2020
2110
|
*/
|
|
2021
2111
|
async sendScheduledMessage(chatId, messageId) {
|
|
2022
|
-
return await
|
|
2112
|
+
return await this.#messageManager.sendScheduledMessage(chatId, messageId);
|
|
2023
2113
|
}
|
|
2024
2114
|
/**
|
|
2025
2115
|
* Pin a message in a chat.
|
|
@@ -2029,7 +2119,7 @@ class Client extends Composer {
|
|
|
2029
2119
|
* @param messageId The identifier of the message.
|
|
2030
2120
|
*/
|
|
2031
2121
|
async pinMessage(chatId, messageId, params) {
|
|
2032
|
-
await
|
|
2122
|
+
await this.#messageManager.pinMessage(chatId, messageId, params);
|
|
2033
2123
|
}
|
|
2034
2124
|
/**
|
|
2035
2125
|
* Unpin a pinned message.
|
|
@@ -2039,7 +2129,7 @@ class Client extends Composer {
|
|
|
2039
2129
|
* @param messageId The identifier of the message.
|
|
2040
2130
|
*/
|
|
2041
2131
|
async unpinMessage(chatId, messageId, params) {
|
|
2042
|
-
await
|
|
2132
|
+
await this.#messageManager.unpinMessage(chatId, messageId, params);
|
|
2043
2133
|
}
|
|
2044
2134
|
/**
|
|
2045
2135
|
* Unpin all pinned messages.
|
|
@@ -2048,7 +2138,7 @@ class Client extends Composer {
|
|
|
2048
2138
|
* @param chatId The identifier of a chat.
|
|
2049
2139
|
*/
|
|
2050
2140
|
async unpinMessages(chatId) {
|
|
2051
|
-
await
|
|
2141
|
+
await this.#messageManager.unpinMessages(chatId);
|
|
2052
2142
|
}
|
|
2053
2143
|
/**
|
|
2054
2144
|
* Forward multiple messages.
|
|
@@ -2060,7 +2150,7 @@ class Client extends Composer {
|
|
|
2060
2150
|
* @returns The forwarded messages.
|
|
2061
2151
|
*/
|
|
2062
2152
|
async forwardMessages(from, to, messageIds, params) {
|
|
2063
|
-
return await
|
|
2153
|
+
return await this.#messageManager.forwardMessages(from, to, messageIds, params);
|
|
2064
2154
|
}
|
|
2065
2155
|
/**
|
|
2066
2156
|
* Forward a single message.
|
|
@@ -2083,7 +2173,7 @@ class Client extends Composer {
|
|
|
2083
2173
|
* @returns The new state of the poll.
|
|
2084
2174
|
*/
|
|
2085
2175
|
async stopPoll(chatId, messageId, params) {
|
|
2086
|
-
return await
|
|
2176
|
+
return await this.#messageManager.stopPoll(chatId, messageId, params);
|
|
2087
2177
|
}
|
|
2088
2178
|
/**
|
|
2089
2179
|
* Send a chat action.
|
|
@@ -2094,7 +2184,7 @@ class Client extends Composer {
|
|
|
2094
2184
|
* @param messageThreadId The thread to send the chat action to.
|
|
2095
2185
|
*/
|
|
2096
2186
|
async sendChatAction(chatId, action, params) {
|
|
2097
|
-
await
|
|
2187
|
+
await this.#messageManager.sendChatAction(chatId, action, params);
|
|
2098
2188
|
}
|
|
2099
2189
|
/**
|
|
2100
2190
|
* Search the messages of a chat. User-only.
|
|
@@ -2104,7 +2194,7 @@ class Client extends Composer {
|
|
|
2104
2194
|
* @param query The message search query.
|
|
2105
2195
|
*/
|
|
2106
2196
|
async searchMessages(chatId, query, params) {
|
|
2107
|
-
return await
|
|
2197
|
+
return await this.#messageManager.searchMessages(chatId, query, params);
|
|
2108
2198
|
}
|
|
2109
2199
|
/**
|
|
2110
2200
|
* Mark messages as read. User-only.
|
|
@@ -2114,7 +2204,7 @@ class Client extends Composer {
|
|
|
2114
2204
|
* @param untilMessageId The identifier of the message that will be marked as read, along with any other unread messages before it.
|
|
2115
2205
|
*/
|
|
2116
2206
|
async readMessages(chatId, untilMessageId) {
|
|
2117
|
-
await
|
|
2207
|
+
await this.#messageManager.readMessages(chatId, untilMessageId);
|
|
2118
2208
|
}
|
|
2119
2209
|
/**
|
|
2120
2210
|
* Start a bot. User-only.
|
|
@@ -2124,7 +2214,7 @@ class Client extends Composer {
|
|
|
2124
2214
|
* @returns The start message.
|
|
2125
2215
|
*/
|
|
2126
2216
|
async startBot(botId, params) {
|
|
2127
|
-
return await
|
|
2217
|
+
return await this.#messageManager.startBot(botId, params);
|
|
2128
2218
|
}
|
|
2129
2219
|
/**
|
|
2130
2220
|
* Transcribe a voice message. User-only.
|
|
@@ -2135,7 +2225,7 @@ class Client extends Composer {
|
|
|
2135
2225
|
* @cache
|
|
2136
2226
|
*/
|
|
2137
2227
|
async transcribeVoice(chatId, messageId) {
|
|
2138
|
-
return await
|
|
2228
|
+
return await this.#messageManager.transcribeVoice(chatId, messageId);
|
|
2139
2229
|
}
|
|
2140
2230
|
/**
|
|
2141
2231
|
* Get the link preview for a message that is about to be sent. User-only.
|
|
@@ -2144,7 +2234,7 @@ class Client extends Composer {
|
|
|
2144
2234
|
* @param text The message's text.
|
|
2145
2235
|
*/
|
|
2146
2236
|
async getLinkPreview(text, params) {
|
|
2147
|
-
return await
|
|
2237
|
+
return await this.#linkPreviewManager.getLinkPreview(text, params);
|
|
2148
2238
|
}
|
|
2149
2239
|
/**
|
|
2150
2240
|
* Open a mini app. User-only.
|
|
@@ -2155,7 +2245,16 @@ class Client extends Composer {
|
|
|
2155
2245
|
* @cache
|
|
2156
2246
|
*/
|
|
2157
2247
|
async openMiniApp(botId, chatId, params) {
|
|
2158
|
-
return await
|
|
2248
|
+
return await this.#messageManager.openMiniApp(botId, chatId, params);
|
|
2249
|
+
}
|
|
2250
|
+
/**
|
|
2251
|
+
* Get a progress ID that can be passed to relevant send* methods to receive upload progress updates for them.
|
|
2252
|
+
*
|
|
2253
|
+
* @method ms
|
|
2254
|
+
* @cache
|
|
2255
|
+
*/
|
|
2256
|
+
async getProgressId() {
|
|
2257
|
+
return await this.#fileManager.getProgressId();
|
|
2159
2258
|
}
|
|
2160
2259
|
//
|
|
2161
2260
|
// ========================= POLLS ========================= //
|
|
@@ -2169,7 +2268,7 @@ class Client extends Composer {
|
|
|
2169
2268
|
* @param optionIndexes The indexes of the options to cast for.
|
|
2170
2269
|
*/
|
|
2171
2270
|
async vote(chatId, messageId, optionIndexes) {
|
|
2172
|
-
await
|
|
2271
|
+
await this.#pollManager.vote(chatId, messageId, optionIndexes);
|
|
2173
2272
|
}
|
|
2174
2273
|
/**
|
|
2175
2274
|
* Retract a vote. User-only.
|
|
@@ -2179,7 +2278,7 @@ class Client extends Composer {
|
|
|
2179
2278
|
* @param messageId The identifier of the message that includes the poll.
|
|
2180
2279
|
*/
|
|
2181
2280
|
async retractVote(chatId, messageId) {
|
|
2182
|
-
await
|
|
2281
|
+
await this.#pollManager.retractVote(chatId, messageId);
|
|
2183
2282
|
}
|
|
2184
2283
|
//
|
|
2185
2284
|
// ========================= FILES ========================= //
|
|
@@ -2198,7 +2297,7 @@ class Client extends Composer {
|
|
|
2198
2297
|
* @cache file
|
|
2199
2298
|
*/
|
|
2200
2299
|
async *download(fileId, params) {
|
|
2201
|
-
for await (const chunk of
|
|
2300
|
+
for await (const chunk of this.#fileManager.download(fileId, params)) {
|
|
2202
2301
|
yield chunk;
|
|
2203
2302
|
}
|
|
2204
2303
|
}
|
|
@@ -2211,7 +2310,7 @@ class Client extends Composer {
|
|
|
2211
2310
|
* @cache
|
|
2212
2311
|
*/
|
|
2213
2312
|
async getCustomEmojiStickers(id) {
|
|
2214
|
-
return await
|
|
2313
|
+
return await this.#fileManager.getCustomEmojiStickers(id);
|
|
2215
2314
|
}
|
|
2216
2315
|
//
|
|
2217
2316
|
// ========================= CHATS ========================= //
|
|
@@ -2222,7 +2321,7 @@ class Client extends Composer {
|
|
|
2222
2321
|
* @method ch
|
|
2223
2322
|
*/
|
|
2224
2323
|
async getChats(params) {
|
|
2225
|
-
return await
|
|
2324
|
+
return await this.#chatListManager.getChats(params?.from, params?.after, params?.limit);
|
|
2226
2325
|
}
|
|
2227
2326
|
/**
|
|
2228
2327
|
* Get a chat.
|
|
@@ -2231,7 +2330,7 @@ class Client extends Composer {
|
|
|
2231
2330
|
* @cache
|
|
2232
2331
|
*/
|
|
2233
2332
|
async getChat(chatId) {
|
|
2234
|
-
return await
|
|
2333
|
+
return await this.#chatListManager.getChat(chatId);
|
|
2235
2334
|
}
|
|
2236
2335
|
/**
|
|
2237
2336
|
* Get chat history. User-only.
|
|
@@ -2240,7 +2339,7 @@ class Client extends Composer {
|
|
|
2240
2339
|
* @param chatId The identifier of a chat.
|
|
2241
2340
|
*/
|
|
2242
2341
|
async getHistory(chatId, params) {
|
|
2243
|
-
return await
|
|
2342
|
+
return await this.#messageManager.getHistory(chatId, params);
|
|
2244
2343
|
}
|
|
2245
2344
|
/**
|
|
2246
2345
|
* Set a chat's available reactions. User-only.
|
|
@@ -2250,7 +2349,7 @@ class Client extends Composer {
|
|
|
2250
2349
|
* @param availableReactions The new available reactions.
|
|
2251
2350
|
*/
|
|
2252
2351
|
async setAvailableReactions(chatId, availableReactions) {
|
|
2253
|
-
await
|
|
2352
|
+
await this.#chatManager.setAvailableReactions(chatId, availableReactions);
|
|
2254
2353
|
}
|
|
2255
2354
|
/**
|
|
2256
2355
|
* Set a chat's photo.
|
|
@@ -2260,7 +2359,7 @@ class Client extends Composer {
|
|
|
2260
2359
|
* @param photo A photo to set as the chat's photo.
|
|
2261
2360
|
*/
|
|
2262
2361
|
async setChatPhoto(chatId, photo, params) {
|
|
2263
|
-
await
|
|
2362
|
+
await this.#chatManager.setChatPhoto(chatId, photo, params);
|
|
2264
2363
|
}
|
|
2265
2364
|
/**
|
|
2266
2365
|
* Delete a chat's photo.
|
|
@@ -2269,7 +2368,7 @@ class Client extends Composer {
|
|
|
2269
2368
|
* @param chatId The identifier of a chat.
|
|
2270
2369
|
*/
|
|
2271
2370
|
async deleteChatPhoto(chatId) {
|
|
2272
|
-
await
|
|
2371
|
+
await this.#chatManager.deleteChatPhoto(chatId);
|
|
2273
2372
|
}
|
|
2274
2373
|
/**
|
|
2275
2374
|
* Ban a member from a chat.
|
|
@@ -2279,7 +2378,7 @@ class Client extends Composer {
|
|
|
2279
2378
|
* @param memberId The identifier of the member.
|
|
2280
2379
|
*/
|
|
2281
2380
|
async banChatMember(chatId, memberId, params) {
|
|
2282
|
-
await
|
|
2381
|
+
await this.#chatManager.banChatMember(chatId, memberId, params);
|
|
2283
2382
|
}
|
|
2284
2383
|
/**
|
|
2285
2384
|
* Unban a member from a chat.
|
|
@@ -2289,7 +2388,7 @@ class Client extends Composer {
|
|
|
2289
2388
|
* @param memberId The identifier of the member.
|
|
2290
2389
|
*/
|
|
2291
2390
|
async unbanChatMember(chatId, memberId) {
|
|
2292
|
-
await
|
|
2391
|
+
await this.#chatManager.unbanChatMember(chatId, memberId);
|
|
2293
2392
|
}
|
|
2294
2393
|
/**
|
|
2295
2394
|
* Kick a member from a chat. Same as a banChatMember call followed by unbanChatMember.
|
|
@@ -2299,8 +2398,8 @@ class Client extends Composer {
|
|
|
2299
2398
|
* @param memberId The identifier of the member.
|
|
2300
2399
|
*/
|
|
2301
2400
|
async kickChatMember(chatId, memberId) {
|
|
2302
|
-
await
|
|
2303
|
-
await
|
|
2401
|
+
await this.#chatManager.banChatMember(chatId, memberId);
|
|
2402
|
+
await this.#chatManager.unbanChatMember(chatId, memberId);
|
|
2304
2403
|
}
|
|
2305
2404
|
/**
|
|
2306
2405
|
* Set the rights of a chat member.
|
|
@@ -2310,7 +2409,7 @@ class Client extends Composer {
|
|
|
2310
2409
|
* @param memberId The identifier of the member.
|
|
2311
2410
|
*/
|
|
2312
2411
|
async setChatMemberRights(chatId, memberId, params) {
|
|
2313
|
-
await
|
|
2412
|
+
await this.#chatManager.setChatMemberRights(chatId, memberId, params);
|
|
2314
2413
|
}
|
|
2315
2414
|
/**
|
|
2316
2415
|
* Get the administrators of a chat.
|
|
@@ -2320,7 +2419,7 @@ class Client extends Composer {
|
|
|
2320
2419
|
* @returns The chat's administrators.
|
|
2321
2420
|
*/
|
|
2322
2421
|
async getChatAdministrators(chatId) {
|
|
2323
|
-
return await
|
|
2422
|
+
return await this.#chatListManager.getChatAdministrators(chatId);
|
|
2324
2423
|
}
|
|
2325
2424
|
/**
|
|
2326
2425
|
* Enable join requests in a chat. User-only.
|
|
@@ -2329,7 +2428,7 @@ class Client extends Composer {
|
|
|
2329
2428
|
* @param chatId The identifier of a chat. Must be a channel or a supergroup.
|
|
2330
2429
|
*/
|
|
2331
2430
|
async enableJoinRequests(chatId) {
|
|
2332
|
-
await
|
|
2431
|
+
await this.#chatManager.enableJoinRequests(chatId);
|
|
2333
2432
|
}
|
|
2334
2433
|
/**
|
|
2335
2434
|
* Disable join requests in a chat. User-only.
|
|
@@ -2338,7 +2437,7 @@ class Client extends Composer {
|
|
|
2338
2437
|
* @param chatId The identifier of a chat. Must be a channel or a supergroup.
|
|
2339
2438
|
*/
|
|
2340
2439
|
async disableJoinRequests(chatId) {
|
|
2341
|
-
await
|
|
2440
|
+
await this.#chatManager.disableJoinRequests(chatId);
|
|
2342
2441
|
}
|
|
2343
2442
|
/**
|
|
2344
2443
|
* Get inactive chats. User-only.
|
|
@@ -2347,7 +2446,7 @@ class Client extends Composer {
|
|
|
2347
2446
|
* @retuns A list of inactive chats the current user is member of.
|
|
2348
2447
|
*/
|
|
2349
2448
|
async getInactiveChats() {
|
|
2350
|
-
return await
|
|
2449
|
+
return await this.#accountManager.getInactiveChats();
|
|
2351
2450
|
}
|
|
2352
2451
|
/**
|
|
2353
2452
|
* Get the invite links created for a chat. User-only.
|
|
@@ -2357,7 +2456,7 @@ class Client extends Composer {
|
|
|
2357
2456
|
* @returns The invite links created for the chat. This might be a subset of the results if they were less than `limit`. The parameters `afterDate` and `afterInviteLink` can be used for pagination.
|
|
2358
2457
|
*/
|
|
2359
2458
|
async getCreatedInviteLinks(chatId, params) {
|
|
2360
|
-
return await
|
|
2459
|
+
return await this.#chatManager.getCreatedInviteLinks(chatId, params);
|
|
2361
2460
|
}
|
|
2362
2461
|
/**
|
|
2363
2462
|
* Join a chat. User-only.
|
|
@@ -2366,7 +2465,7 @@ class Client extends Composer {
|
|
|
2366
2465
|
* @param chatId The identifier of a chat.
|
|
2367
2466
|
*/
|
|
2368
2467
|
async joinChat(chatId) {
|
|
2369
|
-
await
|
|
2468
|
+
await this.#chatManager.joinChat(chatId);
|
|
2370
2469
|
}
|
|
2371
2470
|
/**
|
|
2372
2471
|
* Leave a chat.
|
|
@@ -2375,7 +2474,7 @@ class Client extends Composer {
|
|
|
2375
2474
|
* @param chatId The identifier of a chat.
|
|
2376
2475
|
*/
|
|
2377
2476
|
async leaveChat(chatId) {
|
|
2378
|
-
await
|
|
2477
|
+
await this.#chatManager.leaveChat(chatId);
|
|
2379
2478
|
}
|
|
2380
2479
|
/**
|
|
2381
2480
|
* Get information on a user's chat membership.
|
|
@@ -2385,7 +2484,7 @@ class Client extends Composer {
|
|
|
2385
2484
|
* @param userId The identifier of the user.
|
|
2386
2485
|
*/
|
|
2387
2486
|
async getChatMember(chatId, userId) {
|
|
2388
|
-
return await
|
|
2487
|
+
return await this.#chatListManager.getChatMember(chatId, userId);
|
|
2389
2488
|
}
|
|
2390
2489
|
/**
|
|
2391
2490
|
* Get the members of a chat.
|
|
@@ -2394,7 +2493,7 @@ class Client extends Composer {
|
|
|
2394
2493
|
* @param chatId The identifier of a chat.
|
|
2395
2494
|
*/
|
|
2396
2495
|
async getChatMembers(chatId, params) {
|
|
2397
|
-
return await
|
|
2496
|
+
return await this.#chatListManager.getChatMembers(chatId, params);
|
|
2398
2497
|
}
|
|
2399
2498
|
/**
|
|
2400
2499
|
* Set a chat's sticker set.
|
|
@@ -2404,7 +2503,7 @@ class Client extends Composer {
|
|
|
2404
2503
|
* @param setName The name of the set.
|
|
2405
2504
|
*/
|
|
2406
2505
|
async setChatStickerSet(chatId, setName) {
|
|
2407
|
-
await
|
|
2506
|
+
await this.#messageManager.setChatStickerSet(chatId, setName);
|
|
2408
2507
|
}
|
|
2409
2508
|
/**
|
|
2410
2509
|
* Delete a chat's sticker set.
|
|
@@ -2413,7 +2512,7 @@ class Client extends Composer {
|
|
|
2413
2512
|
* @param chatId The identifier of a chat. Must be a supergroup.
|
|
2414
2513
|
*/
|
|
2415
2514
|
async deleteChatStickerSet(chatId) {
|
|
2416
|
-
await
|
|
2515
|
+
await this.#messageManager.deleteChatStickerSet(chatId);
|
|
2417
2516
|
}
|
|
2418
2517
|
/**
|
|
2419
2518
|
* Set the number of boosts required to circument a chat's default restrictions. User-only.
|
|
@@ -2423,7 +2522,7 @@ class Client extends Composer {
|
|
|
2423
2522
|
* @param boosts The number of boosts required to circumvent its restrictions.
|
|
2424
2523
|
*/
|
|
2425
2524
|
async setBoostsRequiredToCircumventRestrictions(chatId, boosts) {
|
|
2426
|
-
await
|
|
2525
|
+
await this.#chatManager.setBoostsRequiredToCircumventRestrictions(chatId, boosts);
|
|
2427
2526
|
}
|
|
2428
2527
|
/**
|
|
2429
2528
|
* Create an invite link.
|
|
@@ -2433,7 +2532,7 @@ class Client extends Composer {
|
|
|
2433
2532
|
* @returns The newly created invite link.
|
|
2434
2533
|
*/
|
|
2435
2534
|
async createInviteLink(chatId, params) {
|
|
2436
|
-
return await
|
|
2535
|
+
return await this.#chatManager.createInviteLink(chatId, params);
|
|
2437
2536
|
}
|
|
2438
2537
|
/**
|
|
2439
2538
|
* Approve a join request.
|
|
@@ -2443,7 +2542,7 @@ class Client extends Composer {
|
|
|
2443
2542
|
* @param userId The user who made the join request.
|
|
2444
2543
|
*/
|
|
2445
2544
|
async approveJoinRequest(chatId, userId) {
|
|
2446
|
-
await
|
|
2545
|
+
await this.#chatManager.approveJoinRequest(chatId, userId);
|
|
2447
2546
|
}
|
|
2448
2547
|
/**
|
|
2449
2548
|
* Decline a join request.
|
|
@@ -2453,7 +2552,7 @@ class Client extends Composer {
|
|
|
2453
2552
|
* @param userId The user who made the join request.
|
|
2454
2553
|
*/
|
|
2455
2554
|
async declineJoinRequest(chatId, userId) {
|
|
2456
|
-
await
|
|
2555
|
+
await this.#chatManager.declineJoinRequest(chatId, userId);
|
|
2457
2556
|
}
|
|
2458
2557
|
/**
|
|
2459
2558
|
* Approve all join requests. User-only.
|
|
@@ -2462,7 +2561,7 @@ class Client extends Composer {
|
|
|
2462
2561
|
* @param chatId The identifier of a chat with the join requests.
|
|
2463
2562
|
*/
|
|
2464
2563
|
async approveJoinRequests(chatId, params) {
|
|
2465
|
-
await
|
|
2564
|
+
await this.#chatManager.approveJoinRequests(chatId, params);
|
|
2466
2565
|
}
|
|
2467
2566
|
/**
|
|
2468
2567
|
* Decline all join requests. User-only.
|
|
@@ -2471,7 +2570,7 @@ class Client extends Composer {
|
|
|
2471
2570
|
* @param chatId The identifier of a chat with the join requests.
|
|
2472
2571
|
*/
|
|
2473
2572
|
async declineJoinRequests(chatId, params) {
|
|
2474
|
-
await
|
|
2573
|
+
await this.#chatManager.declineJoinRequests(chatId, params);
|
|
2475
2574
|
}
|
|
2476
2575
|
/**
|
|
2477
2576
|
* Get pending join requests in a chat. User-only.
|
|
@@ -2480,7 +2579,7 @@ class Client extends Composer {
|
|
|
2480
2579
|
* @param chatId The identifier of a chat with the join requests.
|
|
2481
2580
|
*/
|
|
2482
2581
|
async getJoinRequests(chatId, params) {
|
|
2483
|
-
return await
|
|
2582
|
+
return await this.#chatManager.getJoinRequests(chatId, params);
|
|
2484
2583
|
}
|
|
2485
2584
|
/**
|
|
2486
2585
|
* Add a single user to a chat.
|
|
@@ -2491,7 +2590,7 @@ class Client extends Composer {
|
|
|
2491
2590
|
* @returns An array of FailedInvitation that has at most a length of 1. If empty, it means that the user was added.
|
|
2492
2591
|
*/
|
|
2493
2592
|
async addChatMember(chatId, userId, params) {
|
|
2494
|
-
return await
|
|
2593
|
+
return await this.#chatManager.addChatMember(chatId, userId, params);
|
|
2495
2594
|
}
|
|
2496
2595
|
/**
|
|
2497
2596
|
* Add multiple users at once to a channel or a supergroup.
|
|
@@ -2501,7 +2600,7 @@ class Client extends Composer {
|
|
|
2501
2600
|
* @param userId The identifiers of the users to add to the channel or supergroup.
|
|
2502
2601
|
*/
|
|
2503
2602
|
async addChatMembers(chatId, userIds) {
|
|
2504
|
-
return await
|
|
2603
|
+
return await this.#chatManager.addChatMembers(chatId, userIds);
|
|
2505
2604
|
}
|
|
2506
2605
|
/**
|
|
2507
2606
|
* Open a chat.
|
|
@@ -2510,7 +2609,7 @@ class Client extends Composer {
|
|
|
2510
2609
|
* @param chatId The identifier of a chat to open.
|
|
2511
2610
|
*/
|
|
2512
2611
|
async openChat(chatId) {
|
|
2513
|
-
await
|
|
2612
|
+
await this.#updateManager.openChat(chatId);
|
|
2514
2613
|
}
|
|
2515
2614
|
/**
|
|
2516
2615
|
* Close a chat previously opened by openChat.
|
|
@@ -2519,7 +2618,7 @@ class Client extends Composer {
|
|
|
2519
2618
|
* @param chatId The identifier of a chat to close.
|
|
2520
2619
|
*/
|
|
2521
2620
|
async closeChat(chatId) {
|
|
2522
|
-
await
|
|
2621
|
+
await this.#updateManager.closeChat(chatId);
|
|
2523
2622
|
}
|
|
2524
2623
|
/**
|
|
2525
2624
|
* Create a group. User-only.
|
|
@@ -2529,7 +2628,7 @@ class Client extends Composer {
|
|
|
2529
2628
|
* @returns The created group.
|
|
2530
2629
|
*/
|
|
2531
2630
|
async createGroup(title, params) {
|
|
2532
|
-
return await
|
|
2631
|
+
return await this.#chatListManager.createGroup(title, params);
|
|
2533
2632
|
}
|
|
2534
2633
|
/**
|
|
2535
2634
|
* Create a supergroup. User-only.
|
|
@@ -2539,7 +2638,7 @@ class Client extends Composer {
|
|
|
2539
2638
|
* @returns The created supergroup.
|
|
2540
2639
|
*/
|
|
2541
2640
|
async createSupergroup(title, params) {
|
|
2542
|
-
return await
|
|
2641
|
+
return await this.#chatListManager.createSupergroup(title, params);
|
|
2543
2642
|
}
|
|
2544
2643
|
/**
|
|
2545
2644
|
* Create a channel. User-only.
|
|
@@ -2549,7 +2648,7 @@ class Client extends Composer {
|
|
|
2549
2648
|
* @returns The created channel.
|
|
2550
2649
|
*/
|
|
2551
2650
|
async createChannel(title, params) {
|
|
2552
|
-
return await
|
|
2651
|
+
return await this.#chatListManager.createChannel(title, params);
|
|
2553
2652
|
}
|
|
2554
2653
|
/**
|
|
2555
2654
|
* Set the time to live of the messages of a chat. User-only.
|
|
@@ -2559,7 +2658,7 @@ class Client extends Composer {
|
|
|
2559
2658
|
* @param messageTtl The time to live of the messages in seconds.
|
|
2560
2659
|
*/
|
|
2561
2660
|
async setMessageTtl(chatId, messageTtl) {
|
|
2562
|
-
await
|
|
2661
|
+
await this.#chatListManager.setMessageTtl(chatId, messageTtl);
|
|
2563
2662
|
}
|
|
2564
2663
|
/**
|
|
2565
2664
|
* Archive multiple chats. User-only.
|
|
@@ -2568,7 +2667,7 @@ class Client extends Composer {
|
|
|
2568
2667
|
* @param chatIds The identifiers of the chats to archive.
|
|
2569
2668
|
*/
|
|
2570
2669
|
async archiveChats(chatIds) {
|
|
2571
|
-
await
|
|
2670
|
+
await this.#chatListManager.archiveChats(chatIds);
|
|
2572
2671
|
}
|
|
2573
2672
|
/**
|
|
2574
2673
|
* Archive a single chat. User-only.
|
|
@@ -2577,7 +2676,7 @@ class Client extends Composer {
|
|
|
2577
2676
|
* @param chatId The identifier of a chat.
|
|
2578
2677
|
*/
|
|
2579
2678
|
async archiveChat(chatId) {
|
|
2580
|
-
await
|
|
2679
|
+
await this.#chatListManager.archiveChat(chatId);
|
|
2581
2680
|
}
|
|
2582
2681
|
/**
|
|
2583
2682
|
* Unarchive multiple chats. User-only.
|
|
@@ -2586,7 +2685,7 @@ class Client extends Composer {
|
|
|
2586
2685
|
* @param chatIds The identifiers of the chats to unarchive.
|
|
2587
2686
|
*/
|
|
2588
2687
|
async unarchiveChats(chatIds) {
|
|
2589
|
-
await
|
|
2688
|
+
await this.#chatListManager.unarchiveChats(chatIds);
|
|
2590
2689
|
}
|
|
2591
2690
|
/**
|
|
2592
2691
|
* Unarchive a single chat. User-only.
|
|
@@ -2595,7 +2694,7 @@ class Client extends Composer {
|
|
|
2595
2694
|
* @param chatId The identifier of a chat.
|
|
2596
2695
|
*/
|
|
2597
2696
|
async unarchiveChat(chatId) {
|
|
2598
|
-
await
|
|
2697
|
+
await this.#chatListManager.unarchiveChat(chatId);
|
|
2599
2698
|
}
|
|
2600
2699
|
/**
|
|
2601
2700
|
* Get common chats between a user and the current one. User-only.
|
|
@@ -2604,7 +2703,7 @@ class Client extends Composer {
|
|
|
2604
2703
|
* @param userId The identifier of the user to get the common chats with them.
|
|
2605
2704
|
*/
|
|
2606
2705
|
async getCommonChats(userId, params) {
|
|
2607
|
-
return await
|
|
2706
|
+
return await this.#chatListManager.getCommonChats(userId, params);
|
|
2608
2707
|
}
|
|
2609
2708
|
/**
|
|
2610
2709
|
* Get the settings of a chat. User-only.
|
|
@@ -2613,7 +2712,7 @@ class Client extends Composer {
|
|
|
2613
2712
|
* @param chatId The identifier of a chat.
|
|
2614
2713
|
*/
|
|
2615
2714
|
async getChatSettings(chatId) {
|
|
2616
|
-
return await
|
|
2715
|
+
return await this.#chatListManager.getChatSettings(chatId);
|
|
2617
2716
|
}
|
|
2618
2717
|
/**
|
|
2619
2718
|
* Disable business bots in a private chat. User-only.
|
|
@@ -2622,7 +2721,7 @@ class Client extends Composer {
|
|
|
2622
2721
|
* @param chatId The identifier of the private chat to disable business bots in.
|
|
2623
2722
|
*/
|
|
2624
2723
|
async disableBusinessBots(chatId) {
|
|
2625
|
-
await
|
|
2724
|
+
await this.#chatListManager.disableBusinessBots(chatId);
|
|
2626
2725
|
}
|
|
2627
2726
|
/**
|
|
2628
2727
|
* Enable business bots in a private chat. User-only.
|
|
@@ -2631,7 +2730,7 @@ class Client extends Composer {
|
|
|
2631
2730
|
* @param chatId The identifier of the private chat to enable business bots in.
|
|
2632
2731
|
*/
|
|
2633
2732
|
async enableBusinessBots(chatId) {
|
|
2634
|
-
await
|
|
2733
|
+
await this.#chatListManager.enableBusinessBots(chatId);
|
|
2635
2734
|
}
|
|
2636
2735
|
/**
|
|
2637
2736
|
* Disable slow mode in a group. User-only.
|
|
@@ -2640,7 +2739,7 @@ class Client extends Composer {
|
|
|
2640
2739
|
* @param chatId The identifier of the group to disable slow mode in.
|
|
2641
2740
|
*/
|
|
2642
2741
|
async disableSlowMode(chatId) {
|
|
2643
|
-
await
|
|
2742
|
+
await this.#chatManager.disableSlowMode(chatId);
|
|
2644
2743
|
}
|
|
2645
2744
|
/**
|
|
2646
2745
|
* Change slow mode in a group. User-only.
|
|
@@ -2650,7 +2749,7 @@ class Client extends Composer {
|
|
|
2650
2749
|
* @param duration New slow mode duration.
|
|
2651
2750
|
*/
|
|
2652
2751
|
async setSlowMode(chatId, duration) {
|
|
2653
|
-
await
|
|
2752
|
+
await this.#chatManager.setSlowMode(chatId, duration);
|
|
2654
2753
|
}
|
|
2655
2754
|
/**
|
|
2656
2755
|
* Change the title of a chat.
|
|
@@ -2660,7 +2759,7 @@ class Client extends Composer {
|
|
|
2660
2759
|
* @param title The new title.
|
|
2661
2760
|
*/
|
|
2662
2761
|
async setChatTitle(chatId, title) {
|
|
2663
|
-
await
|
|
2762
|
+
await this.#chatManager.setChatTitle(chatId, title);
|
|
2664
2763
|
}
|
|
2665
2764
|
/**
|
|
2666
2765
|
* Change the description of a chat.
|
|
@@ -2670,7 +2769,7 @@ class Client extends Composer {
|
|
|
2670
2769
|
* @param description The new description.
|
|
2671
2770
|
*/
|
|
2672
2771
|
async setChatDescription(chatId, description) {
|
|
2673
|
-
await
|
|
2772
|
+
await this.#chatManager.setChatDescription(chatId, description);
|
|
2674
2773
|
}
|
|
2675
2774
|
/**
|
|
2676
2775
|
* Hide or show the member list of a group to non-admins. User-only.
|
|
@@ -2680,7 +2779,7 @@ class Client extends Composer {
|
|
|
2680
2779
|
* @param visible Whether the member list of the group should be visible.
|
|
2681
2780
|
*/
|
|
2682
2781
|
async setMemberListVisibility(chatId, visible) {
|
|
2683
|
-
await
|
|
2782
|
+
await this.#chatManager.setMemberListVisibility(chatId, visible);
|
|
2684
2783
|
}
|
|
2685
2784
|
/**
|
|
2686
2785
|
* Enable or disable topics in a group. User-only.
|
|
@@ -2690,7 +2789,7 @@ class Client extends Composer {
|
|
|
2690
2789
|
* @param enabled Whether topics should be enabled in the group.
|
|
2691
2790
|
*/
|
|
2692
2791
|
async setTopicsEnabled(chatId, enabled) {
|
|
2693
|
-
await
|
|
2792
|
+
await this.#chatManager.setTopicsEnabled(chatId, enabled);
|
|
2694
2793
|
}
|
|
2695
2794
|
/**
|
|
2696
2795
|
* Enable or disable automatic anti-spam in a group. User-only.
|
|
@@ -2700,7 +2799,7 @@ class Client extends Composer {
|
|
|
2700
2799
|
* @param enabled Whether automatic anti-spam should be enabled in the group.
|
|
2701
2800
|
*/
|
|
2702
2801
|
async setAntispamEnabled(chatId, enabled) {
|
|
2703
|
-
await
|
|
2802
|
+
await this.#chatManager.setAntispamEnabled(chatId, enabled);
|
|
2704
2803
|
}
|
|
2705
2804
|
/**
|
|
2706
2805
|
* Enable or disable post signatures in a channel. User-only.
|
|
@@ -2710,7 +2809,7 @@ class Client extends Composer {
|
|
|
2710
2809
|
* @param enabled Whether post signatures should be enabled in the channel.
|
|
2711
2810
|
*/
|
|
2712
2811
|
async setSignaturesEnabled(chatId, enabled, params) {
|
|
2713
|
-
await
|
|
2812
|
+
await this.#chatManager.setSignaturesEnabled(chatId, enabled, params);
|
|
2714
2813
|
}
|
|
2715
2814
|
/**
|
|
2716
2815
|
* Delete a chat. User-only.
|
|
@@ -2719,7 +2818,7 @@ class Client extends Composer {
|
|
|
2719
2818
|
* @param chatId The identifier of a chat.
|
|
2720
2819
|
*/
|
|
2721
2820
|
async deleteChat(chatId) {
|
|
2722
|
-
await
|
|
2821
|
+
await this.#chatManager.deleteChat(chatId);
|
|
2723
2822
|
}
|
|
2724
2823
|
/**
|
|
2725
2824
|
* Get discussion chat suggestions. User-only.
|
|
@@ -2727,7 +2826,7 @@ class Client extends Composer {
|
|
|
2727
2826
|
* @method ch
|
|
2728
2827
|
*/
|
|
2729
2828
|
async getDiscussionChatSuggestions() {
|
|
2730
|
-
return await
|
|
2829
|
+
return await this.#chatManager.getDiscussionChatSuggestions();
|
|
2731
2830
|
}
|
|
2732
2831
|
/**
|
|
2733
2832
|
* Set a channel's discussion chat. User-only.
|
|
@@ -2737,7 +2836,7 @@ class Client extends Composer {
|
|
|
2737
2836
|
* @param discussionChatId The identifier of a chat to use as discussion for the channel.
|
|
2738
2837
|
*/
|
|
2739
2838
|
async setDiscussionChat(chatId, discussionChatId) {
|
|
2740
|
-
await
|
|
2839
|
+
await this.#chatManager.setDiscussionChat(chatId, discussionChatId);
|
|
2741
2840
|
}
|
|
2742
2841
|
/**
|
|
2743
2842
|
* Transfer the ownership of a chat. User-only.
|
|
@@ -2748,7 +2847,7 @@ class Client extends Composer {
|
|
|
2748
2847
|
* @param password The password of the current account.
|
|
2749
2848
|
*/
|
|
2750
2849
|
async transferChatOwnership(chatId, userId, password) {
|
|
2751
|
-
await
|
|
2850
|
+
await this.#chatManager.transferChatOwnership(chatId, userId, password);
|
|
2752
2851
|
}
|
|
2753
2852
|
/**
|
|
2754
2853
|
* Create a forum topic.
|
|
@@ -2759,7 +2858,7 @@ class Client extends Composer {
|
|
|
2759
2858
|
* @returns The created topic.
|
|
2760
2859
|
*/
|
|
2761
2860
|
async createTopic(chatId, title, params) {
|
|
2762
|
-
return await
|
|
2861
|
+
return await this.#forumManager.createTopic(chatId, title, params);
|
|
2763
2862
|
}
|
|
2764
2863
|
/**
|
|
2765
2864
|
* Edit a forum topic.
|
|
@@ -2771,7 +2870,7 @@ class Client extends Composer {
|
|
|
2771
2870
|
* @returns The new topic.
|
|
2772
2871
|
*/
|
|
2773
2872
|
async editTopic(chatId, topicId, title, params) {
|
|
2774
|
-
return await
|
|
2873
|
+
return await this.#forumManager.editTopic(chatId, topicId, title, params);
|
|
2775
2874
|
}
|
|
2776
2875
|
/**
|
|
2777
2876
|
* Hide the general forum topic.
|
|
@@ -2780,7 +2879,7 @@ class Client extends Composer {
|
|
|
2780
2879
|
* @param chatId The identifier of a chat.
|
|
2781
2880
|
*/
|
|
2782
2881
|
async hideGeneralTopic(chatId) {
|
|
2783
|
-
await
|
|
2882
|
+
await this.#forumManager.hideGeneralTopic(chatId);
|
|
2784
2883
|
}
|
|
2785
2884
|
/**
|
|
2786
2885
|
* Show the general forum topic.
|
|
@@ -2789,7 +2888,7 @@ class Client extends Composer {
|
|
|
2789
2888
|
* @param chatId The identifier of a chat.
|
|
2790
2889
|
*/
|
|
2791
2890
|
async showGeneralTopic(chatId) {
|
|
2792
|
-
await
|
|
2891
|
+
await this.#forumManager.showGeneralTopic(chatId);
|
|
2793
2892
|
}
|
|
2794
2893
|
/**
|
|
2795
2894
|
* Close a forum topic.
|
|
@@ -2799,7 +2898,7 @@ class Client extends Composer {
|
|
|
2799
2898
|
* @param topicId The identifier of the topic.
|
|
2800
2899
|
*/
|
|
2801
2900
|
async closeTopic(chatId, topicId) {
|
|
2802
|
-
await
|
|
2901
|
+
await this.#forumManager.closeTopic(chatId, topicId);
|
|
2803
2902
|
}
|
|
2804
2903
|
/**
|
|
2805
2904
|
* Reopen a forum topic.
|
|
@@ -2809,7 +2908,7 @@ class Client extends Composer {
|
|
|
2809
2908
|
* @param topicId The identifier of the topic.
|
|
2810
2909
|
*/
|
|
2811
2910
|
async reopenTopic(chatId, topicId) {
|
|
2812
|
-
await
|
|
2911
|
+
await this.#forumManager.reopenTopic(chatId, topicId);
|
|
2813
2912
|
}
|
|
2814
2913
|
/**
|
|
2815
2914
|
* Pin a forum topic.
|
|
@@ -2819,7 +2918,7 @@ class Client extends Composer {
|
|
|
2819
2918
|
* @param topicId The identifier of the topic.
|
|
2820
2919
|
*/
|
|
2821
2920
|
async pinTopic(chatId, topicId) {
|
|
2822
|
-
await
|
|
2921
|
+
await this.#forumManager.pinTopic(chatId, topicId);
|
|
2823
2922
|
}
|
|
2824
2923
|
/**
|
|
2825
2924
|
* Unpin a forum topic.
|
|
@@ -2829,7 +2928,7 @@ class Client extends Composer {
|
|
|
2829
2928
|
* @param topicId The identifier of the topic.
|
|
2830
2929
|
*/
|
|
2831
2930
|
async unpinTopic(chatId, topicId) {
|
|
2832
|
-
await
|
|
2931
|
+
await this.#forumManager.unpinTopic(chatId, topicId);
|
|
2833
2932
|
}
|
|
2834
2933
|
//
|
|
2835
2934
|
// ========================= CALLBACK QUERIES ========================= //
|
|
@@ -2845,7 +2944,7 @@ class Client extends Composer {
|
|
|
2845
2944
|
* @cache
|
|
2846
2945
|
*/
|
|
2847
2946
|
async sendCallbackQuery(botId, messageId, question) {
|
|
2848
|
-
return await
|
|
2947
|
+
return await this.#callbackQueryManager.sendCallbackQuery(botId, messageId, question);
|
|
2849
2948
|
}
|
|
2850
2949
|
/**
|
|
2851
2950
|
* Answer a callback query. Bot-only.
|
|
@@ -2854,7 +2953,7 @@ class Client extends Composer {
|
|
|
2854
2953
|
* @param id ID of the callback query to answer.
|
|
2855
2954
|
*/
|
|
2856
2955
|
async answerCallbackQuery(id, params) {
|
|
2857
|
-
await
|
|
2956
|
+
await this.#callbackQueryManager.answerCallbackQuery(id, params);
|
|
2858
2957
|
}
|
|
2859
2958
|
//
|
|
2860
2959
|
// ========================= INLINE QUERIES ========================= //
|
|
@@ -2869,7 +2968,7 @@ class Client extends Composer {
|
|
|
2869
2968
|
* @cache
|
|
2870
2969
|
*/
|
|
2871
2970
|
async sendInlineQuery(botId, chatId, params) {
|
|
2872
|
-
return await
|
|
2971
|
+
return await this.#inlineQueryManager.sendInlineQuery(botId, chatId, params);
|
|
2873
2972
|
}
|
|
2874
2973
|
/**
|
|
2875
2974
|
* Answer an inline query. Bot-only.
|
|
@@ -2879,7 +2978,7 @@ class Client extends Composer {
|
|
|
2879
2978
|
* @param results The results to answer with.
|
|
2880
2979
|
*/
|
|
2881
2980
|
async answerInlineQuery(id, results, params) {
|
|
2882
|
-
await
|
|
2981
|
+
await this.#inlineQueryManager.answerInlineQuery(id, results, params);
|
|
2883
2982
|
}
|
|
2884
2983
|
//
|
|
2885
2984
|
// ========================= BOTS ========================= //
|
|
@@ -2890,7 +2989,7 @@ class Client extends Composer {
|
|
|
2890
2989
|
* @method bs
|
|
2891
2990
|
*/
|
|
2892
2991
|
async setMyDescription(params) {
|
|
2893
|
-
await
|
|
2992
|
+
await this.#botInfoManager.setMyDescription(params);
|
|
2894
2993
|
}
|
|
2895
2994
|
/**
|
|
2896
2995
|
* Set the bot's name in the given language. Bot-only.
|
|
@@ -2898,7 +2997,7 @@ class Client extends Composer {
|
|
|
2898
2997
|
* @method bs
|
|
2899
2998
|
*/
|
|
2900
2999
|
async setMyName(params) {
|
|
2901
|
-
await
|
|
3000
|
+
await this.#botInfoManager.setMyName(params);
|
|
2902
3001
|
}
|
|
2903
3002
|
/**
|
|
2904
3003
|
* Set the bot's short description in the given language. Bot-only.
|
|
@@ -2906,7 +3005,7 @@ class Client extends Composer {
|
|
|
2906
3005
|
* @method bs
|
|
2907
3006
|
*/
|
|
2908
3007
|
async setMyShortDescription(params) {
|
|
2909
|
-
await
|
|
3008
|
+
await this.#botInfoManager.setMyShortDescription(params);
|
|
2910
3009
|
}
|
|
2911
3010
|
/**
|
|
2912
3011
|
* Get the bot's description in the given language. Bot-only.
|
|
@@ -2915,7 +3014,7 @@ class Client extends Composer {
|
|
|
2915
3014
|
* @returns The current bot's description in the specified language.
|
|
2916
3015
|
*/
|
|
2917
3016
|
async getMyDescription(params) {
|
|
2918
|
-
return await
|
|
3017
|
+
return await this.#botInfoManager.getMyDescription(params);
|
|
2919
3018
|
}
|
|
2920
3019
|
/**
|
|
2921
3020
|
* Get the bot's name in the given language. Bot-only.
|
|
@@ -2924,7 +3023,7 @@ class Client extends Composer {
|
|
|
2924
3023
|
* @returns The current bot's name in the specified language.
|
|
2925
3024
|
*/
|
|
2926
3025
|
async getMyName(params) {
|
|
2927
|
-
return await
|
|
3026
|
+
return await this.#botInfoManager.getMyName(params);
|
|
2928
3027
|
}
|
|
2929
3028
|
/**
|
|
2930
3029
|
* Get the bot's short description in the given language. Bot-only.
|
|
@@ -2933,7 +3032,7 @@ class Client extends Composer {
|
|
|
2933
3032
|
* @returns The current bot's short description in the specified language.
|
|
2934
3033
|
*/
|
|
2935
3034
|
async getMyShortDescription(params) {
|
|
2936
|
-
return await
|
|
3035
|
+
return await this.#botInfoManager.getMyShortDescription(params);
|
|
2937
3036
|
}
|
|
2938
3037
|
/**
|
|
2939
3038
|
* Set the bot's commands in the given scope and/or language. Bot-only.
|
|
@@ -2942,7 +3041,7 @@ class Client extends Composer {
|
|
|
2942
3041
|
* @param commands The commands to set.
|
|
2943
3042
|
*/
|
|
2944
3043
|
async setMyCommands(commands, params) {
|
|
2945
|
-
await
|
|
3044
|
+
await this.#botInfoManager.setMyCommands(commands, params);
|
|
2946
3045
|
}
|
|
2947
3046
|
/**
|
|
2948
3047
|
* Get the bot's commands in the given scope and/or language. Bot-only.
|
|
@@ -2951,7 +3050,7 @@ class Client extends Composer {
|
|
|
2951
3050
|
* @returns The current bot's commands in the specified language.
|
|
2952
3051
|
*/
|
|
2953
3052
|
async getMyCommands(params) {
|
|
2954
|
-
return await
|
|
3053
|
+
return await this.#botInfoManager.getMyCommands(params);
|
|
2955
3054
|
}
|
|
2956
3055
|
//
|
|
2957
3056
|
// ========================= REACTIONS ========================= //
|
|
@@ -2965,7 +3064,7 @@ class Client extends Composer {
|
|
|
2965
3064
|
* @param reactions The new reactions.
|
|
2966
3065
|
*/
|
|
2967
3066
|
async setReactions(chatId, messageId, reactions, params) {
|
|
2968
|
-
await
|
|
3067
|
+
await this.#messageManager.setReactions(chatId, messageId, reactions, params);
|
|
2969
3068
|
}
|
|
2970
3069
|
/**
|
|
2971
3070
|
* Make a reaction to a message.
|
|
@@ -2976,7 +3075,7 @@ class Client extends Composer {
|
|
|
2976
3075
|
* @param reaction The reaction to add.
|
|
2977
3076
|
*/
|
|
2978
3077
|
async addReaction(chatId, messageId, reaction, params) {
|
|
2979
|
-
await
|
|
3078
|
+
await this.#messageManager.addReaction(chatId, messageId, reaction, params);
|
|
2980
3079
|
}
|
|
2981
3080
|
/**
|
|
2982
3081
|
* Undo a reaction made to a message.
|
|
@@ -2987,7 +3086,7 @@ class Client extends Composer {
|
|
|
2987
3086
|
* @param reaction The reaction to remove.
|
|
2988
3087
|
*/
|
|
2989
3088
|
async removeReaction(chatId, messageId, reaction) {
|
|
2990
|
-
await
|
|
3089
|
+
await this.#messageManager.removeReaction(chatId, messageId, reaction);
|
|
2991
3090
|
}
|
|
2992
3091
|
//
|
|
2993
3092
|
// ========================= STORIES ========================= //
|
|
@@ -3000,7 +3099,7 @@ class Client extends Composer {
|
|
|
3000
3099
|
* @returns The created story.
|
|
3001
3100
|
*/
|
|
3002
3101
|
async createStory(chatId, content, params) {
|
|
3003
|
-
return await
|
|
3102
|
+
return await this.#storyManager.createStory(chatId, content, params);
|
|
3004
3103
|
}
|
|
3005
3104
|
/**
|
|
3006
3105
|
* Retrieve multiple stories. User-only.
|
|
@@ -3014,7 +3113,7 @@ class Client extends Composer {
|
|
|
3014
3113
|
if (!storyIds.length) {
|
|
3015
3114
|
return [];
|
|
3016
3115
|
}
|
|
3017
|
-
return await
|
|
3116
|
+
return await this.#storyManager.getStories(chatId, storyIds);
|
|
3018
3117
|
}
|
|
3019
3118
|
/**
|
|
3020
3119
|
* Retrieve a single story. User-only.
|
|
@@ -3025,7 +3124,7 @@ class Client extends Composer {
|
|
|
3025
3124
|
* @returns The retrieved story.
|
|
3026
3125
|
*/
|
|
3027
3126
|
async getStory(chatId, storyId) {
|
|
3028
|
-
return await
|
|
3127
|
+
return await this.#storyManager.getStory(chatId, storyId);
|
|
3029
3128
|
}
|
|
3030
3129
|
/**
|
|
3031
3130
|
* Delete multiple stories. User-only.
|
|
@@ -3035,7 +3134,7 @@ class Client extends Composer {
|
|
|
3035
3134
|
* @param storyIds The identifiers of the stories to delete.
|
|
3036
3135
|
*/
|
|
3037
3136
|
async deleteStories(chatId, storyIds) {
|
|
3038
|
-
await
|
|
3137
|
+
await this.#storyManager.deleteStories(chatId, storyIds);
|
|
3039
3138
|
}
|
|
3040
3139
|
/**
|
|
3041
3140
|
* Delete a single story. User-only.
|
|
@@ -3045,7 +3144,7 @@ class Client extends Composer {
|
|
|
3045
3144
|
* @param storyId The identifier of the story to delete.
|
|
3046
3145
|
*/
|
|
3047
3146
|
async deleteStory(chatId, storyId) {
|
|
3048
|
-
await
|
|
3147
|
+
await this.#storyManager.deleteStory(chatId, storyId);
|
|
3049
3148
|
}
|
|
3050
3149
|
/**
|
|
3051
3150
|
* Add multiple stories to highlights. User-only.
|
|
@@ -3055,7 +3154,7 @@ class Client extends Composer {
|
|
|
3055
3154
|
* @param storyIds The identifiers of the stories to add to highlights.
|
|
3056
3155
|
*/
|
|
3057
3156
|
async addStoriesToHighlights(chatId, storyIds) {
|
|
3058
|
-
await
|
|
3157
|
+
await this.#storyManager.addStoriesToHighlights(chatId, storyIds);
|
|
3059
3158
|
}
|
|
3060
3159
|
/**
|
|
3061
3160
|
* Add a single story to highlights. User-only.
|
|
@@ -3065,7 +3164,7 @@ class Client extends Composer {
|
|
|
3065
3164
|
* @param storyId The identifier of the story to add to highlights.
|
|
3066
3165
|
*/
|
|
3067
3166
|
async addStoryToHighlights(chatId, storyId) {
|
|
3068
|
-
await
|
|
3167
|
+
await this.#storyManager.addStoryToHighlights(chatId, storyId);
|
|
3069
3168
|
}
|
|
3070
3169
|
/**
|
|
3071
3170
|
* Remove multiple stories from highlights. User-only.
|
|
@@ -3075,7 +3174,7 @@ class Client extends Composer {
|
|
|
3075
3174
|
* @param storyIds The identifiers of the stories to remove from highlights.
|
|
3076
3175
|
*/
|
|
3077
3176
|
async removeStoriesFromHighlights(chatId, storyIds) {
|
|
3078
|
-
await
|
|
3177
|
+
await this.#storyManager.removeStoriesFromHighlights(chatId, storyIds);
|
|
3079
3178
|
}
|
|
3080
3179
|
/**
|
|
3081
3180
|
* Remove a single story from highlights. User-only.
|
|
@@ -3085,7 +3184,7 @@ class Client extends Composer {
|
|
|
3085
3184
|
* @param storyId The identifier of the story to remove from highlights.
|
|
3086
3185
|
*/
|
|
3087
3186
|
async removeStoryFromHighlights(chatId, storyId) {
|
|
3088
|
-
await
|
|
3187
|
+
await this.#storyManager.removeStoryFromHighlights(chatId, storyId);
|
|
3089
3188
|
}
|
|
3090
3189
|
//
|
|
3091
3190
|
// ========================= MISC ========================= //
|
|
@@ -3096,7 +3195,7 @@ class Client extends Composer {
|
|
|
3096
3195
|
* @method mc
|
|
3097
3196
|
*/
|
|
3098
3197
|
async getNetworkStatistics() {
|
|
3099
|
-
return await
|
|
3198
|
+
return await this.#networkStatisticsManager.getNetworkStatistics();
|
|
3100
3199
|
}
|
|
3101
3200
|
/**
|
|
3102
3201
|
* Block a user. User-only.
|
|
@@ -3105,7 +3204,7 @@ class Client extends Composer {
|
|
|
3105
3204
|
* @param userId The identifier of the user to block.
|
|
3106
3205
|
*/
|
|
3107
3206
|
async blockUser(userId) {
|
|
3108
|
-
await
|
|
3207
|
+
await this.#messageManager.blockUser(userId);
|
|
3109
3208
|
}
|
|
3110
3209
|
/**
|
|
3111
3210
|
* Unblock a user. User-only.
|
|
@@ -3114,7 +3213,7 @@ class Client extends Composer {
|
|
|
3114
3213
|
* @param userId The identifier of the user to unblock.
|
|
3115
3214
|
*/
|
|
3116
3215
|
async unblockUser(userId) {
|
|
3117
|
-
await
|
|
3216
|
+
await this.#messageManager.unblockUser(userId);
|
|
3118
3217
|
}
|
|
3119
3218
|
//
|
|
3120
3219
|
// ========================= VIDEO CHATS ========================= //
|
|
@@ -3127,7 +3226,7 @@ class Client extends Composer {
|
|
|
3127
3226
|
* @returns The started video chat.
|
|
3128
3227
|
*/
|
|
3129
3228
|
async startVideoChat(chatId, params) {
|
|
3130
|
-
return await
|
|
3229
|
+
return await this.#videoChatManager.startVideoChat(chatId, params);
|
|
3131
3230
|
}
|
|
3132
3231
|
/**
|
|
3133
3232
|
* Schedule a video chat. User-only.
|
|
@@ -3138,7 +3237,7 @@ class Client extends Composer {
|
|
|
3138
3237
|
* @returns The scheduled video chat.
|
|
3139
3238
|
*/
|
|
3140
3239
|
async scheduleVideoChat(chatId, startAt, params) {
|
|
3141
|
-
return await
|
|
3240
|
+
return await this.#videoChatManager.scheduleVideoChat(chatId, startAt, params);
|
|
3142
3241
|
}
|
|
3143
3242
|
/**
|
|
3144
3243
|
* Join a video chat. User-only.
|
|
@@ -3149,7 +3248,7 @@ class Client extends Composer {
|
|
|
3149
3248
|
* @returns Parameters to be passed to the used WebRTC library.
|
|
3150
3249
|
*/
|
|
3151
3250
|
async joinVideoChat(id, params_, params) {
|
|
3152
|
-
return await
|
|
3251
|
+
return await this.#videoChatManager.joinVideoChat(id, params_, params);
|
|
3153
3252
|
}
|
|
3154
3253
|
/**
|
|
3155
3254
|
* Leave a video chat. User-only.
|
|
@@ -3158,7 +3257,7 @@ class Client extends Composer {
|
|
|
3158
3257
|
* @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
|
|
3159
3258
|
*/
|
|
3160
3259
|
async leaveVideoChat(id) {
|
|
3161
|
-
await
|
|
3260
|
+
await this.#videoChatManager.leaveVideoChat(id);
|
|
3162
3261
|
}
|
|
3163
3262
|
/**
|
|
3164
3263
|
* Join a live stream. User-only.
|
|
@@ -3167,7 +3266,7 @@ class Client extends Composer {
|
|
|
3167
3266
|
* @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
|
|
3168
3267
|
*/
|
|
3169
3268
|
async joinLiveStream(id) {
|
|
3170
|
-
await
|
|
3269
|
+
await this.#videoChatManager.joinLiveStream(id);
|
|
3171
3270
|
}
|
|
3172
3271
|
/**
|
|
3173
3272
|
* Get a video chat. User-only.
|
|
@@ -3177,7 +3276,7 @@ class Client extends Composer {
|
|
|
3177
3276
|
* @cache
|
|
3178
3277
|
*/
|
|
3179
3278
|
async getVideoChat(id) {
|
|
3180
|
-
return await
|
|
3279
|
+
return await this.#videoChatManager.getVideoChat(id);
|
|
3181
3280
|
}
|
|
3182
3281
|
/**
|
|
3183
3282
|
* Get live stream channels. User-only.
|
|
@@ -3186,7 +3285,7 @@ class Client extends Composer {
|
|
|
3186
3285
|
* @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
|
|
3187
3286
|
*/
|
|
3188
3287
|
async getLiveStreamChannels(id) {
|
|
3189
|
-
return await
|
|
3288
|
+
return await this.#videoChatManager.getLiveStreamChannels(id);
|
|
3190
3289
|
}
|
|
3191
3290
|
/**
|
|
3192
3291
|
* Download a live stream chunk. User-only.
|
|
@@ -3198,7 +3297,7 @@ class Client extends Composer {
|
|
|
3198
3297
|
* @param timestamp Millisecond timestamp of the chunk to download.
|
|
3199
3298
|
*/
|
|
3200
3299
|
async *downloadLiveStreamChunk(id, channelId, scale, timestamp, params) {
|
|
3201
|
-
yield*
|
|
3300
|
+
yield* this.#videoChatManager.downloadLiveStreamChunk(id, channelId, scale, timestamp, params);
|
|
3202
3301
|
}
|
|
3203
3302
|
//
|
|
3204
3303
|
// ========================= PAYMENTS ========================= //
|
|
@@ -3211,7 +3310,7 @@ class Client extends Composer {
|
|
|
3211
3310
|
* @param ok Whether the checkout is going to be processed.
|
|
3212
3311
|
*/
|
|
3213
3312
|
async answerPreCheckoutQuery(preCheckoutQueryId, ok, params) {
|
|
3214
|
-
await
|
|
3313
|
+
await this.#paymentManager.answerPreCheckoutQuery(preCheckoutQueryId, ok, params);
|
|
3215
3314
|
}
|
|
3216
3315
|
/**
|
|
3217
3316
|
* Refund a star payment. Bot-only.
|
|
@@ -3221,7 +3320,7 @@ class Client extends Composer {
|
|
|
3221
3320
|
* @param telegramPaymentChargeId The identifier of the charge.
|
|
3222
3321
|
*/
|
|
3223
3322
|
async refundStarPayment(userId, telegramPaymentChargeId) {
|
|
3224
|
-
await
|
|
3323
|
+
await this.#paymentManager.refundStarPayment(userId, telegramPaymentChargeId);
|
|
3225
3324
|
}
|
|
3226
3325
|
//
|
|
3227
3326
|
// ========================= CONTACTS ========================= //
|
|
@@ -3232,7 +3331,7 @@ class Client extends Composer {
|
|
|
3232
3331
|
* @method co
|
|
3233
3332
|
*/
|
|
3234
3333
|
async getContacts() {
|
|
3235
|
-
return await
|
|
3334
|
+
return await this.#accountManager.getContacts();
|
|
3236
3335
|
}
|
|
3237
3336
|
/**
|
|
3238
3337
|
* Delete multiple contacts. User-only.
|
|
@@ -3241,7 +3340,7 @@ class Client extends Composer {
|
|
|
3241
3340
|
* @param userIds The identifiers of contacts to delete.
|
|
3242
3341
|
*/
|
|
3243
3342
|
async deleteContacts(userIds) {
|
|
3244
|
-
await
|
|
3343
|
+
await this.#accountManager.deleteContacts(userIds);
|
|
3245
3344
|
}
|
|
3246
3345
|
/**
|
|
3247
3346
|
* Delete a single contact. User-only.
|
|
@@ -3250,7 +3349,7 @@ class Client extends Composer {
|
|
|
3250
3349
|
* @param userId The identifier of the contact to delete.
|
|
3251
3350
|
*/
|
|
3252
3351
|
async deleteContact(userId) {
|
|
3253
|
-
await
|
|
3352
|
+
await this.#accountManager.deleteContact(userId);
|
|
3254
3353
|
}
|
|
3255
3354
|
/**
|
|
3256
3355
|
* Add a contact. User-only.
|
|
@@ -3259,7 +3358,7 @@ class Client extends Composer {
|
|
|
3259
3358
|
* @param userId The identifier of the user to add as contact.
|
|
3260
3359
|
*/
|
|
3261
3360
|
async addContact(userId, params) {
|
|
3262
|
-
await
|
|
3361
|
+
await this.#accountManager.addContact(userId, params);
|
|
3263
3362
|
}
|
|
3264
3363
|
//
|
|
3265
3364
|
// ========================= TRANSLATIONS ========================= //
|
|
@@ -3271,7 +3370,7 @@ class Client extends Composer {
|
|
|
3271
3370
|
* @cache
|
|
3272
3371
|
*/
|
|
3273
3372
|
async getTranslations(params) {
|
|
3274
|
-
return await
|
|
3373
|
+
return await this.#translationsManager.getTranslations(params);
|
|
3275
3374
|
}
|
|
3276
3375
|
//
|
|
3277
3376
|
// ========================= GIFTS ========================= //
|
|
@@ -3282,7 +3381,7 @@ class Client extends Composer {
|
|
|
3282
3381
|
* @method gf
|
|
3283
3382
|
*/
|
|
3284
3383
|
async getGifts() {
|
|
3285
|
-
return await
|
|
3384
|
+
return await this.#giftManager.getGifts();
|
|
3286
3385
|
}
|
|
3287
3386
|
/**
|
|
3288
3387
|
* Get gifts claimed by a user or a channel. User-only.
|
|
@@ -3291,7 +3390,7 @@ class Client extends Composer {
|
|
|
3291
3390
|
* @param chatId The identifier of a user or a channel to get gifts for.
|
|
3292
3391
|
*/
|
|
3293
3392
|
async getClaimedGifts(chatId, params) {
|
|
3294
|
-
return await
|
|
3393
|
+
return await this.#giftManager.getClaimedGifts(chatId, params);
|
|
3295
3394
|
}
|
|
3296
3395
|
/**
|
|
3297
3396
|
* Send a gift.
|
|
@@ -3301,7 +3400,7 @@ class Client extends Composer {
|
|
|
3301
3400
|
* @param giftId The identifier of the gift to send.
|
|
3302
3401
|
*/
|
|
3303
3402
|
async sendGift(chatId, giftId, params) {
|
|
3304
|
-
await
|
|
3403
|
+
await this.#giftManager.sendGift(chatId, giftId, params);
|
|
3305
3404
|
}
|
|
3306
3405
|
/**
|
|
3307
3406
|
* Sell a gift.
|
|
@@ -3311,7 +3410,7 @@ class Client extends Composer {
|
|
|
3311
3410
|
* @param messageId The identifier of the service message announcing the receival of the gift.
|
|
3312
3411
|
*/
|
|
3313
3412
|
async sellGift(userId, messageId) {
|
|
3314
|
-
await
|
|
3413
|
+
await this.#giftManager.sellGift(userId, messageId);
|
|
3315
3414
|
}
|
|
3316
3415
|
/**
|
|
3317
3416
|
* Get a gift using its slug.
|
|
@@ -3320,125 +3419,7 @@ class Client extends Composer {
|
|
|
3320
3419
|
* @param slug The slug of a gift.
|
|
3321
3420
|
*/
|
|
3322
3421
|
async getGift(slug) {
|
|
3323
|
-
return await
|
|
3422
|
+
return await this.#giftManager.getGift(slug);
|
|
3324
3423
|
}
|
|
3325
3424
|
}
|
|
3326
3425
|
exports.Client = Client;
|
|
3327
|
-
_Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
|
|
3328
|
-
if (__classPrivateFieldGet(this, _Client_disableUpdates, "f") && !("authorizationState" in update) && !("connectionState" in update)) {
|
|
3329
|
-
return;
|
|
3330
|
-
}
|
|
3331
|
-
try {
|
|
3332
|
-
await this.middleware()(await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, update), _0_utilities_js_1.resolve);
|
|
3333
|
-
}
|
|
3334
|
-
catch (err) {
|
|
3335
|
-
__classPrivateFieldGet(this, _Client_L, "f").error("Failed to handle update:", err);
|
|
3336
|
-
throw err;
|
|
3337
|
-
}
|
|
3338
|
-
}, _Client_queueHandleCtxUpdate = function _Client_queueHandleCtxUpdate(update) {
|
|
3339
|
-
__classPrivateFieldGet(this, _Client_updateManager, "f").getHandleUpdateQueue(_2_update_manager_js_1.UpdateManager.MAIN_BOX_ID).add(async () => {
|
|
3340
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, update);
|
|
3341
|
-
});
|
|
3342
|
-
}, _Client_handleUpdate = async function _Client_handleUpdate(update) {
|
|
3343
|
-
const promises = new Array();
|
|
3344
|
-
if (_2_tl_js_1.Api.is("updateUserName", update)) {
|
|
3345
|
-
await this.messageStorage.updateUsernames(Number(update.user_id), update.usernames.map((v) => v.username));
|
|
3346
|
-
const peer = { ...update, _: "peerUser" };
|
|
3347
|
-
const entity = await this[getEntity](peer);
|
|
3348
|
-
if (entity != null) {
|
|
3349
|
-
entity.usernames = update.usernames;
|
|
3350
|
-
entity.first_name = update.first_name;
|
|
3351
|
-
entity.last_name = update.last_name;
|
|
3352
|
-
await this.messageStorage.setEntity(entity);
|
|
3353
|
-
}
|
|
3354
|
-
}
|
|
3355
|
-
if (__classPrivateFieldGet(this, _Client_messageManager, "f").canHandleUpdate(update)) {
|
|
3356
|
-
promises.push(() => __classPrivateFieldGet(this, _Client_messageManager, "f").handleUpdate(update));
|
|
3357
|
-
}
|
|
3358
|
-
if (__classPrivateFieldGet(this, _Client_chatManager, "f").canHandleUpdate(update)) {
|
|
3359
|
-
promises.push(() => __classPrivateFieldGet(this, _Client_chatManager, "f").handleUpdate(update));
|
|
3360
|
-
}
|
|
3361
|
-
if (__classPrivateFieldGet(this, _Client_pollManager, "f").canHandleUpdate(update)) {
|
|
3362
|
-
promises.push(() => __classPrivateFieldGet(this, _Client_pollManager, "f").handleUpdate(update));
|
|
3363
|
-
}
|
|
3364
|
-
if (__classPrivateFieldGet(this, _Client_videoChatManager, "f").canHandleUpdate(update)) {
|
|
3365
|
-
promises.push(() => __classPrivateFieldGet(this, _Client_videoChatManager, "f").handleUpdate(update));
|
|
3366
|
-
}
|
|
3367
|
-
if (__classPrivateFieldGet(this, _Client_callbackQueryManager, "f").canHandleUpdate(update)) {
|
|
3368
|
-
promises.push(() => __classPrivateFieldGet(this, _Client_callbackQueryManager, "f").handleUpdate(update));
|
|
3369
|
-
}
|
|
3370
|
-
if (__classPrivateFieldGet(this, _Client_inlineQueryManager, "f").canHandleUpdate(update)) {
|
|
3371
|
-
promises.push(() => __classPrivateFieldGet(this, _Client_inlineQueryManager, "f").handleUpdate(update));
|
|
3372
|
-
}
|
|
3373
|
-
if (__classPrivateFieldGet(this, _Client_linkPreviewManager, "f").canHandleUpdate(update)) {
|
|
3374
|
-
promises.push(() => __classPrivateFieldGet(this, _Client_linkPreviewManager, "f").handleUpdate(update));
|
|
3375
|
-
}
|
|
3376
|
-
if (__classPrivateFieldGet(this, _Client_reactionManager, "f").canHandleUpdate(update)) {
|
|
3377
|
-
promises.push(() => __classPrivateFieldGet(this, _Client_reactionManager, "f").handleUpdate(update));
|
|
3378
|
-
}
|
|
3379
|
-
if (__classPrivateFieldGet(this, _Client_chatListManager, "f").canHandleUpdate(update)) {
|
|
3380
|
-
promises.push(() => __classPrivateFieldGet(this, _Client_chatListManager, "f").handleUpdate(update));
|
|
3381
|
-
}
|
|
3382
|
-
if (__classPrivateFieldGet(this, _Client_storyManager, "f").canHandleUpdate(update)) {
|
|
3383
|
-
promises.push(() => __classPrivateFieldGet(this, _Client_storyManager, "f").handleUpdate(update));
|
|
3384
|
-
}
|
|
3385
|
-
if (__classPrivateFieldGet(this, _Client_businessConnectionManager, "f").canHandleUpdate(update)) {
|
|
3386
|
-
promises.push(() => __classPrivateFieldGet(this, _Client_businessConnectionManager, "f").handleUpdate(update));
|
|
3387
|
-
}
|
|
3388
|
-
if (__classPrivateFieldGet(this, _Client_storyManager, "f").canHandleUpdate(update)) {
|
|
3389
|
-
promises.push(() => __classPrivateFieldGet(this, _Client_storyManager, "f").handleUpdate(update));
|
|
3390
|
-
}
|
|
3391
|
-
if (__classPrivateFieldGet(this, _Client_paymentManager, "f").canHandleUpdate(update)) {
|
|
3392
|
-
promises.push(() => __classPrivateFieldGet(this, _Client_paymentManager, "f").handleUpdate(update));
|
|
3393
|
-
}
|
|
3394
|
-
if (__classPrivateFieldGet(this, _Client_translationsManager, "f").canHandleUpdate(update)) {
|
|
3395
|
-
promises.push(() => __classPrivateFieldGet(this, _Client_translationsManager, "f").handleUpdate(update));
|
|
3396
|
-
}
|
|
3397
|
-
return () => Promise.resolve().then(async () => {
|
|
3398
|
-
const updates = new Array();
|
|
3399
|
-
for (const promise of promises) {
|
|
3400
|
-
try {
|
|
3401
|
-
const update = await promise();
|
|
3402
|
-
if (update) {
|
|
3403
|
-
updates.push(update);
|
|
3404
|
-
}
|
|
3405
|
-
}
|
|
3406
|
-
catch (err) {
|
|
3407
|
-
__classPrivateFieldGet(this, _Client_L, "f").error("failed to construct update:", err);
|
|
3408
|
-
}
|
|
3409
|
-
}
|
|
3410
|
-
for (const update of updates) {
|
|
3411
|
-
try {
|
|
3412
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, update);
|
|
3413
|
-
}
|
|
3414
|
-
finally {
|
|
3415
|
-
if ("deletedMessages" in update) {
|
|
3416
|
-
for (const { chatId, messageId } of update.deletedMessages) {
|
|
3417
|
-
await this.messageStorage.setMessage(chatId, messageId, null);
|
|
3418
|
-
await __classPrivateFieldGet(this, _Client_chatListManager, "f").reassignChatLastMessage(chatId);
|
|
3419
|
-
}
|
|
3420
|
-
}
|
|
3421
|
-
}
|
|
3422
|
-
}
|
|
3423
|
-
});
|
|
3424
|
-
}, _Client_getMe = async function _Client_getMe() {
|
|
3425
|
-
if (__classPrivateFieldGet(this, _Client_lastGetMe, "f") != null) {
|
|
3426
|
-
return __classPrivateFieldGet(this, _Client_lastGetMe, "f");
|
|
3427
|
-
}
|
|
3428
|
-
else {
|
|
3429
|
-
const user = await this.getMe();
|
|
3430
|
-
__classPrivateFieldSet(this, _Client_lastGetMe, user, "f");
|
|
3431
|
-
return user;
|
|
3432
|
-
}
|
|
3433
|
-
}, _Client_onConnectionStateChange = function _Client_onConnectionStateChange(connected) {
|
|
3434
|
-
if (__classPrivateFieldGet(this, _Client_lastConnectionState, "f") != connected) {
|
|
3435
|
-
if (connected) {
|
|
3436
|
-
if (__classPrivateFieldGet(this, _Client_previouslyConnected, "f")) {
|
|
3437
|
-
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("reconnect"));
|
|
3438
|
-
}
|
|
3439
|
-
__classPrivateFieldSet(this, _Client_previouslyConnected, true, "f");
|
|
3440
|
-
}
|
|
3441
|
-
const connectionState = connected ? "ready" : "notConnected";
|
|
3442
|
-
__classPrivateFieldGet(this, _Client_instances, "m", _Client_queueHandleCtxUpdate).call(this, { connectionState });
|
|
3443
|
-
}
|
|
3444
|
-
};
|