@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
|
@@ -17,18 +17,6 @@
|
|
|
17
17
|
* You should have received a copy of the GNU Lesser General Public License
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
21
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
22
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
23
|
-
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");
|
|
24
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
25
|
-
};
|
|
26
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
27
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
28
|
-
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");
|
|
29
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
30
|
-
};
|
|
31
|
-
var _ChatManager_instances, _ChatManager_c, _ChatManager_toggleJoinRequests, _ChatManager_toggleSlowMode;
|
|
32
20
|
import { unreachable } from "../0_deps.js";
|
|
33
21
|
import { InputError } from "../0_errors.js";
|
|
34
22
|
import { Api } from "../2_tl.js";
|
|
@@ -43,18 +31,17 @@ const chatManagerUpdates = [
|
|
|
43
31
|
"updateBotChatInviteRequester",
|
|
44
32
|
];
|
|
45
33
|
export class ChatManager {
|
|
34
|
+
#c;
|
|
46
35
|
constructor(c) {
|
|
47
|
-
|
|
48
|
-
_ChatManager_c.set(this, void 0);
|
|
49
|
-
__classPrivateFieldSet(this, _ChatManager_c, c, "f");
|
|
36
|
+
this.#c = c;
|
|
50
37
|
}
|
|
51
38
|
canHandleUpdate(update) {
|
|
52
39
|
return Api.isOneOf(chatManagerUpdates, update);
|
|
53
40
|
}
|
|
54
41
|
async handleUpdate(update) {
|
|
55
42
|
if (Api.is("updateChannelParticipant", update) || Api.is("updateChatParticipant", update)) {
|
|
56
|
-
const chatMember = await constructChatMemberUpdated(update,
|
|
57
|
-
const selfId = await
|
|
43
|
+
const chatMember = await constructChatMemberUpdated(update, this.#c.getEntity);
|
|
44
|
+
const selfId = await this.#c.getSelfId();
|
|
58
45
|
if (chatMember.oldChatMember.user.id == selfId) {
|
|
59
46
|
return { myChatMember: chatMember };
|
|
60
47
|
}
|
|
@@ -63,51 +50,56 @@ export class ChatManager {
|
|
|
63
50
|
}
|
|
64
51
|
}
|
|
65
52
|
if (Api.is("updateBotChatInviteRequester", update)) {
|
|
66
|
-
const joinRequest = await constructJoinRequest(update,
|
|
53
|
+
const joinRequest = await constructJoinRequest(update, this.#c.getEntity);
|
|
67
54
|
return { joinRequest };
|
|
68
55
|
}
|
|
69
56
|
return null;
|
|
70
57
|
}
|
|
58
|
+
// JOIN REQUESTS //
|
|
59
|
+
async #toggleJoinRequests(chatId, enabled) {
|
|
60
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
61
|
+
await this.#c.invoke({ _: "channels.toggleJoinRequest", channel, enabled });
|
|
62
|
+
}
|
|
71
63
|
async approveJoinRequest(chatId, userId) {
|
|
72
|
-
await
|
|
64
|
+
await this.#c.invoke({
|
|
73
65
|
_: "messages.hideChatJoinRequest",
|
|
74
|
-
peer: await
|
|
75
|
-
user_id: await
|
|
66
|
+
peer: await this.#c.getInputPeer(chatId),
|
|
67
|
+
user_id: await this.#c.getInputUser(userId),
|
|
76
68
|
approved: true,
|
|
77
69
|
});
|
|
78
70
|
}
|
|
79
71
|
async declineJoinRequest(chatId, userId) {
|
|
80
|
-
await
|
|
72
|
+
await this.#c.invoke({
|
|
81
73
|
_: "messages.hideChatJoinRequest",
|
|
82
|
-
peer: await
|
|
83
|
-
user_id: await
|
|
74
|
+
peer: await this.#c.getInputPeer(chatId),
|
|
75
|
+
user_id: await this.#c.getInputUser(userId),
|
|
84
76
|
});
|
|
85
77
|
}
|
|
86
78
|
async approveJoinRequests(chatId, params) {
|
|
87
|
-
|
|
88
|
-
await
|
|
79
|
+
this.#c.storage.assertUser("approveJoinRequests");
|
|
80
|
+
await this.#c.invoke({
|
|
89
81
|
_: "messages.hideAllChatJoinRequests",
|
|
90
|
-
peer: await
|
|
82
|
+
peer: await this.#c.getInputPeer(chatId),
|
|
91
83
|
approved: true,
|
|
92
84
|
link: params?.inviteLink,
|
|
93
85
|
});
|
|
94
86
|
}
|
|
95
87
|
async declineJoinRequests(chatId, params) {
|
|
96
|
-
|
|
97
|
-
await
|
|
88
|
+
this.#c.storage.assertUser("declineJoinRequests");
|
|
89
|
+
await this.#c.invoke({
|
|
98
90
|
_: "messages.hideAllChatJoinRequests",
|
|
99
|
-
peer: await
|
|
91
|
+
peer: await this.#c.getInputPeer(chatId),
|
|
100
92
|
link: params?.inviteLink,
|
|
101
93
|
});
|
|
102
94
|
}
|
|
103
95
|
async getJoinRequests(chatId, params) {
|
|
104
|
-
|
|
96
|
+
this.#c.storage.assertUser("getJoinRequests");
|
|
105
97
|
if (typeof params?.inviteLink === "string" && typeof params?.search === "string") {
|
|
106
98
|
throw new InputError("inviteLink and search cannot be specified together.");
|
|
107
99
|
}
|
|
108
|
-
const peer = await
|
|
109
|
-
const offset_user = params?.fromUserId ? await
|
|
110
|
-
const { importers } = await
|
|
100
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
101
|
+
const offset_user = params?.fromUserId ? await this.#c.getInputUser(params.fromUserId) : { _: "inputUserEmpty" };
|
|
102
|
+
const { importers } = await this.#c.invoke({
|
|
111
103
|
_: "messages.getChatInviteImporters",
|
|
112
104
|
requested: true,
|
|
113
105
|
peer,
|
|
@@ -118,48 +110,48 @@ export class ChatManager {
|
|
|
118
110
|
limit: getLimit(params?.limit),
|
|
119
111
|
});
|
|
120
112
|
const peer_ = inputPeerToPeer(peer);
|
|
121
|
-
return await Promise.all(importers.map((v) => constructJoinRequest2(peer_, v,
|
|
113
|
+
return await Promise.all(importers.map((v) => constructJoinRequest2(peer_, v, this.#c.getEntity)));
|
|
122
114
|
}
|
|
123
115
|
// INVITE LINKS //
|
|
124
116
|
async createInviteLink(chatId, params) {
|
|
125
117
|
if (params?.requireApproval && params?.limit) {
|
|
126
118
|
throw new InputError("requireApproval cannot be true while limit is specified.");
|
|
127
119
|
}
|
|
128
|
-
const result = await
|
|
129
|
-
return await constructInviteLink(Api.as("chatInviteExported", result),
|
|
120
|
+
const result = await this.#c.invoke({ _: "messages.exportChatInvite", peer: await this.#c.getInputPeer(chatId), title: params?.title, expire_date: params?.expireAt, request_needed: params?.requireApproval ? true : undefined, usage_limit: params?.limit });
|
|
121
|
+
return await constructInviteLink(Api.as("chatInviteExported", result), this.#c.getEntity);
|
|
130
122
|
}
|
|
131
123
|
async getCreatedInviteLinks(chatId, params) {
|
|
132
|
-
|
|
133
|
-
const { invites } = await
|
|
134
|
-
return await Promise.all(invites.map((v) => Api.as("chatInviteExported", v)).map((v) => constructInviteLink(v,
|
|
124
|
+
this.#c.storage.assertUser("getCreatedInviteLinks");
|
|
125
|
+
const { invites } = await this.#c.invoke({ _: "messages.getExportedChatInvites", peer: await this.#c.getInputPeer(chatId), revoked: params?.revoked ? true : undefined, admin_id: params?.by ? await this.#c.getInputUser(params.by) : { _: "inputUserEmpty" }, limit: getLimit(params?.limit), offset_date: params?.afterDate, offset_link: params?.afterInviteLink });
|
|
126
|
+
return await Promise.all(invites.map((v) => Api.as("chatInviteExported", v)).map((v) => constructInviteLink(v, this.#c.getEntity)));
|
|
135
127
|
}
|
|
136
128
|
// JOINING AND LEAVING CHATS //
|
|
137
129
|
async joinChat(chatId) {
|
|
138
|
-
|
|
139
|
-
const peer = await
|
|
130
|
+
this.#c.storage.assertUser("joinChat");
|
|
131
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
140
132
|
if (canBeInputUser(peer)) {
|
|
141
133
|
throw new InputError("Cannot join private chats.");
|
|
142
134
|
}
|
|
143
135
|
else if (canBeInputChannel(peer)) {
|
|
144
|
-
await
|
|
136
|
+
await this.#c.invoke({ _: "channels.joinChannel", channel: toInputChannel(peer) });
|
|
145
137
|
}
|
|
146
138
|
else if (Api.is("inputPeerChat", peer)) {
|
|
147
|
-
await
|
|
139
|
+
await this.#c.invoke({ _: "messages.addChatUser", chat_id: peer.chat_id, user_id: { _: "inputUserSelf" }, fwd_limit: 0 }); // TODO: use potential high-level method for adding participants to chats
|
|
148
140
|
}
|
|
149
141
|
else {
|
|
150
142
|
unreachable();
|
|
151
143
|
}
|
|
152
144
|
}
|
|
153
145
|
async leaveChat(chatId) {
|
|
154
|
-
const peer = await
|
|
146
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
155
147
|
if (canBeInputUser(peer)) {
|
|
156
148
|
throw new InputError("Cannot leave private chats.");
|
|
157
149
|
}
|
|
158
150
|
else if (canBeInputChannel(peer)) {
|
|
159
|
-
await
|
|
151
|
+
await this.#c.invoke({ _: "channels.leaveChannel", channel: toInputChannel(peer) });
|
|
160
152
|
}
|
|
161
153
|
else if (Api.is("inputPeerChat", peer)) {
|
|
162
|
-
await
|
|
154
|
+
await this.#c.invoke({ _: "messages.deleteChatUser", chat_id: peer.chat_id, user_id: { _: "inputUserSelf" } }); // TODO: use potential high-level method for adding participants to chats
|
|
163
155
|
}
|
|
164
156
|
else {
|
|
165
157
|
unreachable();
|
|
@@ -167,21 +159,21 @@ export class ChatManager {
|
|
|
167
159
|
}
|
|
168
160
|
// RESTRICTING, BANNING, AND UNBANNING CHAT MEMBERS //
|
|
169
161
|
async banChatMember(chatId, memberId, params) {
|
|
170
|
-
const chat = await
|
|
162
|
+
const chat = await this.#c.getInputPeer(chatId);
|
|
171
163
|
if (!(Api.is("inputPeerChannel", chat)) && !(Api.is("inputPeerChat", chat))) {
|
|
172
164
|
throw new InputError("Expected a channel, supergroup, or group ID.");
|
|
173
165
|
}
|
|
174
|
-
const member = await
|
|
166
|
+
const member = await this.#c.getInputPeer(memberId);
|
|
175
167
|
if (Api.is("inputPeerChannel", chat)) {
|
|
176
168
|
if (params?.deleteMessages) {
|
|
177
169
|
try {
|
|
178
|
-
await
|
|
170
|
+
await this.#c.messageManager.deleteChatMemberMessages(chatId, memberId);
|
|
179
171
|
}
|
|
180
172
|
catch {
|
|
181
173
|
//
|
|
182
174
|
}
|
|
183
175
|
}
|
|
184
|
-
await
|
|
176
|
+
await this.#c.invoke({
|
|
185
177
|
_: "channels.editBanned",
|
|
186
178
|
channel: { ...chat, _: "inputChannel" },
|
|
187
179
|
participant: member,
|
|
@@ -203,178 +195,182 @@ export class ChatManager {
|
|
|
203
195
|
if (!canBeInputUser(member)) {
|
|
204
196
|
throw new InputError(`Invalid user ID: ${memberId}`);
|
|
205
197
|
}
|
|
206
|
-
await
|
|
198
|
+
await this.#c.invoke({ _: "messages.deleteChatUser", chat_id: chat.chat_id, user_id: toInputUser(member), revoke_history: params?.deleteMessages ? true : undefined });
|
|
207
199
|
}
|
|
208
200
|
}
|
|
209
201
|
async unbanChatMember(chatId, memberId) {
|
|
210
|
-
const channel = await
|
|
211
|
-
const member = await
|
|
212
|
-
await
|
|
202
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
203
|
+
const member = await this.#c.getInputPeer(memberId);
|
|
204
|
+
await this.#c.invoke({ _: "channels.editBanned", channel, participant: member, banned_rights: ({ _: "chatBannedRights", until_date: 0 }) });
|
|
213
205
|
}
|
|
214
206
|
async setChatMemberRights(chatId, memberId, params) {
|
|
215
|
-
const channel = await
|
|
216
|
-
const member = await
|
|
217
|
-
await
|
|
207
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
208
|
+
const member = await this.#c.getInputPeer(memberId);
|
|
209
|
+
await this.#c.invoke({ _: "channels.editBanned", channel, participant: member, banned_rights: chatMemberRightsToTlObject(params?.rights, params?.until) });
|
|
218
210
|
}
|
|
219
211
|
// CHAT SETTINGS //
|
|
220
212
|
async setAvailableReactions(chatId, availableReactions) {
|
|
221
|
-
await
|
|
213
|
+
await this.#c.invoke({ _: "messages.setChatAvailableReactions", peer: await this.#c.getInputPeer(chatId), available_reactions: availableReactions == "none" ? { _: "chatReactionsNone" } : availableReactions == "all" ? { _: "chatReactionsAll" } : Array.isArray(availableReactions) ? ({ _: "chatReactionsSome", reactions: availableReactions.map((v) => reactionToTlObject(v)) }) : unreachable() });
|
|
222
214
|
}
|
|
223
215
|
async setBoostsRequiredToCircumventRestrictions(chatId, boosts) {
|
|
224
|
-
|
|
225
|
-
const channel = await
|
|
226
|
-
await
|
|
216
|
+
this.#c.storage.assertUser("setBoostsRequiredToCircumventRestrictions");
|
|
217
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
218
|
+
await this.#c.invoke({ _: "channels.setBoostsToUnblockRestrictions", channel, boosts });
|
|
227
219
|
}
|
|
228
220
|
async enableJoinRequests(chatId) {
|
|
229
|
-
|
|
230
|
-
await
|
|
221
|
+
this.#c.storage.assertUser("enableJoinRequests");
|
|
222
|
+
await this.#toggleJoinRequests(chatId, true);
|
|
231
223
|
}
|
|
232
224
|
async disableJoinRequests(chatId) {
|
|
233
|
-
|
|
234
|
-
await
|
|
225
|
+
this.#c.storage.assertUser("disableJoinRequests");
|
|
226
|
+
await this.#toggleJoinRequests(chatId, false);
|
|
235
227
|
}
|
|
236
228
|
async setChatStickerSet(chatId, setName) {
|
|
237
|
-
const channel = await
|
|
238
|
-
await
|
|
229
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
230
|
+
await this.#c.invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetShortName", short_name: setName } });
|
|
239
231
|
}
|
|
240
232
|
async deleteChatStickerSet(chatId) {
|
|
241
|
-
const channel = await
|
|
242
|
-
await
|
|
233
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
234
|
+
await this.#c.invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetEmpty" } });
|
|
243
235
|
}
|
|
244
236
|
// CHAT PHOTOS //
|
|
245
237
|
async deleteChatPhoto(chatId) {
|
|
246
|
-
const peer = await
|
|
238
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
247
239
|
if (!(canBeInputChannel(peer)) && !(Api.is("inputPeerChat", peer))) {
|
|
248
240
|
unreachable();
|
|
249
241
|
}
|
|
250
242
|
if (canBeInputChannel(peer)) {
|
|
251
|
-
await
|
|
243
|
+
await this.#c.invoke({ _: "channels.editPhoto", channel: toInputChannel(peer), photo: { _: "inputChatPhotoEmpty" } });
|
|
252
244
|
}
|
|
253
245
|
else if (Api.is("inputPeerChat", peer)) {
|
|
254
|
-
await
|
|
246
|
+
await this.#c.invoke({ _: "messages.editChatPhoto", chat_id: peer.chat_id, photo: { _: "inputChatPhotoEmpty" } });
|
|
255
247
|
}
|
|
256
248
|
}
|
|
257
249
|
async setChatPhoto(chatId, photo, params) {
|
|
258
|
-
const peer = await
|
|
250
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
259
251
|
if (!(canBeInputChannel(peer)) && !(Api.is("inputPeerChat", peer))) {
|
|
260
252
|
unreachable();
|
|
261
253
|
}
|
|
262
|
-
const file = await
|
|
254
|
+
const file = await this.#c.fileManager.upload(photo, params);
|
|
263
255
|
const photo_ = { _: "inputChatUploadedPhoto", file };
|
|
264
256
|
if (canBeInputChannel(peer)) {
|
|
265
|
-
await
|
|
257
|
+
await this.#c.invoke({ _: "channels.editPhoto", channel: toInputChannel(peer), photo: photo_ });
|
|
266
258
|
}
|
|
267
259
|
else if (Api.is("inputPeerChat", peer)) {
|
|
268
|
-
await
|
|
260
|
+
await this.#c.invoke({ _: "messages.editChatPhoto", chat_id: peer.chat_id, photo: photo_ });
|
|
269
261
|
}
|
|
270
262
|
}
|
|
271
263
|
// INVITING MEMBERS //
|
|
272
264
|
async addChatMember(chatId, userId, params) {
|
|
273
|
-
|
|
274
|
-
const chat = await
|
|
265
|
+
this.#c.storage.assertUser("addChatMember");
|
|
266
|
+
const chat = await this.#c.getInputPeer(chatId);
|
|
275
267
|
if (Api.isOneOf(["inputPeerEmpty", "inputPeerSelf", "inputPeerUser", "inputPeerUserFromMessage"], chat)) {
|
|
276
268
|
throw new InputError("Cannot add members to private chats");
|
|
277
269
|
}
|
|
278
|
-
const user = await
|
|
270
|
+
const user = await this.#c.getInputUser(userId);
|
|
279
271
|
if (Api.is("inputPeerChat", chat)) {
|
|
280
|
-
const result = await
|
|
272
|
+
const result = await this.#c.invoke({ _: "messages.addChatUser", chat_id: chat.chat_id, user_id: user, fwd_limit: params?.historyLimit ?? 0 });
|
|
281
273
|
return result.missing_invitees.map(constructFailedInvitation);
|
|
282
274
|
}
|
|
283
275
|
else if (Api.is("inputPeerChannel", chat)) {
|
|
284
|
-
const result = await
|
|
276
|
+
const result = await this.#c.invoke({ _: "channels.inviteToChannel", channel: { ...chat, _: "inputChannel" }, users: [user] });
|
|
285
277
|
return result.missing_invitees.map(constructFailedInvitation);
|
|
286
278
|
}
|
|
287
279
|
unreachable();
|
|
288
280
|
}
|
|
289
281
|
async addChatMembers(chatId, userIds) {
|
|
290
|
-
|
|
291
|
-
const chat = await
|
|
282
|
+
this.#c.storage.assertUser("addChatMembers");
|
|
283
|
+
const chat = await this.#c.getInputPeer(chatId);
|
|
292
284
|
if (Api.isOneOf(["inputPeerEmpty", "inputPeerSelf", "inputPeerUser", "inputPeerUserFromMessage"], chat)) {
|
|
293
285
|
throw new InputError("Cannot add members to private chats");
|
|
294
286
|
}
|
|
295
287
|
const users = new Array();
|
|
296
288
|
for (const userId of userIds) {
|
|
297
|
-
users.push(await
|
|
289
|
+
users.push(await this.#c.getInputUser(userId));
|
|
298
290
|
}
|
|
299
291
|
if (Api.is("inputPeerChat", chat)) {
|
|
300
292
|
throw new InputError("addChatMembers cannot be used with basic groups");
|
|
301
293
|
}
|
|
302
294
|
else if (canBeInputChannel(chat)) {
|
|
303
|
-
const result = await
|
|
295
|
+
const result = await this.#c.invoke({ _: "channels.inviteToChannel", channel: toInputChannel(chat), users });
|
|
304
296
|
return result.missing_invitees.map(constructFailedInvitation);
|
|
305
297
|
}
|
|
306
298
|
unreachable();
|
|
307
299
|
}
|
|
300
|
+
async #toggleSlowMode(chatId, seconds) {
|
|
301
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
302
|
+
await this.#c.invoke({ _: "channels.toggleSlowMode", channel, seconds });
|
|
303
|
+
}
|
|
308
304
|
async disableSlowMode(chatId) {
|
|
309
|
-
|
|
310
|
-
await
|
|
305
|
+
this.#c.storage.assertUser("disableSlowMode");
|
|
306
|
+
await this.#toggleSlowMode(chatId, 0);
|
|
311
307
|
}
|
|
312
308
|
async setSlowMode(chatId, duration) {
|
|
313
|
-
|
|
309
|
+
this.#c.storage.assertUser("setSlowMode");
|
|
314
310
|
const seconds = slowModeDurationToSeconds(duration);
|
|
315
311
|
if (seconds > 1) {
|
|
316
312
|
throw new InputError("Invalid slow mode duration.");
|
|
317
313
|
}
|
|
318
|
-
await
|
|
314
|
+
await this.#toggleSlowMode(chatId, seconds);
|
|
319
315
|
}
|
|
320
316
|
async setChatTitle(chatId, title) {
|
|
321
|
-
const peer = await
|
|
317
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
322
318
|
if (Api.is("inputPeerChat", peer)) {
|
|
323
|
-
await
|
|
319
|
+
await this.#c.invoke({ _: "messages.editChatTitle", chat_id: peer.chat_id, title });
|
|
324
320
|
}
|
|
325
321
|
else if (canBeInputChannel(peer)) {
|
|
326
322
|
const channel = toInputChannel(peer);
|
|
327
|
-
await
|
|
323
|
+
await this.#c.invoke({ _: "channels.editTitle", channel, title });
|
|
328
324
|
}
|
|
329
325
|
else {
|
|
330
326
|
throw new InputError("A chat or channel identifier was expected.");
|
|
331
327
|
}
|
|
332
328
|
}
|
|
333
329
|
async setChatDescription(chatId, description) {
|
|
334
|
-
const peer = await
|
|
330
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
335
331
|
if (canBeInputUser(peer)) {
|
|
336
332
|
throw new InputError("A chat or channel identifier was expected.");
|
|
337
333
|
}
|
|
338
|
-
await
|
|
334
|
+
await this.#c.invoke({ _: "messages.editChatAbout", peer, about: description });
|
|
339
335
|
}
|
|
340
336
|
async setMemberListVisibility(chatId, visible) {
|
|
341
|
-
|
|
342
|
-
const channel = await
|
|
337
|
+
this.#c.storage.assertUser("setMemberListVisible");
|
|
338
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
343
339
|
const enabled = !visible;
|
|
344
|
-
await
|
|
340
|
+
await this.#c.invoke({ _: "channels.toggleParticipantsHidden", channel, enabled });
|
|
345
341
|
}
|
|
346
342
|
async setTopicsEnabled(chatId, enabled) {
|
|
347
|
-
|
|
348
|
-
const channel = await
|
|
349
|
-
await
|
|
343
|
+
this.#c.storage.assertUser("setTopicsEnabled");
|
|
344
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
345
|
+
await this.#c.invoke({ _: "channels.toggleForum", channel, enabled });
|
|
350
346
|
}
|
|
351
347
|
async setAntispamEnabled(chatId, enabled) {
|
|
352
|
-
|
|
353
|
-
const channel = await
|
|
354
|
-
await
|
|
348
|
+
this.#c.storage.assertUser("setTopicsEnabled");
|
|
349
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
350
|
+
await this.#c.invoke({ _: "channels.toggleAntiSpam", channel, enabled });
|
|
355
351
|
}
|
|
356
352
|
async setSignaturesEnabled(chatId, enabled, params) {
|
|
357
|
-
|
|
358
|
-
const channel = await
|
|
359
|
-
await
|
|
353
|
+
this.#c.storage.assertUser("setSignaturesEnabled");
|
|
354
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
355
|
+
await this.#c.invoke({ _: "channels.toggleSignatures", channel, signatures_enabled: enabled ? true : undefined, profiles_enabled: params?.showAuthorProfile ? true : undefined });
|
|
360
356
|
}
|
|
361
357
|
async deleteChat(chatId) {
|
|
362
|
-
|
|
363
|
-
const peer = await
|
|
358
|
+
this.#c.storage.assertUser("deleteChat");
|
|
359
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
364
360
|
if (Api.is("inputPeerChat", peer)) {
|
|
365
|
-
await
|
|
361
|
+
await this.#c.invoke({ _: "messages.deleteChat", chat_id: peer.chat_id });
|
|
366
362
|
}
|
|
367
363
|
else if (canBeInputChannel(peer)) {
|
|
368
364
|
const channel = toInputChannel(peer);
|
|
369
|
-
await
|
|
365
|
+
await this.#c.invoke({ _: "channels.deleteChannel", channel });
|
|
370
366
|
}
|
|
371
367
|
else {
|
|
372
368
|
throw new InputError("A chat or channel identifier was expected.");
|
|
373
369
|
}
|
|
374
370
|
}
|
|
375
371
|
async getDiscussionChatSuggestions() {
|
|
376
|
-
|
|
377
|
-
const { chats } = await
|
|
372
|
+
this.#c.storage.assertUser("getDiscussionChatSuggestions");
|
|
373
|
+
const { chats } = await this.#c.invoke({ _: "channels.getGroupsForDiscussion" });
|
|
378
374
|
return chats
|
|
379
375
|
.map((v) => {
|
|
380
376
|
if (!Api.isOneOf(["chat", "channel"], v)) {
|
|
@@ -387,29 +383,20 @@ export class ChatManager {
|
|
|
387
383
|
.filter((v) => v != null);
|
|
388
384
|
}
|
|
389
385
|
async setDiscussionChat(chatId, discussionChatId) {
|
|
390
|
-
|
|
391
|
-
const [broadcast, group] = await Promise.all([
|
|
392
|
-
await
|
|
386
|
+
this.#c.storage.assertUser("setDiscussionChat");
|
|
387
|
+
const [broadcast, group] = await Promise.all([this.#c.getInputChannel(chatId), this.#c.getInputChannel(discussionChatId)]);
|
|
388
|
+
await this.#c.invoke({ _: "channels.setDiscussionGroup", broadcast, group });
|
|
393
389
|
}
|
|
394
390
|
async transferChatOwnership(chatId, userId, password) {
|
|
395
|
-
|
|
396
|
-
const user_id = await
|
|
391
|
+
this.#c.storage.assertUser("transferChat");
|
|
392
|
+
const user_id = await this.#c.getInputUser(userId);
|
|
397
393
|
const isSelf = Api.is("inputUserSelf", user_id);
|
|
398
|
-
if (isSelf || Api.peerToChatId(user_id) == await
|
|
394
|
+
if (isSelf || Api.peerToChatId(user_id) == await this.#c.getSelfId()) {
|
|
399
395
|
throw new InputError("A user ID except that of the current one was expected.");
|
|
400
396
|
}
|
|
401
|
-
const channel = await
|
|
402
|
-
const ap = await
|
|
397
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
398
|
+
const ap = await this.#c.invoke({ _: "account.getPassword" });
|
|
403
399
|
const password_ = await checkPassword(password, ap);
|
|
404
|
-
await
|
|
400
|
+
await this.#c.invoke({ _: "channels.editCreator", channel, user_id, password: password_ });
|
|
405
401
|
}
|
|
406
402
|
}
|
|
407
|
-
_ChatManager_c = new WeakMap(), _ChatManager_instances = new WeakSet(), _ChatManager_toggleJoinRequests =
|
|
408
|
-
// JOIN REQUESTS //
|
|
409
|
-
async function _ChatManager_toggleJoinRequests(chatId, enabled) {
|
|
410
|
-
const channel = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputChannel(chatId);
|
|
411
|
-
await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.toggleJoinRequest", channel, enabled });
|
|
412
|
-
}, _ChatManager_toggleSlowMode = async function _ChatManager_toggleSlowMode(chatId, seconds) {
|
|
413
|
-
const channel = await __classPrivateFieldGet(this, _ChatManager_c, "f").getInputChannel(chatId);
|
|
414
|
-
await __classPrivateFieldGet(this, _ChatManager_c, "f").invoke({ _: "channels.toggleSlowMode", channel, seconds });
|
|
415
|
-
};
|