diff --git a/Cargo.lock b/Cargo.lock index ae0d46d2..1f2c62ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -197,9 +197,9 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -379,7 +379,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -391,7 +391,7 @@ dependencies = [ "diesel_table_macro_syntax", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -400,7 +400,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc5557efc453706fed5e4fa85006fe9817c224c3f480a34c7e5959fd700921c5" dependencies = [ - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -495,9 +495,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "erased-serde" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4adbf0983fe06bd3a5c19c8477a637c2389feb0994eca7a59e3b961054aa7c0a" +checksum = "55d05712b2d8d88102bc9868020c9e5c7a1f5527c452b9b97450a1d006140ba7" dependencies = [ "serde", ] @@ -585,9 +585,9 @@ dependencies = [ [[package]] name = "frankenstein" -version = "0.29.2" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1d52ca4dfbb8a00672804f8ec9e30ba55751894530689c1a7223fb7cc232c76" +checksum = "7559bcfdd422bd09e0e6c730556f769a1751561bc7b58035f8fed4fcf1adcae0" dependencies = [ "serde", "thiserror", @@ -665,7 +665,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -854,9 +854,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.58" +version = "0.1.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -983,9 +983,9 @@ checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" [[package]] name = "libnghttp2-sys" -version = "0.1.8+1.55.1" +version = "0.1.9+1.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fae956c192dadcdb5dace96db71fa0b827333cce7c7b38dc71446f024d8a340" +checksum = "b57e858af2798e167e709b9d969325b6d8e9d50232fcbc494d7d54f976854a64" dependencies = [ "cc", "libc", @@ -1193,9 +1193,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" +checksum = "1f200d8d83c44a45b21764d1916299752ca035d15ecd46faca3e9a2a2bf6ad06" dependencies = [ "memchr", "thiserror", @@ -1204,9 +1204,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" +checksum = "bcd6ab1236bbdb3a49027e920e693192ebfe8913f6d60e294de57463a493cfde" dependencies = [ "pest", "pest_generator", @@ -1214,22 +1214,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" +checksum = "2a31940305ffc96863a735bef7c7994a00b325a7138fdbc5bda0f1a0476d3275" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] name = "pest_meta" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" +checksum = "a7ff62f5259e53b78d1af898941cdcdccfae7385cf7d793a6e55de5d05bb4b7d" dependencies = [ "once_cell", "pest", @@ -1253,7 +1253,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -1317,9 +1317,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.71" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] @@ -1346,9 +1346,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -1515,29 +1515,29 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" dependencies = [ "itoa", "ryu", @@ -1578,9 +1578,9 @@ dependencies = [ [[package]] name = "similar" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aeaf503862c419d66959f5d7ca015337d864e9c49485d771b732e2a20453597" +checksum = "32fea41aca09ee824cc9724996433064c89f7777e60762749a4170a14abbfa21" [[package]] name = "siphasher" @@ -1653,9 +1653,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.43" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -1673,22 +1673,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.52" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a48fd946b02c0a526b2e9481c8e2a17755e47039164a86c4070446e3a4614d" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.52" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7fbe9b594d6568a6a1443250a7e67d80b74e1e96f6d1715e1e21cc1888291d3" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -1733,7 +1733,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -1776,7 +1776,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -1832,7 +1832,7 @@ checksum = "982ee4197351b5c9782847ef5ec1fdcaf50503fb19d68f9771adae314e72b492" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -1843,9 +1843,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "typetag" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196976efd4a62737b3a2b662cda76efb448d099b1049613d7a5d72743c611ce0" +checksum = "c43148481c7b66502c48f35b8eef38b6ccdc7a9f04bd4cc294226d901ccc9bc7" dependencies = [ "erased-serde", "inventory", @@ -1856,13 +1856,13 @@ dependencies = [ [[package]] name = "typetag-impl" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eea6765137e2414c44c7b1e07c73965a118a72c46148e1e168b3fc9d3ccf3aa" +checksum = "291db8a81af4840c10d636e047cac67664e343be44e24dfdbd1492df9a5d3390" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", ] [[package]] @@ -1966,7 +1966,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", "wasm-bindgen-shared", ] @@ -1988,7 +1988,7 @@ checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.48", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2032,11 +2032,11 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-core" -version = "0.51.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.48.5", + "windows-targets 0.52.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 69711226..777b44c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ dotenvy = "0.15" pretty_env_logger = "0.5" fang = { version = "0.10.4", features = ["blocking"], default-features = false } feed-rs = "1.3" -frankenstein = { version = "0.29.2", default-features = false, features = ["telegram-trait"] } +frankenstein = { version = "0.30.0", default-features = false, features = ["telegram-trait"] } handlebars = "4.5" hex = "0.4" htmlescape = "0.3" diff --git a/src/bot/commands.rs b/src/bot/commands.rs index 88fa9c28..ad1d0e6c 100644 --- a/src/bot/commands.rs +++ b/src/bot/commands.rs @@ -16,6 +16,7 @@ use frankenstein::Chat; use frankenstein::ChatType; use frankenstein::InlineKeyboardButton; use frankenstein::InlineKeyboardMarkup; +use frankenstein::LinkPreviewOptions; use frankenstein::Message; use frankenstein::ReplyMarkup; use frankenstein::SendMessageParams; @@ -377,9 +378,11 @@ pub trait Command { .inline_keyboard(buttons) .build(); + let preview_params = LinkPreviewOptions::builder().is_disabled(true).build(); + let mut params = SendMessageParams::builder() .chat_id(message.chat.id) - .disable_web_page_preview(true) + .link_preview_options(preview_params) .text(text) .reply_markup(ReplyMarkup::InlineKeyboardMarkup(keyboard)) .build(); diff --git a/src/bot/commands/help.rs b/src/bot/commands/help.rs index 73a12bce..19af6e24 100644 --- a/src/bot/commands/help.rs +++ b/src/bot/commands/help.rs @@ -24,6 +24,7 @@ use super::TogglePreviewEnabled; use super::Unsubscribe; use frankenstein::InlineKeyboardButton; use frankenstein::InlineKeyboardMarkup; +use frankenstein::LinkPreviewOptions; use frankenstein::Message; use frankenstein::ReplyMarkup; use frankenstein::SendMessageParams; @@ -202,11 +203,13 @@ impl Help { .inline_keyboard(buttons) .build(); + let preview_params = LinkPreviewOptions::builder().is_disabled(true).build(); + let mut params = SendMessageParams::builder() .chat_id(self.message.chat.id) .text("In private chats use keyboards to interact with the bot. Send /commands to display the keyboard. \n\nIn channels and groups you will have to type commands directly.\n\nJoin https://t.me/el_monitorro with your feedback, suggestions, found bugs, etc.\n\nSelect a command:") .reply_markup(ReplyMarkup::InlineKeyboardMarkup(keyboard)) - .disable_web_page_preview(true) + .link_preview_options(preview_params) .build(); params.message_thread_id = self.message.message_thread_id; diff --git a/src/bot/commands/start.rs b/src/bot/commands/start.rs index 4beec71c..d1aeeed0 100644 --- a/src/bot/commands/start.rs +++ b/src/bot/commands/start.rs @@ -5,6 +5,7 @@ use super::Response; use frankenstein::ChatType; use frankenstein::InlineKeyboardButton; use frankenstein::InlineKeyboardMarkup; +use frankenstein::LinkPreviewOptions; use frankenstein::ReplyMarkup; use frankenstein::SendMessageParams; use typed_builder::TypedBuilder; @@ -57,9 +58,11 @@ impl Command for Start { .inline_keyboard(buttons) .build(); + let preview_params = LinkPreviewOptions::builder().is_disabled(true).build(); + let params = SendMessageParams::builder() .chat_id(self.message.chat.id) - .disable_web_page_preview(true) + .link_preview_options(preview_params) .text(response) .reply_markup(ReplyMarkup::InlineKeyboardMarkup(keyboard)) .build(); diff --git a/src/bot/commands/unknown_command.rs b/src/bot/commands/unknown_command.rs index e504f6f5..f1fedc9b 100644 --- a/src/bot/commands/unknown_command.rs +++ b/src/bot/commands/unknown_command.rs @@ -6,6 +6,7 @@ use super::Response; use frankenstein::ChatType; use frankenstein::InlineKeyboardButton; use frankenstein::InlineKeyboardMarkup; +use frankenstein::LinkPreviewOptions; use frankenstein::ReplyMarkup; use frankenstein::SendMessageParams; use typed_builder::TypedBuilder; @@ -59,11 +60,13 @@ impl Command for UnknownCommand { .inline_keyboard(buttons) .build(); + let preview_params = LinkPreviewOptions::builder().is_disabled(true).build(); + let mut params = SendMessageParams::builder() .chat_id(self.message.chat.id) .text(text) .reply_markup(ReplyMarkup::InlineKeyboardMarkup(keyboard)) - .reply_to_message_id(message.message_id) + .link_preview_options(preview_params) .build(); params.message_thread_id = message.message_thread_id; diff --git a/src/bot/telegram_client.rs b/src/bot/telegram_client.rs index 1980eae1..10448efe 100644 --- a/src/bot/telegram_client.rs +++ b/src/bot/telegram_client.rs @@ -5,8 +5,10 @@ use frankenstein::AllowedUpdate; use frankenstein::DeleteMessageParams; use frankenstein::ErrorResponse; use frankenstein::GetUpdatesParams; +use frankenstein::LinkPreviewOptions; use frankenstein::Message; use frankenstein::ParseMode; +use frankenstein::ReplyParameters; use frankenstein::SendMessageParams; use frankenstein::TelegramApi; use frankenstein::Update; @@ -118,16 +120,25 @@ impl Api { &self, simple_params: &SimpleMessageParams, ) -> Result<(), Error> { + let preview_params = LinkPreviewOptions::builder() + .is_disabled(!simple_params.preview_enabled) + .build(); + let mut message_params = SendMessageParams::builder() .chat_id(simple_params.chat_id) .text(simple_params.message.clone()) - .disable_web_page_preview(!simple_params.preview_enabled) + .link_preview_options(preview_params) .parse_mode(ParseMode::Html) .build(); - message_params.reply_to_message_id = simple_params.reply_message_id; message_params.message_thread_id = simple_params.message_thread_id; + if let Some(message_id) = simple_params.reply_message_id { + let reply_params = ReplyParameters::builder().message_id(message_id).build(); + + message_params.reply_parameters = Some(reply_params); + } + self.send_message_with_params(&message_params) } diff --git a/src/bot/update_handler.rs b/src/bot/update_handler.rs index 5a44d844..7226ecca 100644 --- a/src/bot/update_handler.rs +++ b/src/bot/update_handler.rs @@ -1,6 +1,7 @@ use super::commands::CommandProcessor; use crate::bot::telegram_client; use crate::config::Config; +use frankenstein::MaybeInaccessibleMessage; use frankenstein::Update; use frankenstein::UpdateContent; use std::thread; @@ -79,12 +80,14 @@ impl UpdateHandler { return; } - CommandProcessor::builder() - .message(query.message.unwrap()) - .text(text.unwrap()) - .callback(true) - .build() - .process(); + if let MaybeInaccessibleMessage::Message(message) = query.message.unwrap() { + CommandProcessor::builder() + .message(message) + .text(text.unwrap()) + .callback(true) + .build() + .process(); + } } fn owner_telegram_id() -> Option {