@mtkruto/node 0.67.1 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/0_errors.js +2 -6
- package/esm/3_errors.js +2 -12
- package/esm/3_transport.d.ts +3 -3
- package/esm/3_transport.js +3 -3
- package/esm/3_types.d.ts +8 -7
- package/esm/3_types.d.ts.map +1 -1
- package/esm/3_types.js +8 -7
- package/esm/4_errors.js +2 -12
- package/esm/_dnt.polyfills.d.ts +99 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/_dnt.polyfills.js +127 -1
- package/esm/_dnt.test_polyfills.d.ts.map +1 -0
- package/esm/client/0_filters_test.d.ts.map +1 -1
- package/esm/client/0_markdown_test.d.ts.map +1 -1
- package/esm/client/0_params.d.ts +2 -0
- package/esm/client/0_params.d.ts.map +1 -1
- package/esm/client/0_password.d.ts +5 -5
- package/esm/client/0_password.d.ts.map +1 -1
- package/esm/client/0_password_test.d.ts.map +1 -1
- package/esm/client/0_storage_operations.js +143 -155
- package/esm/client/0_storage_operations_test.d.ts.map +1 -1
- package/esm/client/0_utilities.d.ts +1 -1
- package/esm/client/0_utilities_test.d.ts.map +1 -1
- package/esm/client/1_client_plain.js +4 -22
- package/esm/client/1_composer.js +8 -21
- package/esm/client/2_account_manager.js +85 -97
- package/esm/client/2_bot_info_manager.js +26 -38
- package/esm/client/2_business_connection_manager.js +10 -23
- package/esm/client/2_client_encrypted.js +194 -211
- package/esm/client/2_file_manager.d.ts +4 -3
- package/esm/client/2_file_manager.d.ts.map +1 -1
- package/esm/client/2_file_manager.js +268 -224
- package/esm/client/2_file_manager_test.d.ts.map +1 -1
- package/esm/client/2_network_statistics_manager.js +8 -21
- package/esm/client/2_payment_manager.js +7 -20
- package/esm/client/2_reaction_manager.js +7 -20
- package/esm/client/2_translations_manager.js +97 -107
- package/esm/client/2_update_manager.js +764 -759
- package/esm/client/3_client_encrypted_pool.js +10 -26
- package/esm/client/3_client_encrypted_pool_test.d.ts.map +1 -1
- package/esm/client/3_message_manager.d.ts +1 -1
- package/esm/client/3_message_manager.js +441 -448
- package/esm/client/3_message_manager_test.d.ts.map +1 -1
- package/esm/client/3_video_chat_manager.d.ts +1 -1
- package/esm/client/3_video_chat_manager.js +57 -68
- package/esm/client/4_callback_query_manager.js +18 -30
- package/esm/client/4_chat_list_manager.js +322 -318
- package/esm/client/4_chat_manager.js +118 -131
- package/esm/client/4_forum_manager.js +67 -73
- package/esm/client/4_gift_manager.js +16 -29
- package/esm/client/4_inline_query_manager.js +16 -28
- package/esm/client/4_link_preview_manager.js +6 -19
- package/esm/client/4_poll_manager.js +44 -57
- package/esm/client/4_story_manager.js +41 -53
- package/esm/client/5_client.d.ts +7 -0
- package/esm/client/5_client.d.ts.map +1 -1
- package/esm/client/5_client.js +1271 -1290
- package/esm/connection/1_connection_tcp.node.js +48 -65
- package/esm/connection/1_connection_web_socket.js +75 -91
- package/esm/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
- package/esm/deps/jsr.io/@std/assert/1.0.13/equals.js +4 -4
- package/esm/deps/jsr.io/@std/async/1.0.13/mux_async_iterator.js +31 -47
- package/esm/deps/jsr.io/@std/async/1.0.13/tee.js +11 -34
- package/esm/deps/jsr.io/@std/datetime/0.225.5/_date_time_formatter.js +4 -17
- package/esm/deps/jsr.io/@std/internal/1.0.10/build_message.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/diff.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/diff_str.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/format.d.ts +29 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/format.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/format.js +70 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/styles.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/types.d.ts.map +1 -0
- package/esm/mod.js +2 -12
- package/esm/session/0_session_state.js +12 -38
- package/esm/session/1_session.js +49 -72
- package/esm/session/2_session_encrypted.js +324 -320
- package/esm/storage/1_utilities_test.d.ts.map +1 -1
- package/esm/storage/2_storage_indexed_db.js +26 -44
- package/esm/storage/2_storage_local_storage.node.js +12 -25
- package/esm/storage/2_storage_memory.js +24 -41
- package/esm/storage/2_storage_session_storage.js +3 -16
- package/esm/tl/0_utilities_test.d.ts.map +1 -1
- package/esm/tl/1_tl_reader.js +80 -88
- package/esm/tl/1_tl_reader_test.d.ts.map +1 -1
- package/esm/tl/1_tl_writer.js +155 -164
- package/esm/tl/1_tl_writer_test.d.ts.map +1 -1
- package/esm/tl/2_telegram.d.ts +9 -10
- package/esm/tl/2_telegram.d.ts.map +1 -1
- package/esm/tl/2_telegram.js +10 -10
- package/esm/transport/0_transport.js +1 -8
- package/esm/transport/1_transport_abridged.js +11 -24
- package/esm/transport/1_transport_intermediate.js +10 -23
- package/{script/transport/2_transport_provider.d.ts → esm/transport/1_transport_provider.d.ts} +1 -1
- package/esm/transport/{2_transport_provider.d.ts.map → 1_transport_provider.d.ts.map} +1 -1
- package/{script/transport/3_transport_provider_tcp.d.ts → esm/transport/2_transport_provider_tcp.d.ts} +2 -2
- package/esm/transport/{3_transport_provider_tcp.d.ts.map → 2_transport_provider_tcp.d.ts.map} +1 -1
- package/esm/transport/{3_transport_provider_tcp.js → 2_transport_provider_tcp.js} +1 -1
- package/esm/transport/{3_transport_provider_web_socket.d.ts → 2_transport_provider_web_socket.d.ts} +2 -2
- package/esm/transport/2_transport_provider_web_socket.d.ts.map +1 -0
- package/esm/transport/{3_transport_provider_web_socket.js → 2_transport_provider_web_socket.js} +1 -1
- package/esm/types/0_upload_progress.d.ts +29 -0
- package/esm/types/0_upload_progress.d.ts.map +1 -0
- package/esm/types/0_upload_progress.js +20 -0
- package/esm/types/{2_inline_keyboard_button.d.ts → 1_inline_keyboard_button.d.ts} +1 -1
- package/esm/types/{2_inline_keyboard_button.d.ts.map → 1_inline_keyboard_button.d.ts.map} +1 -1
- package/esm/types/1_sticker.d.ts +1 -1
- package/esm/types/1_sticker.d.ts.map +1 -1
- package/esm/types/2_chat.d.ts.map +1 -1
- package/esm/types/2_poll_answer.d.ts +19 -0
- package/esm/types/2_poll_answer.d.ts.map +1 -1
- package/esm/types/2_poll_answer.js +19 -0
- package/esm/types/2_pre_checkout_query.d.ts.map +1 -1
- package/esm/types/{3_reply_markup.d.ts → 2_reply_markup.d.ts} +2 -2
- package/esm/types/{3_reply_markup.d.ts.map → 2_reply_markup.d.ts.map} +1 -1
- package/esm/types/{3_reply_markup.js → 2_reply_markup.js} +1 -1
- package/esm/types/2_story_interactive_area.d.ts.map +1 -1
- package/esm/types/3_chat_member_updated.d.ts.map +1 -1
- package/esm/types/3_story.d.ts.map +1 -1
- package/esm/types/5_message.d.ts +1 -1
- package/esm/types/5_message.d.ts.map +1 -1
- package/esm/types/5_message.js +1 -1
- package/esm/types/6_inline_query_result.d.ts +1 -1
- package/esm/types/6_inline_query_result.js +1 -1
- package/esm/types/7_update.d.ts +21 -2
- package/esm/types/7_update.d.ts.map +1 -1
- package/esm/utilities/0_bigint_test.d.ts.map +1 -1
- package/esm/utilities/0_buffer.d.ts +1 -1
- package/esm/utilities/0_buffer.d.ts.map +1 -1
- package/esm/utilities/0_buffer_test.d.ts.map +1 -1
- package/esm/utilities/0_hash.d.ts +2 -2
- package/esm/utilities/0_hash.d.ts.map +1 -1
- package/esm/utilities/0_mutex.js +4 -19
- package/esm/utilities/0_part_stream.js +11 -25
- package/esm/utilities/0_part_stream_test.d.ts.map +1 -1
- package/esm/utilities/0_rle.d.ts +2 -2
- package/esm/utilities/0_rle.d.ts.map +1 -1
- package/esm/utilities/0_rle_test.d.ts.map +1 -1
- package/esm/utilities/0_text.d.ts +20 -1
- package/esm/utilities/0_text.d.ts.map +1 -1
- package/esm/utilities/0_text.js +19 -0
- package/esm/utilities/1_auth.d.ts +1 -1
- package/esm/utilities/1_auth.d.ts.map +1 -1
- package/esm/utilities/1_base64.d.ts +1 -1
- package/esm/utilities/1_base64.d.ts.map +1 -1
- package/esm/utilities/1_base64_test.d.ts.map +1 -1
- package/esm/utilities/1_crypto.js +42 -53
- package/esm/utilities/1_crypto_test.d.ts.map +1 -1
- package/esm/utilities/1_logger.d.ts +2 -2
- package/esm/utilities/1_math_test.d.ts.map +1 -1
- package/esm/utilities/2_queue.js +29 -47
- package/package.json +1 -1
- package/script/0_errors.js +2 -6
- package/script/2_tl.js +17 -7
- package/script/3_errors.js +2 -12
- package/script/3_transport.d.ts +3 -3
- package/script/3_transport.js +3 -3
- package/script/3_types.d.ts +8 -7
- package/script/3_types.d.ts.map +1 -1
- package/script/3_types.js +8 -7
- package/script/4_constants.js +17 -7
- package/script/4_errors.js +2 -12
- package/script/_dnt.polyfills.d.ts +99 -0
- package/script/_dnt.polyfills.d.ts.map +1 -1
- package/script/_dnt.polyfills.js +128 -0
- package/script/_dnt.test_polyfills.d.ts.map +1 -0
- package/script/client/0_filters_test.d.ts.map +1 -1
- package/script/client/0_markdown_test.d.ts.map +1 -1
- package/script/client/0_params.d.ts +2 -0
- package/script/client/0_params.d.ts.map +1 -1
- package/script/client/0_password.d.ts +5 -5
- package/script/client/0_password.d.ts.map +1 -1
- package/script/client/0_password.js +17 -7
- package/script/client/0_password_test.d.ts.map +1 -1
- package/script/client/0_storage_operations.js +143 -155
- package/script/client/0_storage_operations_test.d.ts.map +1 -1
- package/script/client/0_utilities.d.ts +1 -1
- package/script/client/0_utilities_test.d.ts.map +1 -1
- package/script/client/1_client_plain.js +4 -22
- package/script/client/1_composer.js +8 -21
- package/script/client/2_account_manager.js +85 -97
- package/script/client/2_bot_info_manager.js +26 -38
- package/script/client/2_business_connection_manager.js +10 -23
- package/script/client/2_client_encrypted.js +195 -212
- package/script/client/2_file_manager.d.ts +4 -3
- package/script/client/2_file_manager.d.ts.map +1 -1
- package/script/client/2_file_manager.js +285 -231
- package/script/client/2_file_manager_test.d.ts.map +1 -1
- package/script/client/2_network_statistics_manager.js +8 -21
- package/script/client/2_payment_manager.js +7 -20
- package/script/client/2_reaction_manager.js +7 -20
- package/script/client/2_translations_manager.js +98 -108
- package/script/client/2_update_manager.js +764 -759
- package/script/client/3_client_encrypted_pool.js +10 -26
- package/script/client/3_client_encrypted_pool_test.d.ts.map +1 -1
- package/script/client/3_message_manager.d.ts +1 -1
- package/script/client/3_message_manager.js +441 -448
- package/script/client/3_message_manager_test.d.ts.map +1 -1
- package/script/client/3_video_chat_manager.d.ts +1 -1
- package/script/client/3_video_chat_manager.js +57 -68
- package/script/client/4_callback_query_manager.js +18 -30
- package/script/client/4_chat_list_manager.js +322 -318
- package/script/client/4_chat_manager.js +118 -131
- package/script/client/4_forum_manager.js +67 -73
- package/script/client/4_gift_manager.js +16 -29
- package/script/client/4_inline_query_manager.js +16 -28
- package/script/client/4_link_preview_manager.js +6 -19
- package/script/client/4_poll_manager.js +44 -57
- package/script/client/4_story_manager.js +41 -53
- package/script/client/5_client.d.ts +7 -0
- package/script/client/5_client.d.ts.map +1 -1
- package/script/client/5_client.js +1271 -1290
- package/script/connection/1_connection_tcp.node.js +48 -65
- package/script/connection/1_connection_web_socket.js +92 -98
- package/script/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
- package/script/deps/jsr.io/@std/assert/1.0.13/equal.js +17 -7
- package/script/deps/jsr.io/@std/assert/1.0.13/equals.js +4 -4
- package/script/deps/jsr.io/@std/async/1.0.13/delay.js +17 -7
- package/script/deps/jsr.io/@std/async/1.0.13/mux_async_iterator.js +31 -47
- package/script/deps/jsr.io/@std/async/1.0.13/tee.js +11 -34
- package/script/deps/jsr.io/@std/datetime/0.225.5/_date_time_formatter.js +4 -17
- package/script/deps/jsr.io/@std/internal/1.0.10/build_message.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/diff.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/diff_str.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/format.d.ts +29 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/format.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/format.js +106 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/styles.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.js +17 -7
- package/script/deps/jsr.io/@std/internal/1.0.10/types.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.0/_os.js +17 -7
- package/script/mod.js +19 -19
- package/script/session/0_session_state.js +12 -38
- package/script/session/1_session.js +66 -79
- package/script/session/2_session_encrypted.js +325 -321
- package/script/storage/1_utilities_test.d.ts.map +1 -1
- package/script/storage/2_storage_indexed_db.js +26 -44
- package/script/storage/2_storage_local_storage.node.js +12 -25
- package/script/storage/2_storage_memory.js +24 -41
- package/script/storage/2_storage_session_storage.js +3 -16
- package/script/tl/0_utilities_test.d.ts.map +1 -1
- package/script/tl/1_tl_reader.js +81 -89
- package/script/tl/1_tl_reader_test.d.ts.map +1 -1
- package/script/tl/1_tl_writer.js +156 -165
- package/script/tl/1_tl_writer_test.d.ts.map +1 -1
- package/script/tl/2_telegram.d.ts +9 -10
- package/script/tl/2_telegram.d.ts.map +1 -1
- package/script/tl/2_telegram.js +32 -10
- package/script/transport/0_obfuscation.js +17 -7
- package/script/transport/0_transport.js +1 -8
- package/script/transport/1_transport_abridged.js +11 -24
- package/script/transport/1_transport_intermediate.js +10 -23
- package/{esm/transport/2_transport_provider.d.ts → script/transport/1_transport_provider.d.ts} +1 -1
- package/script/transport/{2_transport_provider.d.ts.map → 1_transport_provider.d.ts.map} +1 -1
- package/{esm/transport/3_transport_provider_tcp.d.ts → script/transport/2_transport_provider_tcp.d.ts} +2 -2
- package/script/transport/{3_transport_provider_tcp.d.ts.map → 2_transport_provider_tcp.d.ts.map} +1 -1
- package/script/transport/{3_transport_provider_tcp.js → 2_transport_provider_tcp.js} +3 -3
- package/script/transport/{3_transport_provider_web_socket.d.ts → 2_transport_provider_web_socket.d.ts} +2 -2
- package/script/transport/2_transport_provider_web_socket.d.ts.map +1 -0
- package/script/transport/{3_transport_provider_web_socket.js → 2_transport_provider_web_socket.js} +2 -2
- package/script/types/0_upload_progress.d.ts +29 -0
- package/script/types/0_upload_progress.d.ts.map +1 -0
- package/script/types/0_upload_progress.js +21 -0
- package/script/types/{2_inline_keyboard_button.d.ts → 1_inline_keyboard_button.d.ts} +1 -1
- package/script/types/{2_inline_keyboard_button.d.ts.map → 1_inline_keyboard_button.d.ts.map} +1 -1
- package/script/types/1_sticker.d.ts +1 -1
- package/script/types/1_sticker.d.ts.map +1 -1
- package/script/types/2_chat.d.ts.map +1 -1
- package/script/types/2_poll_answer.d.ts +19 -0
- package/script/types/2_poll_answer.d.ts.map +1 -1
- package/script/types/2_poll_answer.js +19 -0
- package/script/types/2_pre_checkout_query.d.ts.map +1 -1
- package/script/types/{3_reply_markup.d.ts → 2_reply_markup.d.ts} +2 -2
- package/script/types/{3_reply_markup.d.ts.map → 2_reply_markup.d.ts.map} +1 -1
- package/script/types/{3_reply_markup.js → 2_reply_markup.js} +3 -3
- package/script/types/2_story_interactive_area.d.ts.map +1 -1
- package/script/types/3_chat_member_updated.d.ts.map +1 -1
- package/script/types/3_story.d.ts.map +1 -1
- package/script/types/5_message.d.ts +1 -1
- package/script/types/5_message.d.ts.map +1 -1
- package/script/types/5_message.js +2 -2
- package/script/types/6_inline_query_result.d.ts +1 -1
- package/script/types/6_inline_query_result.js +4 -4
- package/script/types/7_update.d.ts +21 -2
- package/script/types/7_update.d.ts.map +1 -1
- package/script/utilities/0_bigint.js +17 -7
- package/script/utilities/0_bigint_test.d.ts.map +1 -1
- package/script/utilities/0_buffer.d.ts +1 -1
- package/script/utilities/0_buffer.d.ts.map +1 -1
- package/script/utilities/0_buffer_test.d.ts.map +1 -1
- package/script/utilities/0_env.js +17 -7
- package/script/utilities/0_hash.d.ts +2 -2
- package/script/utilities/0_hash.d.ts.map +1 -1
- package/script/utilities/0_hash.js +17 -7
- package/script/utilities/0_misc.js +17 -7
- package/script/utilities/0_mutex.js +4 -19
- package/script/utilities/0_part_stream.js +11 -25
- package/script/utilities/0_part_stream_test.d.ts.map +1 -1
- package/script/utilities/0_rle.d.ts +2 -2
- package/script/utilities/0_rle.d.ts.map +1 -1
- package/script/utilities/0_rle_test.d.ts.map +1 -1
- package/script/utilities/0_text.d.ts +20 -1
- package/script/utilities/0_text.d.ts.map +1 -1
- package/script/utilities/0_text.js +19 -0
- package/script/utilities/1_auth.d.ts +1 -1
- package/script/utilities/1_auth.d.ts.map +1 -1
- package/script/utilities/1_auth.js +17 -7
- package/script/utilities/1_base64.d.ts +1 -1
- package/script/utilities/1_base64.d.ts.map +1 -1
- package/script/utilities/1_base64_test.d.ts.map +1 -1
- package/script/utilities/1_crypto.js +60 -61
- package/script/utilities/1_crypto_test.d.ts.map +1 -1
- package/script/utilities/1_logger.d.ts +2 -2
- package/script/utilities/1_math_test.d.ts.map +1 -1
- package/script/utilities/2_queue.js +30 -48
- package/esm/deps/jsr.io/@std/internal/1.0.9/build_message.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/diff.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/diff_str.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/format.d.ts +0 -2
- package/esm/deps/jsr.io/@std/internal/1.0.9/format.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/format.js +0 -37
- package/esm/deps/jsr.io/@std/internal/1.0.9/styles.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/types.d.ts.map +0 -1
- package/esm/transport/3_transport_provider_web_socket.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/build_message.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/diff.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/diff_str.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/format.d.ts +0 -2
- package/script/deps/jsr.io/@std/internal/1.0.9/format.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/format.js +0 -63
- package/script/deps/jsr.io/@std/internal/1.0.9/styles.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/types.d.ts.map +0 -1
- package/script/transport/3_transport_provider_web_socket.d.ts.map +0 -1
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.js +0 -0
- /package/esm/transport/{2_transport_provider.js → 1_transport_provider.js} +0 -0
- /package/esm/types/{2_inline_keyboard_button.js → 1_inline_keyboard_button.js} +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.js +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.js +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.js +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.js +0 -0
- /package/script/transport/{2_transport_provider.js → 1_transport_provider.js} +0 -0
- /package/script/types/{2_inline_keyboard_button.js → 1_inline_keyboard_button.js} +0 -0
|
@@ -18,18 +18,6 @@
|
|
|
18
18
|
* You should have received a copy of the GNU Lesser General Public License
|
|
19
19
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
22
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
23
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
24
|
-
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");
|
|
25
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
26
|
-
};
|
|
27
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
28
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
29
|
-
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");
|
|
30
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
31
|
-
};
|
|
32
|
-
var _MessageManager_instances, _a, _MessageManager_c, _MessageManager_LresolveFileId, _MessageManager_checkParams, _MessageManager_constructReplyMarkup, _MessageManager_resolveSendAs, _MessageManager_constructReplyTo, _MessageManager_sendDocumentInner, _MessageManager_sendMedia, _MessageManager_CAPTIONABLE_MESSAGE_TYPES, _MessageManager_editInlineMessageTextInner, _MessageManager_resolveInputMediaInner, _MessageManager_resolveInputMedia, _MessageManager_sendReaction, _MessageManager_getCachedVoiceTranscription, _MessageManager_cacheVoiceTranscription;
|
|
33
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
22
|
exports.MessageManager = void 0;
|
|
35
23
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
@@ -60,31 +48,21 @@ const messageManagerUpdates = [
|
|
|
60
48
|
"updateTranscribedAudio",
|
|
61
49
|
];
|
|
62
50
|
class MessageManager {
|
|
51
|
+
#c;
|
|
52
|
+
#LresolveFileId;
|
|
63
53
|
constructor(c) {
|
|
64
|
-
|
|
65
|
-
_MessageManager_c.set(this, void 0);
|
|
66
|
-
_MessageManager_LresolveFileId.set(this, void 0);
|
|
67
|
-
Object.defineProperty(this, "usernameResolver", {
|
|
68
|
-
enumerable: true,
|
|
69
|
-
configurable: true,
|
|
70
|
-
writable: true,
|
|
71
|
-
value: async (v) => {
|
|
72
|
-
const inputPeer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(v).then((v) => _2_tl_js_1.Api.as("inputPeerUser", v));
|
|
73
|
-
return { ...inputPeer, _: "inputUser" };
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
__classPrivateFieldSet(this, _MessageManager_c, c, "f");
|
|
54
|
+
this.#c = c;
|
|
77
55
|
const L = (0, _1_utilities_js_1.getLogger)("MessageManager").client(c.id);
|
|
78
|
-
|
|
56
|
+
this.#LresolveFileId = L.branch("resolveFileId");
|
|
79
57
|
}
|
|
80
58
|
async getMessages(chatId, messageIds) {
|
|
81
59
|
(0, _0_utilities_js_1.checkArray)(messageIds, _0_utilities_js_1.checkMessageId);
|
|
82
|
-
const peer = await
|
|
60
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
83
61
|
let messages_ = new Array();
|
|
84
|
-
const chatId_ = await
|
|
62
|
+
const chatId_ = await this.#c.getInputPeerChatId(peer);
|
|
85
63
|
let shouldFetch = false;
|
|
86
64
|
for (const messageId of messageIds) {
|
|
87
|
-
const message = await
|
|
65
|
+
const message = await this.#c.messageStorage.getMessage(chatId_, messageId);
|
|
88
66
|
if (message == null) {
|
|
89
67
|
messages_ = [];
|
|
90
68
|
shouldFetch = true;
|
|
@@ -96,10 +74,10 @@ class MessageManager {
|
|
|
96
74
|
}
|
|
97
75
|
if (shouldFetch) {
|
|
98
76
|
if ((0, _0_utilities_js_1.canBeInputChannel)(peer)) {
|
|
99
|
-
messages_ = await
|
|
77
|
+
messages_ = await this.#c.invoke({ _: "channels.getMessages", channel: (0, _0_utilities_js_1.toInputChannel)(peer), id: messageIds.map((v) => ({ _: "inputMessageID", id: v })) }).then((v) => _2_tl_js_1.Api.as("messages.channelMessages", v).messages);
|
|
100
78
|
}
|
|
101
79
|
else {
|
|
102
|
-
messages_ = await
|
|
80
|
+
messages_ = await this.#c.invoke({
|
|
103
81
|
_: "messages.getMessages",
|
|
104
82
|
id: messageIds.map((v) => ({ _: "inputMessageID", id: v })),
|
|
105
83
|
}).then((v) => _2_tl_js_1.Api.as("messages.messages", v).messages);
|
|
@@ -162,9 +140,23 @@ class MessageManager {
|
|
|
162
140
|
}
|
|
163
141
|
return [text, entities];
|
|
164
142
|
}
|
|
143
|
+
#checkParams(params) {
|
|
144
|
+
if (params && "replyMarkup" in params && params.replyMarkup !== undefined) {
|
|
145
|
+
this.#c.storage.assertBot("replyMarkup");
|
|
146
|
+
}
|
|
147
|
+
if (params && "businessConnectionId" in params && params.businessConnectionId !== undefined) {
|
|
148
|
+
this.#c.storage.assertBot("businessConnectionId");
|
|
149
|
+
}
|
|
150
|
+
if (params && "sendAs" in params && params.sendAs !== undefined) {
|
|
151
|
+
this.#c.storage.assertUser("sendAs");
|
|
152
|
+
}
|
|
153
|
+
if (params && "sendAt" in params && params.sendAt !== undefined) {
|
|
154
|
+
this.#c.storage.assertUser("businessConsendAtnectionId");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
165
157
|
async parseText(text_, params) {
|
|
166
|
-
const [text, entities_] =
|
|
167
|
-
const entities = entities_?.length > 0 ? await Promise.all(entities_.map((v) => (0, _3_types_js_2.messageEntityToTlObject)(v,
|
|
158
|
+
const [text, entities_] = MessageManager.parseText(text_, params?.entities ?? [], params?.parseMode ?? this.#c.parseMode);
|
|
159
|
+
const entities = entities_?.length > 0 ? await Promise.all(entities_.map((v) => (0, _3_types_js_2.messageEntityToTlObject)(v, this.#c.getEntity))) : undefined;
|
|
168
160
|
return [text, entities];
|
|
169
161
|
}
|
|
170
162
|
async updatesToMessages(chatId, updates, businessConnectionId) {
|
|
@@ -206,35 +198,35 @@ class MessageManager {
|
|
|
206
198
|
let poll = null;
|
|
207
199
|
let pollResults = null;
|
|
208
200
|
if (pollId) {
|
|
209
|
-
[poll, pollResults] = await Promise.all([
|
|
201
|
+
[poll, pollResults] = await Promise.all([this.#c.messageStorage.getPoll(pollId), this.#c.messageStorage.getPollResults(pollId)]);
|
|
210
202
|
}
|
|
211
|
-
const message = await (0, _3_types_js_2.constructMessage)(message_,
|
|
203
|
+
const message = await (0, _3_types_js_2.constructMessage)(message_, this.#c.getEntity, this.getMessage.bind(this), this.#c.fileManager.getStickerSetName.bind(this.#c.fileManager), r, business, poll ?? undefined, pollResults ?? undefined);
|
|
212
204
|
if (!poll && mediaPoll) {
|
|
213
|
-
await
|
|
205
|
+
await this.#c.storage.setPoll(mediaPoll.poll.id, mediaPoll.poll);
|
|
214
206
|
}
|
|
215
207
|
if (!pollResults && mediaPoll) {
|
|
216
|
-
await
|
|
208
|
+
await this.#c.storage.setPollResults(mediaPoll.poll.id, mediaPoll.results);
|
|
217
209
|
}
|
|
218
210
|
return message;
|
|
219
211
|
}
|
|
220
212
|
async forwardMessages(from, to, messageIds, params) {
|
|
221
213
|
(0, _0_utilities_js_1.checkArray)(messageIds, _0_utilities_js_1.checkMessageId);
|
|
222
|
-
const result = await
|
|
214
|
+
const result = await this.#c.invoke({ _: "messages.forwardMessages", from_peer: await this.#c.getInputPeer(from), to_peer: await this.#c.getInputPeer(to), id: messageIds, random_id: messageIds.map(() => (0, _1_utilities_js_1.getRandomId)()), silent: params?.disableNotification || undefined, top_msg_id: params?.messageThreadId, noforwards: params?.disableNotification || undefined, send_as: params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined, drop_author: params?.dropSenderName || undefined, drop_media_captions: params?.dropCaption || undefined });
|
|
223
215
|
return await this.updatesToMessages(to, result);
|
|
224
216
|
}
|
|
225
217
|
async getHistory(chatId, params) {
|
|
226
|
-
|
|
218
|
+
this.#c.storage.assertUser("getHistory");
|
|
227
219
|
const limit = (0, _0_utilities_js_1.getLimit)(params?.limit);
|
|
228
220
|
let offsetId = params?.fromMessageId ?? 0;
|
|
229
221
|
if (offsetId < 0) {
|
|
230
222
|
offsetId = 0;
|
|
231
223
|
}
|
|
232
|
-
const peer = await
|
|
224
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
233
225
|
const messages = new Array();
|
|
234
226
|
if (messages.length > 0) {
|
|
235
227
|
offsetId = messages[messages.length - 1].id; // TODO: track id of oldest message and don't send requests for it
|
|
236
228
|
}
|
|
237
|
-
const result = await
|
|
229
|
+
const result = await this.#c.invoke({ _: "messages.getHistory", peer: peer, offset_id: offsetId, offset_date: 0, add_offset: 0, limit, max_id: 0, min_id: 0, hash: 0n });
|
|
238
230
|
if (!("messages" in result)) {
|
|
239
231
|
(0, _0_deps_js_1.unreachable)();
|
|
240
232
|
}
|
|
@@ -244,23 +236,40 @@ class MessageManager {
|
|
|
244
236
|
}
|
|
245
237
|
return messages;
|
|
246
238
|
}
|
|
239
|
+
usernameResolver = async (v) => {
|
|
240
|
+
const inputPeer = await this.#c.getInputPeer(v).then((v) => _2_tl_js_1.Api.as("inputPeerUser", v));
|
|
241
|
+
return { ...inputPeer, _: "inputUser" };
|
|
242
|
+
};
|
|
243
|
+
async #constructReplyMarkup(params) {
|
|
244
|
+
if (params?.replyMarkup) {
|
|
245
|
+
this.#c.storage.assertBot("replyMarkup");
|
|
246
|
+
return await (0, _3_types_js_2.replyMarkupToTlObject)(params.replyMarkup, this.usernameResolver.bind(this));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
async #resolveSendAs(params) {
|
|
250
|
+
const sendAs = params?.sendAs;
|
|
251
|
+
if (sendAs !== undefined) {
|
|
252
|
+
this.#c.storage.assertUser("sendAs");
|
|
253
|
+
return sendAs ? await this.#c.getInputPeer(sendAs) : undefined;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
247
256
|
async sendMessage(chatId, text, params) {
|
|
248
|
-
|
|
257
|
+
this.#checkParams(params);
|
|
249
258
|
const [message, entities] = await this.parseText(text, params);
|
|
250
|
-
const replyMarkup = await
|
|
251
|
-
const peer = await
|
|
259
|
+
const replyMarkup = await this.#constructReplyMarkup(params);
|
|
260
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
252
261
|
const randomId = (0, _1_utilities_js_1.getRandomId)();
|
|
253
262
|
const noWebpage = params?.linkPreview?.disable ? true : undefined;
|
|
254
263
|
const invertMedia = params?.linkPreview?.aboveText ? true : undefined;
|
|
255
264
|
const silent = params?.disableNotification ? true : undefined;
|
|
256
265
|
const noforwards = params?.protectContent ? true : undefined;
|
|
257
|
-
const sendAs = await
|
|
266
|
+
const sendAs = await this.#resolveSendAs(params);
|
|
258
267
|
const effect = params?.effectId ? BigInt(params.effectId) : undefined;
|
|
259
268
|
const schedule_date = params?.sendAt;
|
|
260
269
|
const allow_paid_floodskip = params?.paidBroadcast ? true : undefined;
|
|
261
270
|
let result;
|
|
262
271
|
if (!noWebpage && params?.linkPreview?.url) {
|
|
263
|
-
result = await
|
|
272
|
+
result = await this.#c.invoke({
|
|
264
273
|
_: "messages.sendMedia",
|
|
265
274
|
peer,
|
|
266
275
|
random_id: randomId,
|
|
@@ -275,7 +284,7 @@ class MessageManager {
|
|
|
275
284
|
invert_media: invertMedia,
|
|
276
285
|
silent,
|
|
277
286
|
noforwards,
|
|
278
|
-
reply_to: await
|
|
287
|
+
reply_to: await this.#constructReplyTo(params),
|
|
279
288
|
send_as: sendAs,
|
|
280
289
|
entities,
|
|
281
290
|
reply_markup: replyMarkup,
|
|
@@ -285,7 +294,7 @@ class MessageManager {
|
|
|
285
294
|
}, { businessConnectionId: params?.businessConnectionId });
|
|
286
295
|
}
|
|
287
296
|
else {
|
|
288
|
-
result = await
|
|
297
|
+
result = await this.#c.invoke({
|
|
289
298
|
_: "messages.sendMessage",
|
|
290
299
|
peer,
|
|
291
300
|
random_id: randomId,
|
|
@@ -294,7 +303,7 @@ class MessageManager {
|
|
|
294
303
|
invert_media: invertMedia,
|
|
295
304
|
silent,
|
|
296
305
|
noforwards,
|
|
297
|
-
reply_to: await
|
|
306
|
+
reply_to: await this.#constructReplyTo(params),
|
|
298
307
|
send_as: sendAs,
|
|
299
308
|
entities,
|
|
300
309
|
reply_markup: replyMarkup,
|
|
@@ -306,21 +315,38 @@ class MessageManager {
|
|
|
306
315
|
const message_ = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
|
|
307
316
|
return (0, _3_types_js_2.assertMessageType)(message_, "text");
|
|
308
317
|
}
|
|
318
|
+
async #constructReplyTo(params) {
|
|
319
|
+
const topMsgId = params?.messageThreadId;
|
|
320
|
+
if (!params?.replyTo) {
|
|
321
|
+
if (topMsgId) {
|
|
322
|
+
return { _: "inputReplyToMessage", reply_to_msg_id: topMsgId };
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
return undefined;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
if ("messageId" in params.replyTo) {
|
|
329
|
+
return { _: "inputReplyToMessage", reply_to_msg_id: params.replyTo.messageId, top_msg_id: topMsgId, quote_text: params.replyTo.quote?.text, quote_entities: await Promise.all(params.replyTo.quote?.entities.map((v) => (0, _3_types_js_2.messageEntityToTlObject)(v, this.#c.getEntity)) ?? []), quote_offset: params.replyTo.quote?.offset };
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
return { _: "inputReplyToStory", peer: await this.#c.getInputPeer(params.replyTo.chatId), story_id: params.replyTo.storyId };
|
|
333
|
+
}
|
|
334
|
+
}
|
|
309
335
|
async sendVenue(chatId, latitude, longitude, title, address, params) {
|
|
310
|
-
|
|
311
|
-
const peer = await
|
|
336
|
+
this.#checkParams(params);
|
|
337
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
312
338
|
const randomId = (0, _1_utilities_js_1.getRandomId)();
|
|
313
339
|
const silent = params?.disableNotification ? true : undefined;
|
|
314
340
|
const noforwards = params?.protectContent ? true : undefined;
|
|
315
|
-
const sendAs = params?.sendAs ? await
|
|
316
|
-
const replyMarkup = await
|
|
317
|
-
const result = await
|
|
341
|
+
const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
|
|
342
|
+
const replyMarkup = await this.#constructReplyMarkup(params);
|
|
343
|
+
const result = await this.#c.invoke({
|
|
318
344
|
_: "messages.sendMedia",
|
|
319
345
|
peer,
|
|
320
346
|
random_id: randomId,
|
|
321
347
|
silent,
|
|
322
348
|
noforwards,
|
|
323
|
-
reply_to: await
|
|
349
|
+
reply_to: await this.#constructReplyTo(params),
|
|
324
350
|
send_as: sendAs,
|
|
325
351
|
reply_markup: replyMarkup,
|
|
326
352
|
media: ({
|
|
@@ -345,20 +371,20 @@ class MessageManager {
|
|
|
345
371
|
return (0, _3_types_js_2.assertMessageType)(message, "venue");
|
|
346
372
|
}
|
|
347
373
|
async sendContact(chatId, firstName, number, params) {
|
|
348
|
-
|
|
349
|
-
const peer = await
|
|
374
|
+
this.#checkParams(params);
|
|
375
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
350
376
|
const randomId = (0, _1_utilities_js_1.getRandomId)();
|
|
351
377
|
const silent = params?.disableNotification ? true : undefined;
|
|
352
378
|
const noforwards = params?.protectContent ? true : undefined;
|
|
353
|
-
const sendAs = params?.sendAs ? await
|
|
354
|
-
const replyMarkup = await
|
|
355
|
-
const result = await
|
|
379
|
+
const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
|
|
380
|
+
const replyMarkup = await this.#constructReplyMarkup(params);
|
|
381
|
+
const result = await this.#c.invoke({
|
|
356
382
|
_: "messages.sendMedia",
|
|
357
383
|
peer,
|
|
358
384
|
random_id: randomId,
|
|
359
385
|
silent,
|
|
360
386
|
noforwards,
|
|
361
|
-
reply_to: await
|
|
387
|
+
reply_to: await this.#constructReplyTo(params),
|
|
362
388
|
send_as: sendAs,
|
|
363
389
|
reply_markup: replyMarkup,
|
|
364
390
|
media: ({
|
|
@@ -377,20 +403,20 @@ class MessageManager {
|
|
|
377
403
|
return (0, _3_types_js_2.assertMessageType)(message, "contact");
|
|
378
404
|
}
|
|
379
405
|
async sendDice(chatId, params) {
|
|
380
|
-
|
|
381
|
-
const peer = await
|
|
406
|
+
this.#checkParams(params);
|
|
407
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
382
408
|
const randomId = (0, _1_utilities_js_1.getRandomId)();
|
|
383
409
|
const silent = params?.disableNotification ? true : undefined;
|
|
384
410
|
const noforwards = params?.protectContent ? true : undefined;
|
|
385
|
-
const sendAs = params?.sendAs ? await
|
|
386
|
-
const replyMarkup = await
|
|
387
|
-
const result = await
|
|
411
|
+
const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
|
|
412
|
+
const replyMarkup = await this.#constructReplyMarkup(params);
|
|
413
|
+
const result = await this.#c.invoke({
|
|
388
414
|
_: "messages.sendMedia",
|
|
389
415
|
peer,
|
|
390
416
|
random_id: randomId,
|
|
391
417
|
silent,
|
|
392
418
|
noforwards,
|
|
393
|
-
reply_to: await
|
|
419
|
+
reply_to: await this.#constructReplyTo(params),
|
|
394
420
|
send_as: sendAs,
|
|
395
421
|
reply_markup: replyMarkup,
|
|
396
422
|
media: ({
|
|
@@ -406,20 +432,20 @@ class MessageManager {
|
|
|
406
432
|
return (0, _3_types_js_2.assertMessageType)(message, "dice");
|
|
407
433
|
}
|
|
408
434
|
async sendLocation(chatId, latitude, longitude, params) {
|
|
409
|
-
|
|
410
|
-
const peer = await
|
|
435
|
+
this.#checkParams(params);
|
|
436
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
411
437
|
const randomId = (0, _1_utilities_js_1.getRandomId)();
|
|
412
438
|
const silent = params?.disableNotification ? true : undefined;
|
|
413
439
|
const noforwards = params?.protectContent ? true : undefined;
|
|
414
|
-
const sendAs = params?.sendAs ? await
|
|
415
|
-
const replyMarkup = await
|
|
416
|
-
const result = await
|
|
440
|
+
const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
|
|
441
|
+
const replyMarkup = await this.#constructReplyMarkup(params);
|
|
442
|
+
const result = await this.#c.invoke({
|
|
417
443
|
_: "messages.sendMedia",
|
|
418
444
|
peer,
|
|
419
445
|
random_id: randomId,
|
|
420
446
|
silent,
|
|
421
447
|
noforwards,
|
|
422
|
-
reply_to: await
|
|
448
|
+
reply_to: await this.#constructReplyTo(params),
|
|
423
449
|
send_as: sendAs,
|
|
424
450
|
reply_markup: replyMarkup,
|
|
425
451
|
media: params?.livePeriod !== undefined
|
|
@@ -453,53 +479,95 @@ class MessageManager {
|
|
|
453
479
|
return (0, _3_types_js_2.assertMessageType)(message, "location");
|
|
454
480
|
}
|
|
455
481
|
async sendVideoNote(chatId, audio, params) {
|
|
456
|
-
|
|
457
|
-
const message = await
|
|
482
|
+
this.#checkParams(params);
|
|
483
|
+
const message = await this.#sendDocumentInner(chatId, audio, params, _3_types_js_2.FileType.VideoNote, [
|
|
458
484
|
{ _: "documentAttributeVideo", round_message: true, w: params?.length ?? 0, h: params?.length ?? 0, duration: params?.duration ?? 0 },
|
|
459
485
|
], false);
|
|
460
486
|
return (0, _3_types_js_2.assertMessageType)(message, "videoNote");
|
|
461
487
|
}
|
|
462
488
|
async sendAudio(chatId, audio, params) {
|
|
463
|
-
|
|
464
|
-
const message = await
|
|
489
|
+
this.#checkParams(params);
|
|
490
|
+
const message = await this.#sendDocumentInner(chatId, audio, params, _3_types_js_2.FileType.Audio, [
|
|
465
491
|
{ _: "documentAttributeAudio", duration: params?.duration ?? 0, performer: params?.performer, title: params?.title },
|
|
466
492
|
]);
|
|
467
493
|
return (0, _3_types_js_2.assertMessageType)(message, "audio");
|
|
468
494
|
}
|
|
469
495
|
async sendVoice(chatId, voice, params) {
|
|
470
|
-
|
|
471
|
-
const message = await
|
|
496
|
+
this.#checkParams(params);
|
|
497
|
+
const message = await this.#sendDocumentInner(chatId, voice, params, _3_types_js_2.FileType.VoiceNote, [
|
|
472
498
|
{ _: "documentAttributeAudio", voice: true, duration: params?.duration ?? 0 },
|
|
473
499
|
]);
|
|
474
500
|
return (0, _3_types_js_2.assertMessageType)(message, "voice");
|
|
475
501
|
}
|
|
476
502
|
async sendAnimation(chatId, animation, params) {
|
|
477
|
-
|
|
478
|
-
const message = await
|
|
503
|
+
this.#checkParams(params);
|
|
504
|
+
const message = await this.#sendDocumentInner(chatId, animation, params, _3_types_js_2.FileType.Animation, [
|
|
479
505
|
{ _: "documentAttributeAnimated" },
|
|
480
506
|
{ _: "documentAttributeVideo", supports_streaming: true, w: params?.width ?? 0, h: params?.height ?? 0, duration: params?.duration ?? 0 },
|
|
481
507
|
]);
|
|
482
508
|
return (0, _3_types_js_2.assertMessageType)(message, "animation");
|
|
483
509
|
}
|
|
484
510
|
async sendVideo(chatId, video, params) {
|
|
485
|
-
|
|
486
|
-
const message = await
|
|
511
|
+
this.#checkParams(params);
|
|
512
|
+
const message = await this.#sendDocumentInner(chatId, video, params, _3_types_js_2.FileType.Video, [
|
|
487
513
|
{ _: "documentAttributeVideo", supports_streaming: params?.supportsStreaming ? true : undefined, w: params?.width ?? 0, h: params?.height ?? 0, duration: params?.duration ?? 0 },
|
|
488
514
|
]);
|
|
489
515
|
return (0, _3_types_js_2.assertMessageType)(message, "video");
|
|
490
516
|
}
|
|
517
|
+
async #sendDocumentInner(chatId, document, params, fileType, otherAttribs, urlSupported = true, expectedMimeTypes) {
|
|
518
|
+
let media = null;
|
|
519
|
+
const spoiler = params?.hasSpoiler ? true : undefined;
|
|
520
|
+
const ttl_seconds = params && "selfDestruct" in params && typeof params.selfDestruct !== undefined ? (0, _3_types_js_1.selfDestructOptionToInt)(params.selfDestruct) : undefined;
|
|
521
|
+
if (typeof document === "string") {
|
|
522
|
+
const fileId = this.resolveFileId(document, fileType);
|
|
523
|
+
if (fileId != null) {
|
|
524
|
+
media = { _: "inputMediaDocument", id: { ...fileId, _: "inputDocument" }, spoiler, query: otherAttribs.find((v) => _2_tl_js_1.Api.is("documentAttributeSticker", v))?.alt || undefined, ttl_seconds };
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
if (media == null) {
|
|
528
|
+
if (typeof document === "string" && (0, _0_utilities_js_1.isHttpUrl)(document)) {
|
|
529
|
+
if (!urlSupported) {
|
|
530
|
+
throw new _0_errors_js_1.InputError("URL not supported.");
|
|
531
|
+
}
|
|
532
|
+
media = { _: "inputMediaDocumentExternal", url: document, spoiler, ttl_seconds };
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
let mimeType;
|
|
536
|
+
const file = await this.#c.fileManager.upload(document, params, (name) => {
|
|
537
|
+
mimeType = params?.mimeType ?? (0, _0_deps_js_1.contentType)(name.split(".").slice(-1)[0]) ?? FALLBACK_MIME_TYPE;
|
|
538
|
+
if (expectedMimeTypes && !expectedMimeTypes.includes(mimeType)) {
|
|
539
|
+
(0, _0_deps_js_1.unreachable)();
|
|
540
|
+
}
|
|
541
|
+
if (name.endsWith(".tgs") && fileType == _3_types_js_2.FileType.Document) {
|
|
542
|
+
name += "-";
|
|
543
|
+
}
|
|
544
|
+
return name;
|
|
545
|
+
});
|
|
546
|
+
if (_2_tl_js_1.Api.is("inputFileStoryDocument", file)) {
|
|
547
|
+
(0, _0_deps_js_1.unreachable)();
|
|
548
|
+
}
|
|
549
|
+
let thumb = undefined;
|
|
550
|
+
if (params?.thumbnail) {
|
|
551
|
+
thumb = await this.#c.fileManager.upload(params.thumbnail, { chunkSize: params?.chunkSize, signal: params?.signal });
|
|
552
|
+
}
|
|
553
|
+
media = { _: "inputMediaUploadedDocument", file, thumb, spoiler, attributes: [{ _: "documentAttributeFilename", file_name: file.name }, ...otherAttribs], mime_type: mimeType, force_file: fileType == _3_types_js_2.FileType.Document ? true : undefined, ttl_seconds };
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
const message = await this.#sendMedia(chatId, media, params);
|
|
557
|
+
return message;
|
|
558
|
+
}
|
|
491
559
|
async sendDocument(chatId, document, params) {
|
|
492
|
-
|
|
493
|
-
const message = await
|
|
560
|
+
this.#checkParams(params);
|
|
561
|
+
const message = await this.#sendDocumentInner(chatId, document, params, _3_types_js_2.FileType.Document, []);
|
|
494
562
|
return (0, _3_types_js_2.assertMessageType)(message, "document");
|
|
495
563
|
}
|
|
496
564
|
async sendSticker(chatId, sticker, params) {
|
|
497
|
-
|
|
498
|
-
const message = await
|
|
565
|
+
this.#checkParams(params);
|
|
566
|
+
const message = await this.#sendDocumentInner(chatId, sticker, params, _3_types_js_2.FileType.Sticker, [{ _: "documentAttributeSticker", alt: params?.emoji || "", stickerset: { _: "inputStickerSetEmpty" } }], undefined, STICKER_MIME_TYPES);
|
|
499
567
|
return (0, _3_types_js_2.assertMessageType)(message, "sticker");
|
|
500
568
|
}
|
|
501
569
|
async sendPhoto(chatId, photo, params) {
|
|
502
|
-
|
|
570
|
+
this.#checkParams(params);
|
|
503
571
|
let media = null;
|
|
504
572
|
const spoiler = params?.hasSpoiler ? true : undefined;
|
|
505
573
|
const ttl_seconds = params && "selfDestruct" in params && params.selfDestruct !== undefined ? (0, _3_types_js_1.selfDestructOptionToInt)(params.selfDestruct) : undefined;
|
|
@@ -514,13 +582,48 @@ class MessageManager {
|
|
|
514
582
|
media = { _: "inputMediaPhotoExternal", url: photo, spoiler, ttl_seconds: (params && "selfDestruct" in params && params.selfDestruct !== undefined) ? (0, _3_types_js_1.selfDestructOptionToInt)(params.selfDestruct) : undefined };
|
|
515
583
|
}
|
|
516
584
|
else {
|
|
517
|
-
const file = await
|
|
585
|
+
const file = await this.#c.fileManager.upload(photo, params, null, false);
|
|
518
586
|
media = { _: "inputMediaUploadedPhoto", file, spoiler, ttl_seconds: (params && "selfDestruct" in params && params.selfDestruct !== undefined) ? (0, _3_types_js_1.selfDestructOptionToInt)(params.selfDestruct) : undefined };
|
|
519
587
|
}
|
|
520
588
|
}
|
|
521
|
-
const message = await
|
|
589
|
+
const message = await this.#sendMedia(chatId, media, params);
|
|
522
590
|
return (0, _3_types_js_2.assertMessageType)(message, "photo");
|
|
523
591
|
}
|
|
592
|
+
async #sendMedia(chatId, media, params) {
|
|
593
|
+
if (params?.starCount !== undefined) {
|
|
594
|
+
if (params.starCount <= 0) {
|
|
595
|
+
throw new _0_errors_js_1.InputError("starCount cannot be zero or negative");
|
|
596
|
+
}
|
|
597
|
+
media = { _: "inputMediaPaidMedia", stars_amount: BigInt(params.starCount), extended_media: [media] };
|
|
598
|
+
}
|
|
599
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
600
|
+
const randomId = (0, _1_utilities_js_1.getRandomId)();
|
|
601
|
+
const silent = params?.disableNotification ? true : undefined;
|
|
602
|
+
const noforwards = params?.protectContent ? true : undefined;
|
|
603
|
+
const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
|
|
604
|
+
const replyMarkup = await this.#constructReplyMarkup(params);
|
|
605
|
+
const caption_ = params?.caption;
|
|
606
|
+
const parseResult = caption_ !== undefined ? await this.parseText(caption_, { parseMode: params?.parseMode, entities: params?.captionEntities }) : undefined;
|
|
607
|
+
const caption = parseResult === undefined ? undefined : parseResult[0];
|
|
608
|
+
const captionEntities = parseResult === undefined ? undefined : parseResult[1];
|
|
609
|
+
const result = await this.#c.invoke({
|
|
610
|
+
_: "messages.sendMedia",
|
|
611
|
+
peer,
|
|
612
|
+
random_id: randomId,
|
|
613
|
+
silent,
|
|
614
|
+
noforwards,
|
|
615
|
+
reply_markup: replyMarkup,
|
|
616
|
+
reply_to: await this.#constructReplyTo(params),
|
|
617
|
+
send_as: sendAs,
|
|
618
|
+
media,
|
|
619
|
+
message: caption ?? "",
|
|
620
|
+
entities: captionEntities,
|
|
621
|
+
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
622
|
+
schedule_date: params?.sendAt,
|
|
623
|
+
allow_paid_floodskip: params?.paidBroadcast ? true : undefined,
|
|
624
|
+
}, { businessConnectionId: params?.businessConnectionId });
|
|
625
|
+
return (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
|
|
626
|
+
}
|
|
524
627
|
resolveFileId(maybeFileId, expectedFileType) {
|
|
525
628
|
expectedFileType = Array.isArray(expectedFileType) ? expectedFileType : [expectedFileType];
|
|
526
629
|
let fileId = null;
|
|
@@ -528,7 +631,7 @@ class MessageManager {
|
|
|
528
631
|
fileId = (0, _3_types_js_1.deserializeFileId)(maybeFileId);
|
|
529
632
|
}
|
|
530
633
|
catch (err) {
|
|
531
|
-
|
|
634
|
+
this.#LresolveFileId.warning(err);
|
|
532
635
|
}
|
|
533
636
|
if (fileId != null) {
|
|
534
637
|
if (!expectedFileType.includes(fileId.type)) {
|
|
@@ -543,7 +646,7 @@ class MessageManager {
|
|
|
543
646
|
return null;
|
|
544
647
|
}
|
|
545
648
|
async sendPoll(chatId, question, options, params) {
|
|
546
|
-
|
|
649
|
+
this.#checkParams(params);
|
|
547
650
|
question = question?.trim();
|
|
548
651
|
if (!question) {
|
|
549
652
|
throw new Error("Question must not be empty.");
|
|
@@ -551,12 +654,12 @@ class MessageManager {
|
|
|
551
654
|
if (!Array.isArray(options) || options.length < 2) {
|
|
552
655
|
throw new Error("There must be at least two options.");
|
|
553
656
|
}
|
|
554
|
-
const peer = await
|
|
657
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
555
658
|
const randomId = (0, _1_utilities_js_1.getRandomId)();
|
|
556
659
|
const silent = params?.disableNotification ? true : undefined;
|
|
557
660
|
const noforwards = params?.protectContent ? true : undefined;
|
|
558
|
-
const sendAs = params?.sendAs ? await
|
|
559
|
-
const replyMarkup = await
|
|
661
|
+
const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
|
|
662
|
+
const replyMarkup = await this.#constructReplyMarkup(params);
|
|
560
663
|
const explanation = params?.explanation;
|
|
561
664
|
const parseResult = explanation !== undefined ? await this.parseText(explanation, { parseMode: params?.explanationParseMode, entities: params?.explanationEntities }) : undefined;
|
|
562
665
|
const solution = parseResult === undefined ? undefined : parseResult[0];
|
|
@@ -570,14 +673,14 @@ class MessageManager {
|
|
|
570
673
|
const questionParseResult = await this.parseText(question, { parseMode: params?.questionParseMode, entities: params?.questionEntities });
|
|
571
674
|
const poll = { _: "poll", id: (0, _1_utilities_js_1.getRandomId)(), answers, question: { _: "textWithEntities", text: questionParseResult[0], entities: questionParseResult[1] ?? [] }, closed: params?.isClosed ? true : undefined, close_date: params?.closeDate, close_period: params?.openPeriod ? params.openPeriod : undefined, multiple_choice: params?.allowMultipleAnswers ? true : undefined, public_voters: params?.isAnonymous === false ? true : undefined, quiz: params?.type == "quiz" ? true : undefined };
|
|
572
675
|
const media = { _: "inputMediaPoll", poll, correct_answers: params?.correctOptionIndex !== undefined ? [(0, _1_utilities_js_1.encodeText)(String(params.correctOptionIndex))] : undefined, solution, solution_entities: solutionEntities };
|
|
573
|
-
const result = await
|
|
676
|
+
const result = await this.#c.invoke({
|
|
574
677
|
_: "messages.sendMedia",
|
|
575
678
|
peer,
|
|
576
679
|
random_id: randomId,
|
|
577
680
|
silent,
|
|
578
681
|
noforwards,
|
|
579
682
|
reply_markup: replyMarkup,
|
|
580
|
-
reply_to: await
|
|
683
|
+
reply_to: await this.#constructReplyTo(params),
|
|
581
684
|
send_as: sendAs,
|
|
582
685
|
media,
|
|
583
686
|
message: "",
|
|
@@ -589,26 +692,26 @@ class MessageManager {
|
|
|
589
692
|
return (0, _3_types_js_2.assertMessageType)(message, "poll");
|
|
590
693
|
}
|
|
591
694
|
async editMessageReplyMarkup(chatId, messageId, params) {
|
|
592
|
-
|
|
593
|
-
const result = await
|
|
695
|
+
this.#checkParams(params);
|
|
696
|
+
const result = await this.#c.invoke({
|
|
594
697
|
_: "messages.editMessage",
|
|
595
698
|
id: (0, _0_utilities_js_1.checkMessageId)(messageId),
|
|
596
|
-
peer: await
|
|
597
|
-
reply_markup: await
|
|
699
|
+
peer: await this.#c.getInputPeer(chatId),
|
|
700
|
+
reply_markup: await this.#constructReplyMarkup(params),
|
|
598
701
|
}, { businessConnectionId: params?.businessConnectionId });
|
|
599
702
|
const message_ = (await this.updatesToMessages(chatId, result))[0];
|
|
600
703
|
return message_;
|
|
601
704
|
}
|
|
602
705
|
async editInlineMessageReplyMarkup(inlineMessageId, params) {
|
|
603
706
|
const id = await (0, _3_types_js_2.deserializeInlineMessageId)(inlineMessageId);
|
|
604
|
-
await
|
|
707
|
+
await this.#c.invoke({
|
|
605
708
|
_: "messages.editInlineBotMessage",
|
|
606
709
|
id,
|
|
607
|
-
reply_markup: await
|
|
710
|
+
reply_markup: await this.#constructReplyMarkup(params),
|
|
608
711
|
}, { dc: (0, _3_transport_js_1.getDc)(id.dc_id) });
|
|
609
712
|
}
|
|
610
713
|
async editMessageText(chatId, messageId, text, params) {
|
|
611
|
-
|
|
714
|
+
this.#checkParams(params);
|
|
612
715
|
{
|
|
613
716
|
const message = await this.getMessage(chatId, messageId);
|
|
614
717
|
if (!message) {
|
|
@@ -631,27 +734,28 @@ class MessageManager {
|
|
|
631
734
|
if (!noWebpage && params?.linkPreview?.url) {
|
|
632
735
|
media = { _: "inputMediaWebPage", url: params.linkPreview.url, force_large_media: params.linkPreview.largeMedia ? true : undefined, force_small_media: params.linkPreview.smallMedia ? true : undefined, optional: message.length ? undefined : true };
|
|
633
736
|
}
|
|
634
|
-
const result = await
|
|
737
|
+
const result = await this.#c.invoke({
|
|
635
738
|
_: "messages.editMessage",
|
|
636
739
|
id: (0, _0_utilities_js_1.checkMessageId)(messageId),
|
|
637
|
-
peer: await
|
|
740
|
+
peer: await this.#c.getInputPeer(chatId),
|
|
638
741
|
entities,
|
|
639
742
|
message,
|
|
640
743
|
media,
|
|
641
744
|
no_webpage: noWebpage,
|
|
642
745
|
invert_media: invertMedia,
|
|
643
|
-
reply_markup: await
|
|
746
|
+
reply_markup: await this.#constructReplyMarkup(params),
|
|
644
747
|
}, { businessConnectionId: params?.businessConnectionId });
|
|
645
748
|
const message_ = (await this.updatesToMessages(chatId, result))[0];
|
|
646
749
|
return (0, _3_types_js_2.assertMessageType)(message_, "text");
|
|
647
750
|
}
|
|
751
|
+
static #CAPTIONABLE_MESSAGE_TYPES = ["photo", "document", "video", "animation", "voice", "audio", "video"];
|
|
648
752
|
async editMessageCaption(chatId, messageId, params) {
|
|
649
753
|
let canHaveCaption = false;
|
|
650
754
|
const message_ = await this.getMessage(chatId, messageId);
|
|
651
755
|
if (!message_) {
|
|
652
756
|
throw new _0_errors_js_1.InputError("Message not found.");
|
|
653
757
|
}
|
|
654
|
-
for (const type of
|
|
758
|
+
for (const type of MessageManager.#CAPTIONABLE_MESSAGE_TYPES) {
|
|
655
759
|
if ((0, _3_types_js_1.isMessageType)(message_, type)) {
|
|
656
760
|
canHaveCaption = true;
|
|
657
761
|
}
|
|
@@ -660,24 +764,133 @@ class MessageManager {
|
|
|
660
764
|
throw new _0_errors_js_1.InputError("The referenced message cannot have a caption.");
|
|
661
765
|
}
|
|
662
766
|
const [message, entities] = await this.parseText(params?.caption ?? "", params);
|
|
663
|
-
const result = await
|
|
767
|
+
const result = await this.#c.invoke({
|
|
664
768
|
_: "messages.editMessage",
|
|
665
769
|
id: (0, _0_utilities_js_1.checkMessageId)(messageId),
|
|
666
|
-
peer: await
|
|
770
|
+
peer: await this.#c.getInputPeer(chatId),
|
|
667
771
|
entities: message ? entities : [],
|
|
668
772
|
message,
|
|
669
|
-
reply_markup: await
|
|
773
|
+
reply_markup: await this.#constructReplyMarkup(params),
|
|
670
774
|
}, { businessConnectionId: params?.businessConnectionId });
|
|
671
775
|
return (await this.updatesToMessages(chatId, result))[0];
|
|
672
776
|
}
|
|
777
|
+
async #editInlineMessageTextInner(inlineMessageId, text, params, allowEmpty = true) {
|
|
778
|
+
this.#checkParams(params);
|
|
779
|
+
const [message, entities] = await this.parseText(text, params);
|
|
780
|
+
if (!allowEmpty && !message) {
|
|
781
|
+
throw new _0_errors_js_1.InputError("Message text cannot be empty.");
|
|
782
|
+
}
|
|
783
|
+
const id = await (0, _3_types_js_2.deserializeInlineMessageId)(inlineMessageId);
|
|
784
|
+
if (params?.linkPreview && params.linkPreview.type != "input") {
|
|
785
|
+
throw new _0_errors_js_1.InputError("Expected link preview of type input.");
|
|
786
|
+
}
|
|
787
|
+
const noWebpage = params?.linkPreview && params.linkPreview.type == "input" && params.linkPreview.disable ? true : undefined;
|
|
788
|
+
const invertMedia = params?.linkPreview?.aboveText ? true : undefined;
|
|
789
|
+
let media = undefined;
|
|
790
|
+
if (!noWebpage && params?.linkPreview?.url) {
|
|
791
|
+
media = { _: "inputMediaWebPage", url: params.linkPreview.url, force_large_media: params.linkPreview.largeMedia ? true : undefined, force_small_media: params.linkPreview.smallMedia ? true : undefined, optional: message.length ? undefined : true };
|
|
792
|
+
}
|
|
793
|
+
await this.#c.invoke({
|
|
794
|
+
_: "messages.editInlineBotMessage",
|
|
795
|
+
id,
|
|
796
|
+
entities,
|
|
797
|
+
message,
|
|
798
|
+
media,
|
|
799
|
+
no_webpage: noWebpage,
|
|
800
|
+
invert_media: invertMedia,
|
|
801
|
+
reply_markup: await this.#constructReplyMarkup(params),
|
|
802
|
+
}, { dc: (0, _3_transport_js_1.getDc)(id.dc_id) });
|
|
803
|
+
}
|
|
673
804
|
async editInlineMessageText(inlineMessageId, text, params) {
|
|
674
|
-
await
|
|
805
|
+
await this.#editInlineMessageTextInner(inlineMessageId, text, params, false);
|
|
675
806
|
}
|
|
676
807
|
async editInlineMessageCaption(inlineMessageId, params) {
|
|
677
|
-
await
|
|
808
|
+
await this.#editInlineMessageTextInner(inlineMessageId, params?.caption ?? "", params);
|
|
809
|
+
}
|
|
810
|
+
async #resolveInputMediaInner(document, media, fileType, otherAttribs) {
|
|
811
|
+
let media_ = null;
|
|
812
|
+
const spoiler = "hasSpoiler" in media && media.hasSpoiler ? true : undefined;
|
|
813
|
+
if (typeof document === "string") {
|
|
814
|
+
const fileId = this.resolveFileId(document, fileType);
|
|
815
|
+
if (fileId != null) {
|
|
816
|
+
media_ = { _: "inputMediaDocument", id: { ...fileId, _: "inputDocument" }, spoiler, query: otherAttribs.find((v) => _2_tl_js_1.Api.is("documentAttributeSticker", v))?.alt || undefined };
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
if (media_ == null) {
|
|
820
|
+
if (typeof document === "string" && (0, _0_utilities_js_1.isHttpUrl)(document)) {
|
|
821
|
+
media_ = { _: "inputMediaDocumentExternal", url: document, spoiler };
|
|
822
|
+
}
|
|
823
|
+
else {
|
|
824
|
+
let mimeType;
|
|
825
|
+
const file = await this.#c.fileManager.upload(document, media, (name) => {
|
|
826
|
+
mimeType = media?.mimeType ?? (0, _0_deps_js_1.contentType)(name.split(".").slice(-1)[0]) ?? FALLBACK_MIME_TYPE;
|
|
827
|
+
if (name.endsWith(".tgs") && fileType == _3_types_js_2.FileType.Document) {
|
|
828
|
+
name += "-";
|
|
829
|
+
}
|
|
830
|
+
return name;
|
|
831
|
+
});
|
|
832
|
+
if (_2_tl_js_1.Api.is("inputFileStoryDocument", file)) {
|
|
833
|
+
(0, _0_deps_js_1.unreachable)();
|
|
834
|
+
}
|
|
835
|
+
let thumb = undefined;
|
|
836
|
+
if ("thumbnail" in media && media.thumbnail) {
|
|
837
|
+
thumb = await this.#c.fileManager.upload(media.thumbnail, { chunkSize: media?.chunkSize, signal: media?.signal });
|
|
838
|
+
}
|
|
839
|
+
media_ = { _: "inputMediaUploadedDocument", file, thumb, spoiler, attributes: [{ _: "documentAttributeFilename", file_name: file.name }, ...otherAttribs], mime_type: mimeType, force_file: fileType == _3_types_js_2.FileType.Document ? true : undefined };
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
return media_;
|
|
843
|
+
}
|
|
844
|
+
async #resolveInputMedia(media) {
|
|
845
|
+
if ("animation" in media) {
|
|
846
|
+
return await this.#resolveInputMediaInner(media.animation, media, _3_types_js_2.FileType.Animation, [
|
|
847
|
+
{ _: "documentAttributeAnimated" },
|
|
848
|
+
{ _: "documentAttributeVideo", supports_streaming: true, w: media?.width ?? 0, h: media?.height ?? 0, duration: media?.duration ?? 0 },
|
|
849
|
+
]);
|
|
850
|
+
}
|
|
851
|
+
else if ("audio" in media) {
|
|
852
|
+
return await this.#resolveInputMediaInner(media.audio, media, _3_types_js_2.FileType.Audio, [
|
|
853
|
+
{ _: "documentAttributeAudio", duration: media?.duration ?? 0, performer: media?.performer, title: media?.title },
|
|
854
|
+
]);
|
|
855
|
+
}
|
|
856
|
+
else if ("document" in media) {
|
|
857
|
+
return await this.#resolveInputMediaInner(media.document, media, _3_types_js_2.FileType.Document, []);
|
|
858
|
+
}
|
|
859
|
+
else if ("photo" in media) {
|
|
860
|
+
let media_ = null;
|
|
861
|
+
const spoiler = media.hasSpoiler ? true : undefined;
|
|
862
|
+
const ttl_seconds = "selfDestruct" in media && media.selfDestruct !== undefined ? (0, _3_types_js_1.selfDestructOptionToInt)(media.selfDestruct) : undefined;
|
|
863
|
+
if (typeof media.photo === "string") {
|
|
864
|
+
const fileId = this.resolveFileId(media.photo, [_3_types_js_2.FileType.Photo, _3_types_js_2.FileType.ProfilePhoto]);
|
|
865
|
+
if (fileId != null) {
|
|
866
|
+
media_ = { _: "inputMediaPhoto", id: { ...fileId, _: "inputPhoto" }, spoiler, ttl_seconds };
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
if (media_ == null) {
|
|
870
|
+
if (typeof media.photo === "string" && (0, _0_utilities_js_1.isHttpUrl)(media.photo)) {
|
|
871
|
+
media_ = { _: "inputMediaPhotoExternal", url: media.photo, spoiler };
|
|
872
|
+
}
|
|
873
|
+
else {
|
|
874
|
+
const file = await this.#c.fileManager.upload(media.photo, media, null, false);
|
|
875
|
+
media_ = { _: "inputMediaUploadedPhoto", file, spoiler, ttl_seconds };
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
return media_;
|
|
879
|
+
}
|
|
880
|
+
else if ("video" in media) {
|
|
881
|
+
const ttl_seconds = "selfDestruct" in media && media.selfDestruct !== undefined ? (0, _3_types_js_1.selfDestructOptionToInt)(media.selfDestruct) : undefined;
|
|
882
|
+
const media_ = await this.#resolveInputMediaInner(media.video, media, _3_types_js_2.FileType.Video, [
|
|
883
|
+
{ _: "documentAttributeVideo", supports_streaming: media?.supportsStreaming ? true : undefined, w: media?.width ?? 0, h: media?.height ?? 0, duration: media?.duration ?? 0 },
|
|
884
|
+
]);
|
|
885
|
+
media_.ttl_seconds = ttl_seconds;
|
|
886
|
+
return media_;
|
|
887
|
+
}
|
|
888
|
+
else {
|
|
889
|
+
(0, _0_deps_js_1.unreachable)();
|
|
890
|
+
}
|
|
678
891
|
}
|
|
679
892
|
async editMessageMedia(chatId, messageId, media, params) {
|
|
680
|
-
|
|
893
|
+
this.#checkParams(params);
|
|
681
894
|
const message = await this.getMessage(chatId, messageId);
|
|
682
895
|
if (!message) {
|
|
683
896
|
throw new _0_errors_js_1.InputError("Message not found.");
|
|
@@ -686,12 +899,12 @@ class MessageManager {
|
|
|
686
899
|
throw new _0_errors_js_1.InputError("Unexpected message type.");
|
|
687
900
|
}
|
|
688
901
|
const [text, entities] = media.caption !== undefined ? await this.parseText(media.caption, { entities: media.captionEntities, parseMode: media.parseMode }) : ["", []];
|
|
689
|
-
const result = await
|
|
902
|
+
const result = await this.#c.invoke({
|
|
690
903
|
_: "messages.editMessage",
|
|
691
|
-
peer: await
|
|
904
|
+
peer: await this.#c.getInputPeer(chatId),
|
|
692
905
|
id: messageId,
|
|
693
|
-
media: await
|
|
694
|
-
reply_markup: await
|
|
906
|
+
media: await this.#resolveInputMedia(media),
|
|
907
|
+
reply_markup: await this.#constructReplyMarkup(params),
|
|
695
908
|
message: text,
|
|
696
909
|
entities,
|
|
697
910
|
}, { businessConnectionId: params?.businessConnectionId });
|
|
@@ -699,66 +912,69 @@ class MessageManager {
|
|
|
699
912
|
return message_;
|
|
700
913
|
}
|
|
701
914
|
async editInlineMessageMedia(inlineMessageId, media, params) {
|
|
702
|
-
|
|
703
|
-
|
|
915
|
+
this.#checkParams(params);
|
|
916
|
+
this.#c.storage.assertBot("editInlineMessageMedia");
|
|
704
917
|
const id = await (0, _3_types_js_2.deserializeInlineMessageId)(inlineMessageId);
|
|
705
|
-
await
|
|
918
|
+
await this.#c.invoke({
|
|
706
919
|
_: "messages.editInlineBotMessage",
|
|
707
920
|
id,
|
|
708
|
-
media: await
|
|
709
|
-
reply_markup: await
|
|
921
|
+
media: await this.#resolveInputMedia(media),
|
|
922
|
+
reply_markup: await this.#constructReplyMarkup(params),
|
|
710
923
|
}, { dc: (0, _3_transport_js_1.getDc)(id.dc_id) });
|
|
711
924
|
}
|
|
712
925
|
async deleteMessages(chatId, messageIds, params) {
|
|
713
926
|
(0, _0_utilities_js_1.checkArray)(messageIds, _0_utilities_js_1.checkMessageId);
|
|
714
|
-
const peer = await
|
|
927
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
715
928
|
if ((0, _0_utilities_js_1.canBeInputChannel)(peer)) {
|
|
716
|
-
await
|
|
929
|
+
await this.#c.invoke({ _: "channels.deleteMessages", channel: (0, _0_utilities_js_1.toInputChannel)(peer), id: messageIds });
|
|
717
930
|
}
|
|
718
931
|
else {
|
|
719
|
-
await
|
|
932
|
+
await this.#c.invoke({ _: "messages.deleteMessages", id: messageIds, revoke: params?.onlyForMe ? undefined : true });
|
|
720
933
|
}
|
|
721
934
|
}
|
|
722
935
|
async deleteScheduledMessages(chatId, messageIds) {
|
|
723
|
-
|
|
936
|
+
this.#c.storage.assertUser("sendScheduledMessage");
|
|
724
937
|
(0, _0_utilities_js_1.checkArray)(messageIds, _0_utilities_js_1.checkMessageId);
|
|
725
|
-
const peer = await
|
|
726
|
-
await
|
|
938
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
939
|
+
await this.#c.invoke({ _: "messages.deleteScheduledMessages", peer, id: messageIds });
|
|
727
940
|
}
|
|
728
941
|
async deleteScheduledMessage(chatId, messageId) {
|
|
729
|
-
|
|
942
|
+
this.#c.storage.assertUser("deleteScheduledMessage");
|
|
730
943
|
return await this.deleteScheduledMessages(chatId, [messageId]);
|
|
731
944
|
}
|
|
732
945
|
async sendScheduledMessages(chatId, messageIds) {
|
|
733
|
-
|
|
946
|
+
this.#c.storage.assertUser("sendScheduledMessages");
|
|
734
947
|
(0, _0_utilities_js_1.checkArray)(messageIds, _0_utilities_js_1.checkMessageId);
|
|
735
|
-
const peer = await
|
|
736
|
-
const result = await
|
|
948
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
949
|
+
const result = await this.#c.invoke({ _: "messages.sendScheduledMessages", peer, id: messageIds });
|
|
737
950
|
return await this.updatesToMessages(chatId, result);
|
|
738
951
|
}
|
|
739
952
|
async sendScheduledMessage(chatId, messageId) {
|
|
740
|
-
|
|
953
|
+
this.#c.storage.assertUser("sendScheduledMessage");
|
|
741
954
|
return (await this.sendScheduledMessages(chatId, [messageId]))[0];
|
|
742
955
|
}
|
|
743
956
|
async deleteChatMemberMessages(chatId, memberId) {
|
|
744
|
-
|
|
745
|
-
const channel = await
|
|
746
|
-
const participant = await
|
|
747
|
-
await
|
|
957
|
+
this.#c.storage.assertUser("deleteChatMemberMessages");
|
|
958
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
959
|
+
const participant = await this.#c.getInputPeer(memberId);
|
|
960
|
+
await this.#c.invoke({ _: "channels.deleteParticipantHistory", channel, participant });
|
|
748
961
|
}
|
|
749
962
|
async pinMessage(chatId, messageId, params) {
|
|
750
|
-
|
|
751
|
-
await
|
|
963
|
+
this.#checkParams(params);
|
|
964
|
+
await this.#c.invoke({ _: "messages.updatePinnedMessage", peer: await this.#c.getInputPeer(chatId), id: (0, _0_utilities_js_1.checkMessageId)(messageId), silent: params?.disableNotification ? true : undefined, pm_oneside: params?.bothSides ? undefined : true });
|
|
752
965
|
}
|
|
753
966
|
async unpinMessage(chatId, messageId, params) {
|
|
754
|
-
|
|
755
|
-
await
|
|
967
|
+
this.#checkParams(params);
|
|
968
|
+
await this.#c.invoke({ _: "messages.updatePinnedMessage", peer: await this.#c.getInputPeer(chatId), id: (0, _0_utilities_js_1.checkMessageId)(messageId), unpin: true }, { businessConnectionId: params?.businessConnectionId });
|
|
756
969
|
}
|
|
757
970
|
async unpinMessages(chatId) {
|
|
758
|
-
await
|
|
971
|
+
await this.#c.invoke({ _: "messages.unpinAllMessages", peer: await this.#c.getInputPeer(chatId) });
|
|
972
|
+
}
|
|
973
|
+
async #sendReaction(chatId, messageId, reactions, params) {
|
|
974
|
+
await this.#c.invoke({ _: "messages.sendReaction", peer: await this.#c.getInputPeer(chatId), msg_id: (0, _0_utilities_js_1.checkMessageId)(messageId), reaction: reactions.map((v) => (0, _3_types_js_2.reactionToTlObject)(v)), big: params?.big ? true : undefined, add_to_recent: params?.addToRecents ? true : undefined });
|
|
759
975
|
}
|
|
760
976
|
async setReactions(chatId, messageId, reactions, params) {
|
|
761
|
-
await
|
|
977
|
+
await this.#sendReaction(chatId, messageId, reactions, params);
|
|
762
978
|
}
|
|
763
979
|
async addReaction(chatId, messageId, reaction, params) {
|
|
764
980
|
const message = await this.getMessage(chatId, messageId);
|
|
@@ -795,7 +1011,7 @@ class MessageManager {
|
|
|
795
1011
|
if (_2_tl_js_1.Api.is("updateNewMessage", update) || _2_tl_js_1.Api.is("updateNewChannelMessage", update) || _2_tl_js_1.Api.is("updateEditMessage", update) || _2_tl_js_1.Api.is("updateEditChannelMessage", update)) {
|
|
796
1012
|
if (_2_tl_js_1.Api.is("message", update.message) || _2_tl_js_1.Api.is("messageService", update.message)) {
|
|
797
1013
|
const chatId = _2_tl_js_1.Api.peerToChatId(update.message.peer_id);
|
|
798
|
-
await
|
|
1014
|
+
await this.#c.messageStorage.setMessage(chatId, update.message.id, update.message);
|
|
799
1015
|
}
|
|
800
1016
|
}
|
|
801
1017
|
if (_2_tl_js_1.Api.isOneOf([
|
|
@@ -811,13 +1027,13 @@ class MessageManager {
|
|
|
811
1027
|
const isOutgoing = update.message.out;
|
|
812
1028
|
let shouldIgnore = false;
|
|
813
1029
|
if (isOutgoing) {
|
|
814
|
-
if (
|
|
815
|
-
|
|
1030
|
+
if (this.#c.outgoingMessages == null) {
|
|
1031
|
+
this.#c.outgoingMessages = this.#c.storage.accountType == "user" ? "all" : "business";
|
|
816
1032
|
}
|
|
817
|
-
if (
|
|
1033
|
+
if (this.#c.outgoingMessages == "none") {
|
|
818
1034
|
shouldIgnore = true;
|
|
819
1035
|
}
|
|
820
|
-
else if (
|
|
1036
|
+
else if (this.#c.outgoingMessages == "business") {
|
|
821
1037
|
if (!_2_tl_js_1.Api.is("updateBotNewBusinessMessage", update) && !_2_tl_js_1.Api.is("updateBotEditBusinessMessage", update)) {
|
|
822
1038
|
shouldIgnore = true;
|
|
823
1039
|
}
|
|
@@ -842,7 +1058,7 @@ class MessageManager {
|
|
|
842
1058
|
if (_2_tl_js_1.Api.is("updateDeleteMessages", update)) {
|
|
843
1059
|
const deletedMessages = new Array();
|
|
844
1060
|
for (const messageId of update.messages) {
|
|
845
|
-
const chatId = await
|
|
1061
|
+
const chatId = await this.#c.messageStorage.getMessageChat(messageId);
|
|
846
1062
|
if (chatId) {
|
|
847
1063
|
deletedMessages.push({ chatId, messageId });
|
|
848
1064
|
}
|
|
@@ -855,7 +1071,7 @@ class MessageManager {
|
|
|
855
1071
|
const chatId = _2_tl_js_1.Api.getChannelChatId(update.channel_id);
|
|
856
1072
|
const deletedMessages = new Array();
|
|
857
1073
|
for (const messageId of update.messages) {
|
|
858
|
-
const message = await
|
|
1074
|
+
const message = await this.#c.messageStorage.getMessage(chatId, messageId);
|
|
859
1075
|
if (message != null) {
|
|
860
1076
|
deletedMessages.push({ chatId, messageId });
|
|
861
1077
|
}
|
|
@@ -874,13 +1090,13 @@ class MessageManager {
|
|
|
874
1090
|
}
|
|
875
1091
|
if (_2_tl_js_1.Api.is("updateTranscribedAudio", update)) {
|
|
876
1092
|
const voiceTranscription = (0, _3_types_js_1.constructVoiceTranscription)(update);
|
|
877
|
-
await
|
|
1093
|
+
await this.#c.messageStorage.setVoiceTranscription(voiceTranscription);
|
|
878
1094
|
return { voiceTranscription };
|
|
879
1095
|
}
|
|
880
1096
|
return null;
|
|
881
1097
|
}
|
|
882
1098
|
async sendChatAction(chatId, action, params) {
|
|
883
|
-
|
|
1099
|
+
this.#checkParams(params);
|
|
884
1100
|
let action_;
|
|
885
1101
|
switch (action) {
|
|
886
1102
|
case "type":
|
|
@@ -919,11 +1135,11 @@ class MessageManager {
|
|
|
919
1135
|
default:
|
|
920
1136
|
throw new _0_errors_js_1.InputError(`Invalid chat action: ${action}`);
|
|
921
1137
|
}
|
|
922
|
-
await
|
|
1138
|
+
await this.#c.invoke({ _: "messages.setTyping", peer: await this.#c.getInputPeer(chatId), action: action_, top_msg_id: params?.messageThreadId }, { businessConnectionId: params?.businessConnectionId });
|
|
923
1139
|
}
|
|
924
1140
|
async searchMessages(chatId, query, params) {
|
|
925
|
-
|
|
926
|
-
const result = await
|
|
1141
|
+
this.#c.storage.assertUser("searchMessages");
|
|
1142
|
+
const result = await this.#c.invoke({ _: "messages.search", peer: await this.#c.getInputPeer(chatId), q: query, add_offset: 0, filter: (0, _0_message_search_filter_js_1.messageSearchFilterToTlObject)(params?.filter ?? "empty"), hash: 0n, limit: (0, _0_utilities_js_1.getLimit)(params?.limit), max_date: 0, max_id: 0, min_date: 0, min_id: 0, offset_id: params?.after ? params.after : 0, from_id: params?.from ? await this.#c.getInputPeer(params.from) : undefined });
|
|
927
1143
|
if (!("messages" in result)) {
|
|
928
1144
|
(0, _0_deps_js_1.unreachable)();
|
|
929
1145
|
}
|
|
@@ -935,25 +1151,25 @@ class MessageManager {
|
|
|
935
1151
|
return messages;
|
|
936
1152
|
}
|
|
937
1153
|
async blockUser(userId) {
|
|
938
|
-
|
|
939
|
-
const id = await
|
|
940
|
-
await
|
|
1154
|
+
this.#c.storage.assertUser("blockUser");
|
|
1155
|
+
const id = await this.#c.getInputPeer(userId);
|
|
1156
|
+
await this.#c.invoke({ _: "contacts.block", id });
|
|
941
1157
|
}
|
|
942
1158
|
async unblockUser(userId) {
|
|
943
|
-
|
|
944
|
-
const id = await
|
|
945
|
-
await
|
|
1159
|
+
this.#c.storage.assertUser("unblockUser");
|
|
1160
|
+
const id = await this.#c.getInputPeer(userId);
|
|
1161
|
+
await this.#c.invoke({ _: "contacts.unblock", id });
|
|
946
1162
|
}
|
|
947
1163
|
async setChatStickerSet(chatId, setName) {
|
|
948
|
-
const channel = await
|
|
949
|
-
await
|
|
1164
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
1165
|
+
await this.#c.invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetShortName", short_name: setName } });
|
|
950
1166
|
}
|
|
951
1167
|
async deleteChatStickerSet(chatId) {
|
|
952
|
-
const channel = await
|
|
953
|
-
await
|
|
1168
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
1169
|
+
await this.#c.invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetEmpty" } });
|
|
954
1170
|
}
|
|
955
1171
|
async stopPoll(chatId, messageId, params) {
|
|
956
|
-
|
|
1172
|
+
this.#checkParams(params);
|
|
957
1173
|
const message = await this.getMessage(chatId, messageId);
|
|
958
1174
|
if (!message) {
|
|
959
1175
|
throw new _0_errors_js_1.InputError("Message not found.");
|
|
@@ -964,26 +1180,26 @@ class MessageManager {
|
|
|
964
1180
|
if (message.poll.isClosed) {
|
|
965
1181
|
throw new _0_errors_js_1.InputError("Poll is already stopped.");
|
|
966
1182
|
}
|
|
967
|
-
const result = await
|
|
1183
|
+
const result = await this.#c.invoke({
|
|
968
1184
|
_: "messages.editMessage",
|
|
969
|
-
peer: await
|
|
1185
|
+
peer: await this.#c.getInputPeer(chatId),
|
|
970
1186
|
id: messageId,
|
|
971
1187
|
media: ({ _: "inputMediaPoll", poll: ({ _: "poll", id: BigInt(message.poll.id), closed: true, question: { _: "textWithEntities", text: "", entities: [] }, answers: [] }) }),
|
|
972
|
-
reply_markup: await
|
|
1188
|
+
reply_markup: await this.#constructReplyMarkup(params),
|
|
973
1189
|
}, { businessConnectionId: params?.businessConnectionId });
|
|
974
1190
|
const message_ = (await this.updatesToMessages(chatId, result))[0];
|
|
975
1191
|
return (0, _3_types_js_2.assertMessageType)(message_, "poll").poll;
|
|
976
1192
|
}
|
|
977
1193
|
async editMessageLiveLocation(chatId, messageId, latitude, longitude, params) {
|
|
978
|
-
|
|
1194
|
+
this.#checkParams(params);
|
|
979
1195
|
const message = await this.getMessage(chatId, messageId);
|
|
980
1196
|
if (message && "location" in message && message.location.livePeriod) {
|
|
981
|
-
const result = await
|
|
1197
|
+
const result = await this.#c.invoke({
|
|
982
1198
|
_: "messages.editMessage",
|
|
983
|
-
peer: await
|
|
1199
|
+
peer: await this.#c.getInputPeer(chatId),
|
|
984
1200
|
id: messageId,
|
|
985
1201
|
media: ({ _: "inputMediaGeoLive", geo_point: ({ _: "inputGeoPoint", lat: latitude, long: longitude, accuracy_radius: params?.horizontalAccuracy }), heading: params?.heading, proximity_notification_radius: params?.proximityAlertRadius }),
|
|
986
|
-
reply_markup: await
|
|
1202
|
+
reply_markup: await this.#constructReplyMarkup(params),
|
|
987
1203
|
}, { businessConnectionId: params?.businessConnectionId });
|
|
988
1204
|
const message = (await this.updatesToMessages(chatId, result))[0];
|
|
989
1205
|
return (0, _3_types_js_2.assertMessageType)(message, "location");
|
|
@@ -991,19 +1207,19 @@ class MessageManager {
|
|
|
991
1207
|
(0, _0_deps_js_1.unreachable)();
|
|
992
1208
|
}
|
|
993
1209
|
async editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params) {
|
|
994
|
-
|
|
995
|
-
|
|
1210
|
+
this.#checkParams(params);
|
|
1211
|
+
this.#c.storage.assertBot("editInlineMessageLiveLocation");
|
|
996
1212
|
const id = await (0, _3_types_js_2.deserializeInlineMessageId)(inlineMessageId);
|
|
997
|
-
await
|
|
1213
|
+
await this.#c.invoke({
|
|
998
1214
|
_: "messages.editInlineBotMessage",
|
|
999
1215
|
id,
|
|
1000
1216
|
media: ({ _: "inputMediaGeoLive", geo_point: ({ _: "inputGeoPoint", lat: latitude, long: longitude, accuracy_radius: params?.horizontalAccuracy }), heading: params?.heading, proximity_notification_radius: params?.proximityAlertRadius }),
|
|
1001
|
-
reply_markup: await
|
|
1217
|
+
reply_markup: await this.#constructReplyMarkup(params),
|
|
1002
1218
|
}, { dc: (0, _3_transport_js_1.getDc)(id.dc_id) });
|
|
1003
1219
|
}
|
|
1004
1220
|
async sendInvoice(chatId, title, description, payload, currency, prices, params) {
|
|
1005
|
-
|
|
1006
|
-
|
|
1221
|
+
this.#c.storage.assertBot("sendInvoice");
|
|
1222
|
+
this.#checkParams(params);
|
|
1007
1223
|
if (title.length < 1) {
|
|
1008
1224
|
throw new _0_errors_js_1.InputError("Invoice title cannot be empty.");
|
|
1009
1225
|
}
|
|
@@ -1030,7 +1246,7 @@ class MessageManager {
|
|
|
1030
1246
|
phone_to_provider: params?.sendPhoneNumberToProvider || undefined,
|
|
1031
1247
|
flexible: params?.flexible || undefined,
|
|
1032
1248
|
};
|
|
1033
|
-
const message = await
|
|
1249
|
+
const message = await this.#sendMedia(chatId, {
|
|
1034
1250
|
_: "inputMediaInvoice",
|
|
1035
1251
|
title,
|
|
1036
1252
|
description,
|
|
@@ -1056,7 +1272,7 @@ class MessageManager {
|
|
|
1056
1272
|
return (0, _3_types_js_2.assertMessageType)(message, "invoice");
|
|
1057
1273
|
}
|
|
1058
1274
|
async sendMediaGroup(chatId, media, params) {
|
|
1059
|
-
|
|
1275
|
+
this.#checkParams(params);
|
|
1060
1276
|
{
|
|
1061
1277
|
if (!Array.isArray(media) || !media.length) {
|
|
1062
1278
|
throw new _0_errors_js_1.InputError("Media group must not be empty.");
|
|
@@ -1082,25 +1298,25 @@ class MessageManager {
|
|
|
1082
1298
|
for (const v of media) {
|
|
1083
1299
|
const randomId = (0, _1_utilities_js_1.getRandomId)();
|
|
1084
1300
|
const [message, entities] = v.caption !== undefined ? await this.parseText(v.caption, { entities: v.captionEntities, parseMode: v.parseMode }) : ["", []];
|
|
1085
|
-
multiMedia.push({ _: "inputSingleMedia", message, entities, random_id: randomId, media: await
|
|
1301
|
+
multiMedia.push({ _: "inputSingleMedia", message, entities, random_id: randomId, media: await this.#resolveInputMedia(v) });
|
|
1086
1302
|
}
|
|
1087
|
-
const peer = await
|
|
1303
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
1088
1304
|
for (const [i, media_] of multiMedia.entries()) {
|
|
1089
1305
|
if (_2_tl_js_1.Api.is("inputMediaUploadedPhoto", media_.media)) {
|
|
1090
|
-
const result = _2_tl_js_1.Api.as("messageMediaPhoto", await
|
|
1306
|
+
const result = _2_tl_js_1.Api.as("messageMediaPhoto", await this.#c.invoke({ _: "messages.uploadMedia", media: media_.media, peer }));
|
|
1091
1307
|
const photo = _2_tl_js_1.Api.as("photo", result.photo);
|
|
1092
1308
|
multiMedia[i] = { ...media_, media: { _: "inputMediaPhoto", id: { ...photo, _: "inputPhoto" } } };
|
|
1093
1309
|
}
|
|
1094
1310
|
else if (_2_tl_js_1.Api.is("inputMediaUploadedDocument", media_.media)) {
|
|
1095
|
-
const result = _2_tl_js_1.Api.as("messageMediaDocument", await
|
|
1311
|
+
const result = _2_tl_js_1.Api.as("messageMediaDocument", await this.#c.invoke({ _: "messages.uploadMedia", media: media_.media, peer }));
|
|
1096
1312
|
const document = _2_tl_js_1.Api.as("document", result.document);
|
|
1097
1313
|
multiMedia[i] = { ...media_, media: { _: "inputMediaDocument", id: { ...document, _: "inputDocument" } } };
|
|
1098
1314
|
}
|
|
1099
1315
|
}
|
|
1100
1316
|
const silent = params?.disableNotification ? true : undefined;
|
|
1101
1317
|
const noforwards = params?.protectContent ? true : undefined;
|
|
1102
|
-
const sendAs = params?.sendAs ? await
|
|
1103
|
-
const result = await
|
|
1318
|
+
const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
|
|
1319
|
+
const result = await this.#c.invoke({
|
|
1104
1320
|
_: "messages.sendMultiMedia",
|
|
1105
1321
|
peer,
|
|
1106
1322
|
multi_media: multiMedia,
|
|
@@ -1108,19 +1324,19 @@ class MessageManager {
|
|
|
1108
1324
|
noforwards,
|
|
1109
1325
|
silent,
|
|
1110
1326
|
send_as: sendAs,
|
|
1111
|
-
reply_to: await
|
|
1327
|
+
reply_to: await this.#constructReplyTo(params),
|
|
1112
1328
|
allow_paid_floodskip: params?.paidBroadcast ? true : undefined,
|
|
1113
1329
|
});
|
|
1114
1330
|
return await this.updatesToMessages(chatId, result);
|
|
1115
1331
|
}
|
|
1116
1332
|
async readMessages(chatId, untilMessageId) {
|
|
1117
|
-
|
|
1118
|
-
const peer = await
|
|
1333
|
+
this.#c.storage.assertUser("readMessages");
|
|
1334
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
1119
1335
|
const max_id = untilMessageId;
|
|
1120
|
-
await
|
|
1336
|
+
await this.#c.invoke({ _: "messages.readHistory", peer, max_id });
|
|
1121
1337
|
}
|
|
1122
1338
|
async startBot(botId, params) {
|
|
1123
|
-
|
|
1339
|
+
this.#c.storage.assertUser("startBot");
|
|
1124
1340
|
const start_param = params?.deeplink?.trim() || "";
|
|
1125
1341
|
if (params?.chatId !== undefined && !start_param) {
|
|
1126
1342
|
throw new _0_errors_js_1.InputError("deeplink cannot be unspecified while chatId is specified.");
|
|
@@ -1128,13 +1344,13 @@ class MessageManager {
|
|
|
1128
1344
|
if (!params?.deeplink) {
|
|
1129
1345
|
return await this.sendMessage(botId, "/start");
|
|
1130
1346
|
}
|
|
1131
|
-
const bot = await
|
|
1132
|
-
const peer = await
|
|
1133
|
-
const result = await
|
|
1347
|
+
const bot = await this.#c.getInputUser(botId);
|
|
1348
|
+
const peer = await this.#c.getInputPeer(params?.chatId || botId);
|
|
1349
|
+
const result = await this.#c.invoke({ _: "messages.startBot", bot, peer, random_id: (0, _1_utilities_js_1.getRandomId)(), start_param });
|
|
1134
1350
|
return (await this.updatesToMessages(botId, result))[0];
|
|
1135
1351
|
}
|
|
1136
1352
|
async transcribeVoice(chatId, messageId) {
|
|
1137
|
-
|
|
1353
|
+
this.#c.storage.assertUser("transcribeVoice");
|
|
1138
1354
|
const message = await this.getMessage(chatId, messageId);
|
|
1139
1355
|
if (message == null) {
|
|
1140
1356
|
throw new _0_errors_js_1.InputError("Message not found.");
|
|
@@ -1142,16 +1358,32 @@ class MessageManager {
|
|
|
1142
1358
|
if (!(0, _3_types_js_1.isMessageType)(message, "voice")) {
|
|
1143
1359
|
throw new _0_errors_js_1.InputError("Message not voice.");
|
|
1144
1360
|
}
|
|
1145
|
-
const cachedTranscription = await
|
|
1361
|
+
const cachedTranscription = await this.#getCachedVoiceTranscription(message);
|
|
1146
1362
|
if (cachedTranscription) {
|
|
1147
1363
|
return cachedTranscription;
|
|
1148
1364
|
}
|
|
1149
|
-
const peer = await
|
|
1150
|
-
const result = await
|
|
1151
|
-
return await
|
|
1365
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
1366
|
+
const result = await this.#c.invoke({ _: "messages.transcribeAudio", peer, msg_id: messageId });
|
|
1367
|
+
return await this.#cacheVoiceTranscription(message, (0, _3_types_js_1.constructVoiceTranscription)(result));
|
|
1368
|
+
}
|
|
1369
|
+
async #getCachedVoiceTranscription(message) {
|
|
1370
|
+
const reference = await this.#c.messageStorage.getVoiceTranscriptionReference(message.chat.id, message.id, (0, _1_utilities_js_1.fromUnixTimestamp)(message.editDate ?? message.date));
|
|
1371
|
+
if (!reference) {
|
|
1372
|
+
return null;
|
|
1373
|
+
}
|
|
1374
|
+
const voiceTranscription = await this.#c.messageStorage.getVoiceTranscription(reference);
|
|
1375
|
+
if (!voiceTranscription || !voiceTranscription.done) {
|
|
1376
|
+
return null;
|
|
1377
|
+
}
|
|
1378
|
+
return voiceTranscription;
|
|
1379
|
+
}
|
|
1380
|
+
async #cacheVoiceTranscription(message, voiceTranscription) {
|
|
1381
|
+
await this.#c.messageStorage.setVoiceTranscriptionReference(message.chat.id, message.id, (0, _1_utilities_js_1.fromUnixTimestamp)(message.editDate ?? message.date), BigInt(voiceTranscription.id));
|
|
1382
|
+
await this.#c.messageStorage.setVoiceTranscription(voiceTranscription);
|
|
1383
|
+
return voiceTranscription;
|
|
1152
1384
|
}
|
|
1153
1385
|
async resolveMessageLink(link) {
|
|
1154
|
-
const parseResult =
|
|
1386
|
+
const parseResult = MessageManager.parseMessageLink(link);
|
|
1155
1387
|
if (parseResult == null) {
|
|
1156
1388
|
throw new _0_errors_js_1.InputError("Invalid messsage link.");
|
|
1157
1389
|
}
|
|
@@ -1238,20 +1470,20 @@ class MessageManager {
|
|
|
1238
1470
|
return [peer, id];
|
|
1239
1471
|
}
|
|
1240
1472
|
async openMiniApp(botId, chatId, params) {
|
|
1241
|
-
|
|
1473
|
+
this.#c.storage.assertUser("openMiniApp");
|
|
1242
1474
|
const from_bot_menu = params?.fromMenu ? true : undefined;
|
|
1243
1475
|
const silent = params?.disableNotification ? true : undefined;
|
|
1244
1476
|
const compact = params?.mode === "compact" ? true : undefined;
|
|
1245
1477
|
const fullscreen = params?.mode === "fullscreen" ? true : undefined;
|
|
1246
|
-
const peer = await
|
|
1247
|
-
const bot = await
|
|
1478
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
1479
|
+
const bot = await this.#c.getInputUser(botId);
|
|
1248
1480
|
const url = params?.url;
|
|
1249
1481
|
const start_param = params?.startParameter;
|
|
1250
1482
|
const theme_params = params?.themeParameters ? { _: "dataJSON", data: params.themeParameters } : undefined;
|
|
1251
|
-
const platform =
|
|
1252
|
-
const reply_to = await
|
|
1253
|
-
const send_as = params?.sendAs ? await
|
|
1254
|
-
const result = await
|
|
1483
|
+
const platform = this.#c.langPack ?? "";
|
|
1484
|
+
const reply_to = await this.#constructReplyTo(params);
|
|
1485
|
+
const send_as = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
|
|
1486
|
+
const result = await this.#c.invoke({
|
|
1255
1487
|
_: "messages.requestWebView",
|
|
1256
1488
|
from_bot_menu,
|
|
1257
1489
|
silent,
|
|
@@ -1270,242 +1502,3 @@ class MessageManager {
|
|
|
1270
1502
|
}
|
|
1271
1503
|
}
|
|
1272
1504
|
exports.MessageManager = MessageManager;
|
|
1273
|
-
_a = MessageManager, _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(), _MessageManager_instances = new WeakSet(), _MessageManager_checkParams = function _MessageManager_checkParams(params) {
|
|
1274
|
-
if (params && "replyMarkup" in params && params.replyMarkup !== undefined) {
|
|
1275
|
-
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("replyMarkup");
|
|
1276
|
-
}
|
|
1277
|
-
if (params && "businessConnectionId" in params && params.businessConnectionId !== undefined) {
|
|
1278
|
-
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("businessConnectionId");
|
|
1279
|
-
}
|
|
1280
|
-
if (params && "sendAs" in params && params.sendAs !== undefined) {
|
|
1281
|
-
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendAs");
|
|
1282
|
-
}
|
|
1283
|
-
if (params && "sendAt" in params && params.sendAt !== undefined) {
|
|
1284
|
-
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("businessConsendAtnectionId");
|
|
1285
|
-
}
|
|
1286
|
-
}, _MessageManager_constructReplyMarkup = async function _MessageManager_constructReplyMarkup(params) {
|
|
1287
|
-
if (params?.replyMarkup) {
|
|
1288
|
-
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("replyMarkup");
|
|
1289
|
-
return await (0, _3_types_js_2.replyMarkupToTlObject)(params.replyMarkup, this.usernameResolver.bind(this));
|
|
1290
|
-
}
|
|
1291
|
-
}, _MessageManager_resolveSendAs = async function _MessageManager_resolveSendAs(params) {
|
|
1292
|
-
const sendAs = params?.sendAs;
|
|
1293
|
-
if (sendAs !== undefined) {
|
|
1294
|
-
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendAs");
|
|
1295
|
-
return sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(sendAs) : undefined;
|
|
1296
|
-
}
|
|
1297
|
-
}, _MessageManager_constructReplyTo = async function _MessageManager_constructReplyTo(params) {
|
|
1298
|
-
const topMsgId = params?.messageThreadId;
|
|
1299
|
-
if (!params?.replyTo) {
|
|
1300
|
-
if (topMsgId) {
|
|
1301
|
-
return { _: "inputReplyToMessage", reply_to_msg_id: topMsgId };
|
|
1302
|
-
}
|
|
1303
|
-
else {
|
|
1304
|
-
return undefined;
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1307
|
-
if ("messageId" in params.replyTo) {
|
|
1308
|
-
return { _: "inputReplyToMessage", reply_to_msg_id: params.replyTo.messageId, top_msg_id: topMsgId, quote_text: params.replyTo.quote?.text, quote_entities: await Promise.all(params.replyTo.quote?.entities.map((v) => (0, _3_types_js_2.messageEntityToTlObject)(v, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity)) ?? []), quote_offset: params.replyTo.quote?.offset };
|
|
1309
|
-
}
|
|
1310
|
-
else {
|
|
1311
|
-
return { _: "inputReplyToStory", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.replyTo.chatId), story_id: params.replyTo.storyId };
|
|
1312
|
-
}
|
|
1313
|
-
}, _MessageManager_sendDocumentInner = async function _MessageManager_sendDocumentInner(chatId, document, params, fileType, otherAttribs, urlSupported = true, expectedMimeTypes) {
|
|
1314
|
-
let media = null;
|
|
1315
|
-
const spoiler = params?.hasSpoiler ? true : undefined;
|
|
1316
|
-
const ttl_seconds = params && "selfDestruct" in params && typeof params.selfDestruct !== undefined ? (0, _3_types_js_1.selfDestructOptionToInt)(params.selfDestruct) : undefined;
|
|
1317
|
-
if (typeof document === "string") {
|
|
1318
|
-
const fileId = this.resolveFileId(document, fileType);
|
|
1319
|
-
if (fileId != null) {
|
|
1320
|
-
media = { _: "inputMediaDocument", id: { ...fileId, _: "inputDocument" }, spoiler, query: otherAttribs.find((v) => _2_tl_js_1.Api.is("documentAttributeSticker", v))?.alt || undefined, ttl_seconds };
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
if (media == null) {
|
|
1324
|
-
if (typeof document === "string" && (0, _0_utilities_js_1.isHttpUrl)(document)) {
|
|
1325
|
-
if (!urlSupported) {
|
|
1326
|
-
throw new _0_errors_js_1.InputError("URL not supported.");
|
|
1327
|
-
}
|
|
1328
|
-
media = { _: "inputMediaDocumentExternal", url: document, spoiler, ttl_seconds };
|
|
1329
|
-
}
|
|
1330
|
-
else {
|
|
1331
|
-
let mimeType;
|
|
1332
|
-
const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(document, params, (name) => {
|
|
1333
|
-
mimeType = params?.mimeType ?? (0, _0_deps_js_1.contentType)(name.split(".").slice(-1)[0]) ?? FALLBACK_MIME_TYPE;
|
|
1334
|
-
if (expectedMimeTypes && !expectedMimeTypes.includes(mimeType)) {
|
|
1335
|
-
(0, _0_deps_js_1.unreachable)();
|
|
1336
|
-
}
|
|
1337
|
-
if (name.endsWith(".tgs") && fileType == _3_types_js_2.FileType.Document) {
|
|
1338
|
-
name += "-";
|
|
1339
|
-
}
|
|
1340
|
-
return name;
|
|
1341
|
-
});
|
|
1342
|
-
if (_2_tl_js_1.Api.is("inputFileStoryDocument", file)) {
|
|
1343
|
-
(0, _0_deps_js_1.unreachable)();
|
|
1344
|
-
}
|
|
1345
|
-
let thumb = undefined;
|
|
1346
|
-
if (params?.thumbnail) {
|
|
1347
|
-
thumb = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(params.thumbnail, { chunkSize: params?.chunkSize, signal: params?.signal });
|
|
1348
|
-
}
|
|
1349
|
-
media = { _: "inputMediaUploadedDocument", file, thumb, spoiler, attributes: [{ _: "documentAttributeFilename", file_name: file.name }, ...otherAttribs], mime_type: mimeType, force_file: fileType == _3_types_js_2.FileType.Document ? true : undefined, ttl_seconds };
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendMedia).call(this, chatId, media, params);
|
|
1353
|
-
return message;
|
|
1354
|
-
}, _MessageManager_sendMedia = async function _MessageManager_sendMedia(chatId, media, params) {
|
|
1355
|
-
if (params?.starCount !== undefined) {
|
|
1356
|
-
if (params.starCount <= 0) {
|
|
1357
|
-
throw new _0_errors_js_1.InputError("starCount cannot be zero or negative");
|
|
1358
|
-
}
|
|
1359
|
-
media = { _: "inputMediaPaidMedia", stars_amount: BigInt(params.starCount), extended_media: [media] };
|
|
1360
|
-
}
|
|
1361
|
-
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
1362
|
-
const randomId = (0, _1_utilities_js_1.getRandomId)();
|
|
1363
|
-
const silent = params?.disableNotification ? true : undefined;
|
|
1364
|
-
const noforwards = params?.protectContent ? true : undefined;
|
|
1365
|
-
const sendAs = params?.sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.sendAs) : undefined;
|
|
1366
|
-
const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
|
|
1367
|
-
const caption_ = params?.caption;
|
|
1368
|
-
const parseResult = caption_ !== undefined ? await this.parseText(caption_, { parseMode: params?.parseMode, entities: params?.captionEntities }) : undefined;
|
|
1369
|
-
const caption = parseResult === undefined ? undefined : parseResult[0];
|
|
1370
|
-
const captionEntities = parseResult === undefined ? undefined : parseResult[1];
|
|
1371
|
-
const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
|
|
1372
|
-
_: "messages.sendMedia",
|
|
1373
|
-
peer,
|
|
1374
|
-
random_id: randomId,
|
|
1375
|
-
silent,
|
|
1376
|
-
noforwards,
|
|
1377
|
-
reply_markup: replyMarkup,
|
|
1378
|
-
reply_to: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyTo).call(this, params),
|
|
1379
|
-
send_as: sendAs,
|
|
1380
|
-
media,
|
|
1381
|
-
message: caption ?? "",
|
|
1382
|
-
entities: captionEntities,
|
|
1383
|
-
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
1384
|
-
schedule_date: params?.sendAt,
|
|
1385
|
-
allow_paid_floodskip: params?.paidBroadcast ? true : undefined,
|
|
1386
|
-
}, { businessConnectionId: params?.businessConnectionId });
|
|
1387
|
-
return (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
|
|
1388
|
-
}, _MessageManager_editInlineMessageTextInner = async function _MessageManager_editInlineMessageTextInner(inlineMessageId, text, params, allowEmpty = true) {
|
|
1389
|
-
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
1390
|
-
const [message, entities] = await this.parseText(text, params);
|
|
1391
|
-
if (!allowEmpty && !message) {
|
|
1392
|
-
throw new _0_errors_js_1.InputError("Message text cannot be empty.");
|
|
1393
|
-
}
|
|
1394
|
-
const id = await (0, _3_types_js_2.deserializeInlineMessageId)(inlineMessageId);
|
|
1395
|
-
if (params?.linkPreview && params.linkPreview.type != "input") {
|
|
1396
|
-
throw new _0_errors_js_1.InputError("Expected link preview of type input.");
|
|
1397
|
-
}
|
|
1398
|
-
const noWebpage = params?.linkPreview && params.linkPreview.type == "input" && params.linkPreview.disable ? true : undefined;
|
|
1399
|
-
const invertMedia = params?.linkPreview?.aboveText ? true : undefined;
|
|
1400
|
-
let media = undefined;
|
|
1401
|
-
if (!noWebpage && params?.linkPreview?.url) {
|
|
1402
|
-
media = { _: "inputMediaWebPage", url: params.linkPreview.url, force_large_media: params.linkPreview.largeMedia ? true : undefined, force_small_media: params.linkPreview.smallMedia ? true : undefined, optional: message.length ? undefined : true };
|
|
1403
|
-
}
|
|
1404
|
-
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
|
|
1405
|
-
_: "messages.editInlineBotMessage",
|
|
1406
|
-
id,
|
|
1407
|
-
entities,
|
|
1408
|
-
message,
|
|
1409
|
-
media,
|
|
1410
|
-
no_webpage: noWebpage,
|
|
1411
|
-
invert_media: invertMedia,
|
|
1412
|
-
reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params),
|
|
1413
|
-
}, { dc: (0, _3_transport_js_1.getDc)(id.dc_id) });
|
|
1414
|
-
}, _MessageManager_resolveInputMediaInner = async function _MessageManager_resolveInputMediaInner(document, media, fileType, otherAttribs) {
|
|
1415
|
-
let media_ = null;
|
|
1416
|
-
const spoiler = "hasSpoiler" in media && media.hasSpoiler ? true : undefined;
|
|
1417
|
-
if (typeof document === "string") {
|
|
1418
|
-
const fileId = this.resolveFileId(document, fileType);
|
|
1419
|
-
if (fileId != null) {
|
|
1420
|
-
media_ = { _: "inputMediaDocument", id: { ...fileId, _: "inputDocument" }, spoiler, query: otherAttribs.find((v) => _2_tl_js_1.Api.is("documentAttributeSticker", v))?.alt || undefined };
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
if (media_ == null) {
|
|
1424
|
-
if (typeof document === "string" && (0, _0_utilities_js_1.isHttpUrl)(document)) {
|
|
1425
|
-
media_ = { _: "inputMediaDocumentExternal", url: document, spoiler };
|
|
1426
|
-
}
|
|
1427
|
-
else {
|
|
1428
|
-
let mimeType;
|
|
1429
|
-
const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(document, media, (name) => {
|
|
1430
|
-
mimeType = media?.mimeType ?? (0, _0_deps_js_1.contentType)(name.split(".").slice(-1)[0]) ?? FALLBACK_MIME_TYPE;
|
|
1431
|
-
if (name.endsWith(".tgs") && fileType == _3_types_js_2.FileType.Document) {
|
|
1432
|
-
name += "-";
|
|
1433
|
-
}
|
|
1434
|
-
return name;
|
|
1435
|
-
});
|
|
1436
|
-
if (_2_tl_js_1.Api.is("inputFileStoryDocument", file)) {
|
|
1437
|
-
(0, _0_deps_js_1.unreachable)();
|
|
1438
|
-
}
|
|
1439
|
-
let thumb = undefined;
|
|
1440
|
-
if ("thumbnail" in media && media.thumbnail) {
|
|
1441
|
-
thumb = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(media.thumbnail, { chunkSize: media?.chunkSize, signal: media?.signal });
|
|
1442
|
-
}
|
|
1443
|
-
media_ = { _: "inputMediaUploadedDocument", file, thumb, spoiler, attributes: [{ _: "documentAttributeFilename", file_name: file.name }, ...otherAttribs], mime_type: mimeType, force_file: fileType == _3_types_js_2.FileType.Document ? true : undefined };
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
|
-
return media_;
|
|
1447
|
-
}, _MessageManager_resolveInputMedia = async function _MessageManager_resolveInputMedia(media) {
|
|
1448
|
-
if ("animation" in media) {
|
|
1449
|
-
return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMediaInner).call(this, media.animation, media, _3_types_js_2.FileType.Animation, [
|
|
1450
|
-
{ _: "documentAttributeAnimated" },
|
|
1451
|
-
{ _: "documentAttributeVideo", supports_streaming: true, w: media?.width ?? 0, h: media?.height ?? 0, duration: media?.duration ?? 0 },
|
|
1452
|
-
]);
|
|
1453
|
-
}
|
|
1454
|
-
else if ("audio" in media) {
|
|
1455
|
-
return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMediaInner).call(this, media.audio, media, _3_types_js_2.FileType.Audio, [
|
|
1456
|
-
{ _: "documentAttributeAudio", duration: media?.duration ?? 0, performer: media?.performer, title: media?.title },
|
|
1457
|
-
]);
|
|
1458
|
-
}
|
|
1459
|
-
else if ("document" in media) {
|
|
1460
|
-
return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMediaInner).call(this, media.document, media, _3_types_js_2.FileType.Document, []);
|
|
1461
|
-
}
|
|
1462
|
-
else if ("photo" in media) {
|
|
1463
|
-
let media_ = null;
|
|
1464
|
-
const spoiler = media.hasSpoiler ? true : undefined;
|
|
1465
|
-
const ttl_seconds = "selfDestruct" in media && media.selfDestruct !== undefined ? (0, _3_types_js_1.selfDestructOptionToInt)(media.selfDestruct) : undefined;
|
|
1466
|
-
if (typeof media.photo === "string") {
|
|
1467
|
-
const fileId = this.resolveFileId(media.photo, [_3_types_js_2.FileType.Photo, _3_types_js_2.FileType.ProfilePhoto]);
|
|
1468
|
-
if (fileId != null) {
|
|
1469
|
-
media_ = { _: "inputMediaPhoto", id: { ...fileId, _: "inputPhoto" }, spoiler, ttl_seconds };
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
if (media_ == null) {
|
|
1473
|
-
if (typeof media.photo === "string" && (0, _0_utilities_js_1.isHttpUrl)(media.photo)) {
|
|
1474
|
-
media_ = { _: "inputMediaPhotoExternal", url: media.photo, spoiler };
|
|
1475
|
-
}
|
|
1476
|
-
else {
|
|
1477
|
-
const file = await __classPrivateFieldGet(this, _MessageManager_c, "f").fileManager.upload(media.photo, media, null, false);
|
|
1478
|
-
media_ = { _: "inputMediaUploadedPhoto", file, spoiler, ttl_seconds };
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
return media_;
|
|
1482
|
-
}
|
|
1483
|
-
else if ("video" in media) {
|
|
1484
|
-
const ttl_seconds = "selfDestruct" in media && media.selfDestruct !== undefined ? (0, _3_types_js_1.selfDestructOptionToInt)(media.selfDestruct) : undefined;
|
|
1485
|
-
const media_ = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMediaInner).call(this, media.video, media, _3_types_js_2.FileType.Video, [
|
|
1486
|
-
{ _: "documentAttributeVideo", supports_streaming: media?.supportsStreaming ? true : undefined, w: media?.width ?? 0, h: media?.height ?? 0, duration: media?.duration ?? 0 },
|
|
1487
|
-
]);
|
|
1488
|
-
media_.ttl_seconds = ttl_seconds;
|
|
1489
|
-
return media_;
|
|
1490
|
-
}
|
|
1491
|
-
else {
|
|
1492
|
-
(0, _0_deps_js_1.unreachable)();
|
|
1493
|
-
}
|
|
1494
|
-
}, _MessageManager_sendReaction = async function _MessageManager_sendReaction(chatId, messageId, reactions, params) {
|
|
1495
|
-
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.sendReaction", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), msg_id: (0, _0_utilities_js_1.checkMessageId)(messageId), reaction: reactions.map((v) => (0, _3_types_js_2.reactionToTlObject)(v)), big: params?.big ? true : undefined, add_to_recent: params?.addToRecents ? true : undefined });
|
|
1496
|
-
}, _MessageManager_getCachedVoiceTranscription = async function _MessageManager_getCachedVoiceTranscription(message) {
|
|
1497
|
-
const reference = await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.getVoiceTranscriptionReference(message.chat.id, message.id, (0, _1_utilities_js_1.fromUnixTimestamp)(message.editDate ?? message.date));
|
|
1498
|
-
if (!reference) {
|
|
1499
|
-
return null;
|
|
1500
|
-
}
|
|
1501
|
-
const voiceTranscription = await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.getVoiceTranscription(reference);
|
|
1502
|
-
if (!voiceTranscription || !voiceTranscription.done) {
|
|
1503
|
-
return null;
|
|
1504
|
-
}
|
|
1505
|
-
return voiceTranscription;
|
|
1506
|
-
}, _MessageManager_cacheVoiceTranscription = async function _MessageManager_cacheVoiceTranscription(message, voiceTranscription) {
|
|
1507
|
-
await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.setVoiceTranscriptionReference(message.chat.id, message.id, (0, _1_utilities_js_1.fromUnixTimestamp)(message.editDate ?? message.date), BigInt(voiceTranscription.id));
|
|
1508
|
-
await __classPrivateFieldGet(this, _MessageManager_c, "f").messageStorage.setVoiceTranscription(voiceTranscription);
|
|
1509
|
-
return voiceTranscription;
|
|
1510
|
-
};
|
|
1511
|
-
_MessageManager_CAPTIONABLE_MESSAGE_TYPES = { value: ["photo", "document", "video", "animation", "voice", "audio", "video"] };
|