From 242f2609d8128140d8ab19ac9d88c38646b61536 Mon Sep 17 00:00:00 2001 From: Sokhibjon Orzikulov Date: Mon, 14 Oct 2024 23:11:09 +0500 Subject: [PATCH] new type update checkups --- .gitignore | 1 + Cargo.lock | 152 +++++++++++--------------- bots/xinuxmgr/Cargo.toml | 2 +- bots/xinuxmgr/src/functions/inline.rs | 20 +++- bots/xinuxmgr/src/functions/mod.rs | 4 +- bots/xinuxmgr/src/functions/warn.rs | 24 ++-- flake.lock | 61 +++++++++++ 7 files changed, 154 insertions(+), 110 deletions(-) create mode 100644 flake.lock diff --git a/.gitignore b/.gitignore index 8d5f8d4..53b5cf6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .env nohup.out /target +.idea \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index ae93676..3c00f13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -41,19 +41,6 @@ dependencies = [ "libc", ] -[[package]] -name = "aquamarine" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a941c39708478e8eea39243b5983f1c42d2717b3620ee91f4a52115fd02ac43f" -dependencies = [ - "itertools 0.9.0", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "aquamarine" version = "0.5.0" @@ -61,7 +48,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21cc1548309245035eb18aa7f0967da6bc65587005170c56e6ef2788a4cf3f4e" dependencies = [ "include_dir", - "itertools 0.10.5", + "itertools", "proc-macro-error", "proc-macro2", "quote", @@ -848,15 +835,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "itertools" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.10.5" @@ -990,12 +968,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "never" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c96aba5aa877601bb3f6dd6a63a969e1f82e60646e81e71b14496995e9853c91" - [[package]] name = "num-traits" version = "0.2.19" @@ -1066,13 +1038,15 @@ dependencies = [ [[package]] name = "orzklv" -version = "0.0.8" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4238952fc4c59e01c1225011218f494603d73b66c757c4f3973839cc4410bd3e" +checksum = "8129cb8be2fb2db50a1b78c25e747788ac8291d2dcda5fa7e310d32b932c79e8" dependencies = [ "async-trait", - "teloxide 0.12.2", + "teloxide", + "thiserror", "tokio", + "toml", "url", ] @@ -1558,6 +1532,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -1741,38 +1724,13 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20f34339676cdcab560c9a82300c4c2581f68b9369aedf0fae86f2ff9565ff3e" -[[package]] -name = "teloxide" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c63345cf32a8850ebddcdd769dc2d5193d5e231262d5dada264b79da01a664da" -dependencies = [ - "aquamarine 0.1.12", - "bytes", - "derive_more", - "dptree", - "futures", - "log", - "mime", - "pin-project", - "serde", - "serde_json", - "serde_with_macros", - "teloxide-core 0.9.1", - "thiserror", - "tokio", - "tokio-stream", - "tokio-util", - "url", -] - [[package]] name = "teloxide" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f79dd283eb21b90451c03fa7c7f83b9985130efb876b33bad89a2c208ccbc16" dependencies = [ - "aquamarine 0.5.0", + "aquamarine", "axum", "bytes", "derive_more", @@ -1785,7 +1743,7 @@ dependencies = [ "rand", "serde", "serde_json", - "teloxide-core 0.10.1", + "teloxide-core", "teloxide-macros", "thiserror", "tokio", @@ -1796,37 +1754,6 @@ dependencies = [ "url", ] -[[package]] -name = "teloxide-core" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "303db260110c238e3af77bb9dff18bf7a5b5196f783059b0852aab75f91d5a16" -dependencies = [ - "bitflags 1.3.2", - "bytes", - "chrono", - "derive_more", - "either", - "futures", - "log", - "mime", - "never", - "once_cell", - "pin-project", - "rc-box", - "reqwest 0.11.27", - "serde", - "serde_json", - "serde_with_macros", - "take_mut", - "takecell", - "thiserror", - "tokio", - "tokio-util", - "url", - "uuid", -] - [[package]] name = "teloxide-core" version = "0.10.1" @@ -2010,6 +1937,40 @@ dependencies = [ "tokio", ] +[[package]] +name = "toml" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tower" version = "0.4.13" @@ -2462,6 +2423,15 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "winnow" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" @@ -2482,7 +2452,7 @@ dependencies = [ "pretty_env_logger", "serde", "serde_json", - "teloxide 0.13.0", + "teloxide", "tokio", "url", "uuid", diff --git a/bots/xinuxmgr/Cargo.toml b/bots/xinuxmgr/Cargo.toml index 43b3098..cddde91 100644 --- a/bots/xinuxmgr/Cargo.toml +++ b/bots/xinuxmgr/Cargo.toml @@ -18,5 +18,5 @@ url = "2.4.1" uuid = { version = "1.5.0", features = ["v4"] } serde_json = "1" serde = { version = "1", features = ["derive"] } -orzklv = { version = "0.0.8", features = ["full"] } +orzklv = { version = "0.1.8", features = ["full"] } libxinux = { version = "0.2.3", features = ["pkgs-async"] } diff --git a/bots/xinuxmgr/src/functions/inline.rs b/bots/xinuxmgr/src/functions/inline.rs index 3fe6986..63926d4 100644 --- a/bots/xinuxmgr/src/functions/inline.rs +++ b/bots/xinuxmgr/src/functions/inline.rs @@ -14,7 +14,13 @@ macro_rules! return_err_answer { InputMessageContent::Text( InputMessageContentText::new($msg) .parse_mode(ParseMode::Html) - .disable_web_page_preview(true), + .link_preview_options(LinkPreviewOptions { + is_disabled: true, + url: None, + prefer_small_media: false, + prefer_large_media: false, + show_above_text: false, + }) ), ) .reply_markup(err_keyboard()) @@ -67,11 +73,17 @@ pub async fn inline( InputMessageContent::Text( InputMessageContentText::new(view_generate(d)) .parse_mode(ParseMode::Html) - .disable_web_page_preview(true), + .link_preview_options(LinkPreviewOptions { + is_disabled: true, + url: None, + prefer_small_media: false, + prefer_large_media: false, + show_above_text: false, + }) ), ) - .description(d.description.clone().unwrap()) - .reply_markup(kb_generate(d)), + .description(d.description.clone().unwrap()) + .reply_markup(kb_generate(d)), ) }) .collect(); diff --git a/bots/xinuxmgr/src/functions/mod.rs b/bots/xinuxmgr/src/functions/mod.rs index 22f2257..7090f60 100644 --- a/bots/xinuxmgr/src/functions/mod.rs +++ b/bots/xinuxmgr/src/functions/mod.rs @@ -58,7 +58,7 @@ pub async fn callback( pub async fn triggers(bot: Bot, msg: Message) -> Result<(), Box> { if let Some(thread) = msg.thread_id { - if msg.chat.id.0 == -1001174263940 && thread == 178654 { + if msg.chat.id.0 == -1001174263940 && thread.0.0 == 178654 { // Delete anything except image if msg.photo().is_some() || msg.document().is_some() { return Ok(()); @@ -72,7 +72,7 @@ pub async fn triggers(bot: Bot, msg: Message) -> Result<(), Box Resp } if msg.reply_to_message().is_none() - || msg.reply_to_message().unwrap().id == MessageId(msg.thread_id.unwrap()) + || msg.reply_to_message().unwrap().id == MessageId(msg.thread_id.unwrap().0.0) { return { bot.send_message_tf(msg.chat.id, TEXT_NON_REPLY, msg) @@ -43,7 +43,7 @@ pub async fn command(bot: &Bot, msg: &Message, me: &Me, topics: &Topics) -> Resp } // if replied person is bot itself, send a fail message - if let Some(user) = msg.reply_to_message().as_ref().unwrap().from() { + if let Some(user) = &msg.reply_to_message().as_ref().unwrap().from { if user.username.is_some() && user.username.clone().unwrap() == me.username() { return { bot.send_message_tf(msg.chat.id, TEXT_FAIL, msg).await?; @@ -55,7 +55,7 @@ pub async fn command(bot: &Bot, msg: &Message, me: &Me, topics: &Topics) -> Resp bot.delete_message(msg.chat.id, msg.reply_to_message().unwrap().id) .await?; - let replied_person = match msg.reply_to_message().unwrap().from() { + let replied_person = match &msg.reply_to_message().unwrap().from { None => { bot.send_message_tf( msg.chat.id, @@ -73,15 +73,15 @@ pub async fn command(bot: &Bot, msg: &Message, me: &Me, topics: &Topics) -> Resp msg.chat.id, format!( "Xo'sh, {}. Qaysi mavzu taraflama yozgan odam chetlashdi?", - msg.from().unwrap().id, - msg.from().unwrap().first_name + msg.from.clone().unwrap().id, + msg.from.clone().unwrap().first_name ), msg, ) // view_detail(msg.reply_to_message().unwrap()) .parse_mode(ParseMode::Html) .reply_markup(keyboard( topics.list(), - msg.from().unwrap().id, + msg.from.clone().unwrap().id, &replied_person.id, &replied_person.first_name, )) @@ -113,23 +113,23 @@ pub async fn callback( match code { None => { - bot.delete_message(message.chat.id, message.id).await?; + bot.delete_message(message.chat().id, message.id()).await?; bot.send_message_tf( - message.chat.id, + message.chat().id, "Unaqa topic borga o'xshamaydi do'stlar...", - &message, + &message.regular_message().unwrap(), ) .await?; Ok(()) } Some(c) => { - bot.delete_message(message.chat.id, message.id).await?; + bot.delete_message(message.chat().id, message.id()).await?; bot.send_message_tf( - message.chat.id, + message.chat().id, view_detail(sender, title.to_string()), - &message, + &message.regular_message().unwrap(), ) .reply_markup(callback_keyboard(title, c)) .parse_mode(ParseMode::Html) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..243467a --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1728492678, + "narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "5633bcff0c6162b9e4b5f1264264611e950c8ec7", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +}