@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,36 +17,31 @@
|
|
|
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
|
|
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 _ForumManager_instances, _a, _ForumManager_c, _ForumManager_validateTopicTitle, _ForumManager_assertNongenralTopicIdValid, _ForumManager_assertAnyTopicIdValid, _ForumManager_toggleGeneralTopicHidden, _ForumManager_toggleNongeneralTopicClosed, _ForumManager_setTopicPinned;
|
|
20
|
+
var _a;
|
|
32
21
|
import { InputError } from "../0_errors.js";
|
|
33
22
|
import { getRandomId } from "../1_utilities.js";
|
|
34
23
|
import { assertMessageType, constructTopic } from "../3_types.js";
|
|
35
24
|
export class ForumManager {
|
|
25
|
+
#c;
|
|
36
26
|
constructor(c) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
this.#c = c;
|
|
28
|
+
}
|
|
29
|
+
static #validateTopicTitle(title) {
|
|
30
|
+
title = title.trim();
|
|
31
|
+
if (!title) {
|
|
32
|
+
throw new InputEvent("Invalid topic title.");
|
|
33
|
+
}
|
|
34
|
+
return title;
|
|
40
35
|
}
|
|
41
36
|
async createTopic(chatId, title, params) {
|
|
42
|
-
title =
|
|
37
|
+
title = _a.#validateTopicTitle(title);
|
|
43
38
|
let send_as;
|
|
44
39
|
if (params?.sendAs) {
|
|
45
|
-
|
|
46
|
-
send_as = await
|
|
40
|
+
this.#c.storage.assertUser("sendAs");
|
|
41
|
+
send_as = await this.#c.getInputPeer(params.sendAs);
|
|
47
42
|
}
|
|
48
|
-
const channel = await
|
|
49
|
-
const updates = await
|
|
43
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
44
|
+
const updates = await this.#c.invoke({
|
|
50
45
|
_: "channels.createForumTopic",
|
|
51
46
|
channel,
|
|
52
47
|
title,
|
|
@@ -55,80 +50,79 @@ export class ForumManager {
|
|
|
55
50
|
send_as,
|
|
56
51
|
random_id: getRandomId(),
|
|
57
52
|
});
|
|
58
|
-
const message = (await
|
|
53
|
+
const message = (await this.#c.messageManager.updatesToMessages(chatId, updates))[0];
|
|
59
54
|
return constructTopic(assertMessageType(message, "forumTopicCreated"));
|
|
60
55
|
}
|
|
56
|
+
static #assertNongenralTopicIdValid(topicId) {
|
|
57
|
+
if (!topicId || topicId < 2) {
|
|
58
|
+
throw new InputError("Invalid topic ID.");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
static #assertAnyTopicIdValid(topicId) {
|
|
62
|
+
if (!topicId || topicId < 1) {
|
|
63
|
+
throw new InputError("Invalid topic ID.");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
61
66
|
async editTopic(chatId, topicId, title, params) {
|
|
62
|
-
|
|
63
|
-
title =
|
|
64
|
-
const channel = await
|
|
65
|
-
const updates = await
|
|
67
|
+
_a.#assertNongenralTopicIdValid(topicId);
|
|
68
|
+
title = _a.#validateTopicTitle(title);
|
|
69
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
70
|
+
const updates = await this.#c.invoke({
|
|
66
71
|
_: "channels.editForumTopic",
|
|
67
72
|
channel,
|
|
68
73
|
topic_id: topicId,
|
|
69
74
|
title,
|
|
70
75
|
icon_emoji_id: params?.customEmojiId ? BigInt(params.customEmojiId) : undefined,
|
|
71
76
|
});
|
|
72
|
-
const message = (await
|
|
77
|
+
const message = (await this.#c.messageManager.updatesToMessages(chatId, updates))[0];
|
|
73
78
|
return constructTopic(assertMessageType(message, "forumTopicEdited"));
|
|
74
79
|
}
|
|
80
|
+
async #toggleGeneralTopicHidden(chatId, hidden) {
|
|
81
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
82
|
+
await this.#c.invoke({
|
|
83
|
+
_: "channels.editForumTopic",
|
|
84
|
+
channel,
|
|
85
|
+
topic_id: 1,
|
|
86
|
+
hidden,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
75
89
|
async hideGeneralTopic(chatId) {
|
|
76
|
-
await
|
|
90
|
+
await this.#toggleGeneralTopicHidden(chatId, true);
|
|
77
91
|
}
|
|
78
92
|
async showGeneralTopic(chatId) {
|
|
79
|
-
await
|
|
93
|
+
await this.#toggleGeneralTopicHidden(chatId, false);
|
|
94
|
+
}
|
|
95
|
+
async #toggleNongeneralTopicClosed(chatId, topicId, closed) {
|
|
96
|
+
_a.#assertNongenralTopicIdValid(topicId);
|
|
97
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
98
|
+
await this.#c.invoke({
|
|
99
|
+
_: "channels.editForumTopic",
|
|
100
|
+
channel,
|
|
101
|
+
topic_id: 1,
|
|
102
|
+
closed,
|
|
103
|
+
});
|
|
80
104
|
}
|
|
81
105
|
async closeTopic(chatId, topicId) {
|
|
82
|
-
await
|
|
106
|
+
await this.#toggleNongeneralTopicClosed(chatId, topicId, true);
|
|
83
107
|
}
|
|
84
108
|
async reopenTopic(chatId, topicId) {
|
|
85
|
-
await
|
|
109
|
+
await this.#toggleNongeneralTopicClosed(chatId, topicId, false);
|
|
110
|
+
}
|
|
111
|
+
async #setTopicPinned(chatId, topicId, pinned) {
|
|
112
|
+
_a.#assertAnyTopicIdValid(topicId);
|
|
113
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
114
|
+
await this.#c.invoke({
|
|
115
|
+
_: "channels.updatePinnedForumTopic",
|
|
116
|
+
channel,
|
|
117
|
+
topic_id: 1,
|
|
118
|
+
pinned,
|
|
119
|
+
});
|
|
86
120
|
}
|
|
87
121
|
async pinTopic(chatId, topicId) {
|
|
88
|
-
await
|
|
122
|
+
await this.#setTopicPinned(chatId, topicId, true);
|
|
89
123
|
}
|
|
90
124
|
async unpinTopic(chatId, topicId) {
|
|
91
|
-
await
|
|
125
|
+
await this.#setTopicPinned(chatId, topicId, false);
|
|
92
126
|
}
|
|
93
127
|
}
|
|
94
|
-
_a = ForumManager
|
|
95
|
-
title = title.trim();
|
|
96
|
-
if (!title) {
|
|
97
|
-
throw new InputEvent("Invalid topic title.");
|
|
98
|
-
}
|
|
99
|
-
return title;
|
|
100
|
-
}, _ForumManager_assertNongenralTopicIdValid = function _ForumManager_assertNongenralTopicIdValid(topicId) {
|
|
101
|
-
if (!topicId || topicId < 2) {
|
|
102
|
-
throw new InputError("Invalid topic ID.");
|
|
103
|
-
}
|
|
104
|
-
}, _ForumManager_assertAnyTopicIdValid = function _ForumManager_assertAnyTopicIdValid(topicId) {
|
|
105
|
-
if (!topicId || topicId < 1) {
|
|
106
|
-
throw new InputError("Invalid topic ID.");
|
|
107
|
-
}
|
|
108
|
-
}, _ForumManager_toggleGeneralTopicHidden = async function _ForumManager_toggleGeneralTopicHidden(chatId, hidden) {
|
|
109
|
-
const channel = await __classPrivateFieldGet(this, _ForumManager_c, "f").getInputChannel(chatId);
|
|
110
|
-
await __classPrivateFieldGet(this, _ForumManager_c, "f").invoke({
|
|
111
|
-
_: "channels.editForumTopic",
|
|
112
|
-
channel,
|
|
113
|
-
topic_id: 1,
|
|
114
|
-
hidden,
|
|
115
|
-
});
|
|
116
|
-
}, _ForumManager_toggleNongeneralTopicClosed = async function _ForumManager_toggleNongeneralTopicClosed(chatId, topicId, closed) {
|
|
117
|
-
__classPrivateFieldGet(_a, _a, "m", _ForumManager_assertNongenralTopicIdValid).call(_a, topicId);
|
|
118
|
-
const channel = await __classPrivateFieldGet(this, _ForumManager_c, "f").getInputChannel(chatId);
|
|
119
|
-
await __classPrivateFieldGet(this, _ForumManager_c, "f").invoke({
|
|
120
|
-
_: "channels.editForumTopic",
|
|
121
|
-
channel,
|
|
122
|
-
topic_id: 1,
|
|
123
|
-
closed,
|
|
124
|
-
});
|
|
125
|
-
}, _ForumManager_setTopicPinned = async function _ForumManager_setTopicPinned(chatId, topicId, pinned) {
|
|
126
|
-
__classPrivateFieldGet(_a, _a, "m", _ForumManager_assertAnyTopicIdValid).call(_a, topicId);
|
|
127
|
-
const channel = await __classPrivateFieldGet(this, _ForumManager_c, "f").getInputChannel(chatId);
|
|
128
|
-
await __classPrivateFieldGet(this, _ForumManager_c, "f").invoke({
|
|
129
|
-
_: "channels.updatePinnedForumTopic",
|
|
130
|
-
channel,
|
|
131
|
-
topic_id: 1,
|
|
132
|
-
pinned,
|
|
133
|
-
});
|
|
134
|
-
};
|
|
128
|
+
_a = ForumManager;
|
|
@@ -17,63 +17,51 @@
|
|
|
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 _GiftManager_c;
|
|
32
20
|
import { unreachable } from "../0_deps.js";
|
|
33
21
|
import { InputError } from "../0_errors.js";
|
|
34
22
|
import { Api } from "../2_tl.js";
|
|
35
23
|
import { constructClaimedGifts, constructGift } from "../3_types.js";
|
|
36
24
|
import { getLimit } from "./0_utilities.js";
|
|
37
25
|
export class GiftManager {
|
|
26
|
+
#c;
|
|
38
27
|
constructor(c) {
|
|
39
|
-
|
|
40
|
-
__classPrivateFieldSet(this, _GiftManager_c, c, "f");
|
|
28
|
+
this.#c = c;
|
|
41
29
|
}
|
|
42
30
|
async getGifts() {
|
|
43
|
-
const gifts = await
|
|
31
|
+
const gifts = await this.#c.invoke({ _: "payments.getStarGifts", hash: 0 });
|
|
44
32
|
if (!(Api.is("payments.starGifts", gifts))) {
|
|
45
33
|
unreachable();
|
|
46
34
|
}
|
|
47
|
-
return await Promise.all(gifts.gifts.map((v) => constructGift(v,
|
|
35
|
+
return await Promise.all(gifts.gifts.map((v) => constructGift(v, this.#c.getEntity)));
|
|
48
36
|
}
|
|
49
37
|
async getClaimedGifts(chatId, params) {
|
|
50
|
-
|
|
38
|
+
this.#c.storage.assertUser("getClaimedGifts");
|
|
51
39
|
const offset = params?.offset ?? "";
|
|
52
40
|
const limit = getLimit(params?.limit);
|
|
53
|
-
const peer = await
|
|
54
|
-
const result = await
|
|
55
|
-
return await constructClaimedGifts(result,
|
|
41
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
42
|
+
const result = await this.#c.invoke({ _: "payments.getSavedStarGifts", peer, offset, limit });
|
|
43
|
+
return await constructClaimedGifts(result, this.#c.getEntity);
|
|
56
44
|
}
|
|
57
45
|
async sendGift(chatId, giftId, params) {
|
|
58
46
|
const hide_name = params?.private ? true : undefined;
|
|
59
47
|
const include_upgrade = params?.upgrade ? true : undefined;
|
|
60
|
-
const peer = await
|
|
48
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
61
49
|
const gift_id = BigInt(giftId);
|
|
62
50
|
let message;
|
|
63
51
|
if (params?.message) {
|
|
64
|
-
const parsedText = await
|
|
52
|
+
const parsedText = await this.#c.messageManager.parseText(params.message, params);
|
|
65
53
|
message = { _: "textWithEntities", text: parsedText[0], entities: parsedText[1] ?? [] };
|
|
66
54
|
}
|
|
67
55
|
const invoice = { _: "inputInvoiceStarGift", hide_name, include_upgrade, peer, gift_id, message };
|
|
68
|
-
const paymentForm = await
|
|
69
|
-
await
|
|
56
|
+
const paymentForm = await this.#c.invoke({ _: "payments.getPaymentForm", invoice });
|
|
57
|
+
await this.#c.invoke({ _: "payments.sendStarsForm", form_id: paymentForm.form_id, invoice });
|
|
70
58
|
}
|
|
71
59
|
async sellGift(userId, messageId) {
|
|
72
|
-
const message = await
|
|
60
|
+
const message = await this.#c.messageManager.getMessage(userId, messageId);
|
|
73
61
|
if (message == null) {
|
|
74
62
|
throw new InputError("Message not found.");
|
|
75
63
|
}
|
|
76
|
-
await
|
|
64
|
+
await this.#c.invoke({ _: "payments.convertStarGift", stargift: { _: "inputSavedStarGiftUser", msg_id: message.id } });
|
|
77
65
|
}
|
|
78
66
|
async getGift(slug) {
|
|
79
67
|
if (slug.length > 100) {
|
|
@@ -83,8 +71,7 @@ export class GiftManager {
|
|
|
83
71
|
if (!/^[a-z]+-[1-9][0-9]*$/.test(slug)) {
|
|
84
72
|
throw new InputError("Invalid slug.");
|
|
85
73
|
}
|
|
86
|
-
const result = await
|
|
87
|
-
return await constructGift(result.gift,
|
|
74
|
+
const result = await this.#c.invoke({ _: "payments.getUniqueStarGift", slug });
|
|
75
|
+
return await constructGift(result.gift, this.#c.getEntity.bind(this));
|
|
88
76
|
}
|
|
89
77
|
}
|
|
90
|
-
_GiftManager_c = new WeakMap();
|
|
@@ -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 _a, _InlineQueryManager_c, _InlineQueryManager_isExpired;
|
|
32
20
|
import { unreachable } from "../0_deps.js";
|
|
33
21
|
import { Api } from "../2_tl.js";
|
|
34
22
|
import { constructChosenInlineResult, constructInlineQuery, constructInlineQueryAnswer, inlineQueryResultToTlObject } from "../3_types.js";
|
|
@@ -38,45 +26,45 @@ const inlineQueryManagerUpdates = [
|
|
|
38
26
|
"updateBotInlineSend",
|
|
39
27
|
];
|
|
40
28
|
export class InlineQueryManager {
|
|
29
|
+
#c;
|
|
41
30
|
constructor(c) {
|
|
42
|
-
|
|
43
|
-
__classPrivateFieldSet(this, _InlineQueryManager_c, c, "f");
|
|
31
|
+
this.#c = c;
|
|
44
32
|
}
|
|
45
33
|
async answerInlineQuery(id, results, params) {
|
|
46
|
-
|
|
34
|
+
this.#c.storage.assertBot("answerInlineQuery");
|
|
47
35
|
checkInlineQueryId(id);
|
|
48
|
-
await
|
|
36
|
+
await this.#c.invoke({ _: "messages.setInlineBotResults", query_id: BigInt(id), results: await Promise.all(results.map((v) => inlineQueryResultToTlObject(v, this.#c.messageManager.parseText.bind(this.#c.messageManager), this.#c.messageManager.usernameResolver.bind(this.#c.messageManager)))), cache_time: params?.cacheTime ?? 300, private: params?.isPersonal ? true : undefined, switch_webview: params?.button && params.button.miniApp ? ({ _: "inlineBotWebView", text: params.button.text, url: params.button.miniApp.url }) : undefined, switch_pm: params?.button && params.button.startParameter ? ({ _: "inlineBotSwitchPM", text: params.button.text, start_param: params.button.startParameter }) : undefined, gallery: params?.isGallery ? true : undefined, next_offset: params?.nextOffset });
|
|
49
37
|
}
|
|
50
38
|
canHandleUpdate(update) {
|
|
51
39
|
return Api.isOneOf(inlineQueryManagerUpdates, update);
|
|
52
40
|
}
|
|
53
41
|
async handleUpdate(update) {
|
|
54
42
|
if (Api.is("updateBotInlineQuery", update)) {
|
|
55
|
-
return { inlineQuery: await constructInlineQuery(update,
|
|
43
|
+
return { inlineQuery: await constructInlineQuery(update, this.#c.getEntity) };
|
|
56
44
|
}
|
|
57
45
|
else if (Api.is("updateBotInlineSend", update)) {
|
|
58
|
-
return { chosenInlineResult: await constructChosenInlineResult(update,
|
|
46
|
+
return { chosenInlineResult: await constructChosenInlineResult(update, this.#c.getEntity) };
|
|
59
47
|
}
|
|
60
48
|
else {
|
|
61
49
|
unreachable();
|
|
62
50
|
}
|
|
63
51
|
}
|
|
64
52
|
async sendInlineQuery(botId_, chatId, params) {
|
|
65
|
-
|
|
66
|
-
const bot = await
|
|
67
|
-
const botId = await
|
|
68
|
-
const maybeResults = await
|
|
69
|
-
if (maybeResults != null && !
|
|
53
|
+
this.#c.storage.assertUser("sendInlineQuery");
|
|
54
|
+
const bot = await this.#c.getInputUser(botId_), peer = await this.#c.getInputPeer(chatId), query = params?.query ?? "", offset = params?.offset ?? "";
|
|
55
|
+
const botId = await this.#c.getInputPeerChatId(bot), peerId = await this.#c.getInputPeerChatId(peer);
|
|
56
|
+
const maybeResults = await this.#c.messageStorage.getInlineQueryAnswer(botId, peerId, query, offset);
|
|
57
|
+
if (maybeResults != null && !InlineQueryManager.#isExpired(maybeResults[1], maybeResults[0].cache_time)) {
|
|
70
58
|
return constructInlineQueryAnswer(maybeResults[0]);
|
|
71
59
|
}
|
|
72
60
|
const then = new Date();
|
|
73
|
-
const results = await
|
|
61
|
+
const results = await this.#c.invoke({ _: "messages.getInlineBotResults", bot, peer, query, offset });
|
|
74
62
|
if (results.cache_time > 0) {
|
|
75
|
-
await
|
|
63
|
+
await this.#c.messageStorage.setInlineQueryAnswer(botId, peerId, query, offset, results, then);
|
|
76
64
|
}
|
|
77
65
|
return constructInlineQueryAnswer(results);
|
|
78
66
|
}
|
|
67
|
+
static #isExpired(date, cacheTime) {
|
|
68
|
+
return (Date.now() - date.getTime()) / 1000 > cacheTime;
|
|
69
|
+
}
|
|
79
70
|
}
|
|
80
|
-
_a = InlineQueryManager, _InlineQueryManager_c = new WeakMap(), _InlineQueryManager_isExpired = function _InlineQueryManager_isExpired(date, cacheTime) {
|
|
81
|
-
return (Date.now() - date.getTime()) / 1000 > cacheTime;
|
|
82
|
-
};
|
|
@@ -17,37 +17,25 @@
|
|
|
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 _LinkPreviewManager_c;
|
|
32
20
|
import { Api } from "../2_tl.js";
|
|
33
21
|
import { constructLinkPreview } from "../3_types.js";
|
|
34
22
|
const linkPreviewManagerUpdates = [
|
|
35
23
|
"updateWebPage",
|
|
36
24
|
];
|
|
37
25
|
export class LinkPreviewManager {
|
|
26
|
+
#c;
|
|
38
27
|
constructor(c) {
|
|
39
|
-
|
|
40
|
-
__classPrivateFieldSet(this, _LinkPreviewManager_c, c, "f");
|
|
28
|
+
this.#c = c;
|
|
41
29
|
}
|
|
42
30
|
async getLinkPreview(text, params) {
|
|
43
|
-
const [text_, entities_] = await
|
|
44
|
-
const result = await
|
|
31
|
+
const [text_, entities_] = await this.#c.messageManager.parseText(text, params);
|
|
32
|
+
const result = await this.#c.invoke({
|
|
45
33
|
_: "messages.getWebPagePreview",
|
|
46
34
|
message: text_,
|
|
47
35
|
entities: entities_,
|
|
48
36
|
});
|
|
49
37
|
if (Api.is("messageMediaWebPage", result.media)) {
|
|
50
|
-
return await constructLinkPreview(result.media, undefined,
|
|
38
|
+
return await constructLinkPreview(result.media, undefined, this.#c.getEntity);
|
|
51
39
|
}
|
|
52
40
|
else {
|
|
53
41
|
return null;
|
|
@@ -57,8 +45,7 @@ export class LinkPreviewManager {
|
|
|
57
45
|
return Api.isOneOf(linkPreviewManagerUpdates, update);
|
|
58
46
|
}
|
|
59
47
|
async handleUpdate(update) {
|
|
60
|
-
const linkPreview = await constructLinkPreview({ _: "messageMediaWebPage", webpage: update.webpage }, undefined,
|
|
48
|
+
const linkPreview = await constructLinkPreview({ _: "messageMediaWebPage", webpage: update.webpage }, undefined, this.#c.getEntity);
|
|
61
49
|
return { linkPreview };
|
|
62
50
|
}
|
|
63
51
|
}
|
|
64
|
-
_LinkPreviewManager_c = new WeakMap();
|
|
@@ -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 _PollManager_instances, _PollManager_c, _PollManager_voteInner;
|
|
32
20
|
import { unreachable } from "../0_deps.js";
|
|
33
21
|
import { InputError } from "../0_errors.js";
|
|
34
22
|
import { Api } from "../2_tl.js";
|
|
@@ -38,35 +26,68 @@ const pollManagerUpdates = [
|
|
|
38
26
|
"updateMessagePollVote",
|
|
39
27
|
];
|
|
40
28
|
export class PollManager {
|
|
29
|
+
#c;
|
|
41
30
|
constructor(c) {
|
|
42
|
-
|
|
43
|
-
_PollManager_c.set(this, void 0);
|
|
44
|
-
__classPrivateFieldSet(this, _PollManager_c, c, "f");
|
|
31
|
+
this.#c = c;
|
|
45
32
|
}
|
|
46
33
|
async vote(chatId, messageId, optionIndexes) {
|
|
47
|
-
|
|
34
|
+
this.#c.storage.assertUser("vote");
|
|
48
35
|
if (!optionIndexes.length) {
|
|
49
36
|
throw new InputError("No options provided.");
|
|
50
37
|
}
|
|
51
|
-
await
|
|
38
|
+
await this.#voteInner(chatId, messageId, optionIndexes);
|
|
52
39
|
}
|
|
53
40
|
async retractVote(chatId, messageId) {
|
|
54
|
-
|
|
55
|
-
await
|
|
41
|
+
this.#c.storage.assertUser("retractVote");
|
|
42
|
+
await this.#voteInner(chatId, messageId, []);
|
|
43
|
+
}
|
|
44
|
+
async #voteInner(chatId, messageId, optionIndexes) {
|
|
45
|
+
const message = await this.#c.messageManager.getMessage(chatId, messageId);
|
|
46
|
+
if (!("poll" in message)) {
|
|
47
|
+
throw new InputError("Message not a poll.");
|
|
48
|
+
}
|
|
49
|
+
if (message.poll.options.filter((v) => v.chosen).length == 0 && optionIndexes.length == 0) {
|
|
50
|
+
throw new InputError("No vote has been casted.");
|
|
51
|
+
}
|
|
52
|
+
if (!message.poll.allowMultipleAnswers && optionIndexes.length > 1) {
|
|
53
|
+
throw new InputError("Cannot cast multiple options for this vote.");
|
|
54
|
+
}
|
|
55
|
+
for (const optionIndex of optionIndexes) {
|
|
56
|
+
if (optionIndex + 1 > message.poll.options.length) {
|
|
57
|
+
throw new InputError("Got invalid option index.");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (optionIndexes.length > 0 && message.poll.options.map((v, i) => [i, v.chosen]).filter((v) => v[1]).every(([v]) => optionIndexes.includes(v))) {
|
|
61
|
+
throw new InputError("The same options are already casted.");
|
|
62
|
+
}
|
|
63
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
64
|
+
const chatId_ = Api.peerToChatId(peer);
|
|
65
|
+
const message_ = await this.#c.messageStorage.getMessage(chatId_, messageId);
|
|
66
|
+
if (!Api.is("message", message_)) {
|
|
67
|
+
unreachable();
|
|
68
|
+
}
|
|
69
|
+
const media = message_.media;
|
|
70
|
+
if (!Api.is("messageMediaPoll", media)) {
|
|
71
|
+
unreachable();
|
|
72
|
+
}
|
|
73
|
+
const poll = media.poll;
|
|
74
|
+
optionIndexes = Array.from(new Set(optionIndexes));
|
|
75
|
+
const options = optionIndexes.map((i) => poll.answers[i].option);
|
|
76
|
+
await this.#c.invoke({ _: "messages.sendVote", peer, msg_id: messageId, options });
|
|
56
77
|
}
|
|
57
78
|
canHandleUpdate(update) {
|
|
58
79
|
return Api.isOneOf(pollManagerUpdates, update);
|
|
59
80
|
}
|
|
60
81
|
async handleUpdate(update) {
|
|
61
82
|
if (Api.is("updateMessagePoll", update)) {
|
|
62
|
-
await
|
|
83
|
+
await this.#c.storage.setPollResults(update.poll_id, update.results);
|
|
63
84
|
let poll = null;
|
|
64
85
|
if (update.poll) {
|
|
65
86
|
poll = update.poll;
|
|
66
|
-
await
|
|
87
|
+
await this.#c.storage.setPoll(poll.id, poll);
|
|
67
88
|
}
|
|
68
89
|
else {
|
|
69
|
-
poll = await
|
|
90
|
+
poll = await this.#c.storage.getPoll(update.poll_id);
|
|
70
91
|
}
|
|
71
92
|
if (poll) {
|
|
72
93
|
const messageMediaPoll = { _: "messageMediaPoll", poll, results: update.results };
|
|
@@ -77,42 +98,8 @@ export class PollManager {
|
|
|
77
98
|
}
|
|
78
99
|
}
|
|
79
100
|
else {
|
|
80
|
-
const pollAnswer = await constructPollAnswer(update,
|
|
101
|
+
const pollAnswer = await constructPollAnswer(update, this.#c.getEntity);
|
|
81
102
|
return { pollAnswer };
|
|
82
103
|
}
|
|
83
104
|
}
|
|
84
105
|
}
|
|
85
|
-
_PollManager_c = new WeakMap(), _PollManager_instances = new WeakSet(), _PollManager_voteInner = async function _PollManager_voteInner(chatId, messageId, optionIndexes) {
|
|
86
|
-
const message = await __classPrivateFieldGet(this, _PollManager_c, "f").messageManager.getMessage(chatId, messageId);
|
|
87
|
-
if (!("poll" in message)) {
|
|
88
|
-
throw new InputError("Message not a poll.");
|
|
89
|
-
}
|
|
90
|
-
if (message.poll.options.filter((v) => v.chosen).length == 0 && optionIndexes.length == 0) {
|
|
91
|
-
throw new InputError("No vote has been casted.");
|
|
92
|
-
}
|
|
93
|
-
if (!message.poll.allowMultipleAnswers && optionIndexes.length > 1) {
|
|
94
|
-
throw new InputError("Cannot cast multiple options for this vote.");
|
|
95
|
-
}
|
|
96
|
-
for (const optionIndex of optionIndexes) {
|
|
97
|
-
if (optionIndex + 1 > message.poll.options.length) {
|
|
98
|
-
throw new InputError("Got invalid option index.");
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (optionIndexes.length > 0 && message.poll.options.map((v, i) => [i, v.chosen]).filter((v) => v[1]).every(([v]) => optionIndexes.includes(v))) {
|
|
102
|
-
throw new InputError("The same options are already casted.");
|
|
103
|
-
}
|
|
104
|
-
const peer = await __classPrivateFieldGet(this, _PollManager_c, "f").getInputPeer(chatId);
|
|
105
|
-
const chatId_ = Api.peerToChatId(peer);
|
|
106
|
-
const message_ = await __classPrivateFieldGet(this, _PollManager_c, "f").messageStorage.getMessage(chatId_, messageId);
|
|
107
|
-
if (!Api.is("message", message_)) {
|
|
108
|
-
unreachable();
|
|
109
|
-
}
|
|
110
|
-
const media = message_.media;
|
|
111
|
-
if (!Api.is("messageMediaPoll", media)) {
|
|
112
|
-
unreachable();
|
|
113
|
-
}
|
|
114
|
-
const poll = media.poll;
|
|
115
|
-
optionIndexes = Array.from(new Set(optionIndexes));
|
|
116
|
-
const options = optionIndexes.map((i) => poll.answers[i].option);
|
|
117
|
-
await __classPrivateFieldGet(this, _PollManager_c, "f").invoke({ _: "messages.sendVote", peer, msg_id: messageId, options });
|
|
118
|
-
};
|