Index: Cargo.lock ================================================================== --- Cargo.lock +++ Cargo.lock @@ -2,13 +2,13 @@ # It is not intended for manual editing. version = 3 [[package]] name = "addr2line" -version = "0.15.2" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7a2e47a1fbe209ee101dd6d61285226744c6c8d3c21c8dc878ba6cb9f467f3a" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] [[package]] @@ -140,11 +140,11 @@ "cfg-if", "concurrent-queue", "futures-io", "futures-lite 2.3.0", "parking", - "polling 3.7.1", + "polling 3.7.2", "rustix 0.38.34", "slab", "tracing", "windows-sys 0.52.0", ] @@ -236,21 +236,10 @@ name = "async-task" version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" -[[package]] -name = "async-trait" -version = "0.1.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "atomic-waker" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" @@ -261,13 +250,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.59" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4717cfcbfaa661a0fd48f8453951837ae7e8f81e481fbb136e3202d72805a744" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", "cfg-if", "libc", @@ -367,15 +356,14 @@ "crossbeam-utils", ] [[package]] name = "config" -version = "0.13.4" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23738e11972c7643e4ec947840fc463b6a571afcd3e735bdfce7d03c7a784aca" +checksum = "7328b20597b53c2454f0b1919720c25c7339051c02b72b7e05409e00b14132be" dependencies = [ - "async-trait", "lazy_static", "nom 7.1.3", "pathdiff", "serde", "toml", @@ -744,13 +732,13 @@ "wasi", ] [[package]] name = "gimli" -version = "0.24.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "gloo-timers" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -791,10 +779,16 @@ name = "hermit-abi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" @@ -1054,11 +1048,11 @@ name = "io-lifetimes" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", "windows-sys 0.48.0", ] [[package]] @@ -1182,13 +1176,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" [[package]] name = "memchr" -version = "2.3.4" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "mime" version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1210,16 +1204,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.4.4" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" dependencies = [ "adler", - "autocfg", ] [[package]] name = "mio" version = "0.8.11" @@ -1254,13 +1247,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c96aba5aa877601bb3f6dd6a63a969e1f82e60646e81e71b14496995e9853c91" [[package]] name = "nom" -version = "6.2.2" +version = "6.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6a7a9657c84d5814c6196b68bb4429df09c18b1573806259fba397ea4ad0d44" +checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2" dependencies = [ "bitvec", "funty", "lexical-core", "memchr", @@ -1290,19 +1283,22 @@ name = "num_cpus" version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", ] [[package]] name = "object" -version = "0.24.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170" +checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" +dependencies = [ + "memchr", +] [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1468,17 +1464,17 @@ "windows-sys 0.48.0", ] [[package]] name = "polling" -version = "3.7.1" +version = "3.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6a007746f34ed64099e88783b0ae369eaa3da6392868ba262e2af9b8fbaea1" +checksum = "a3ed00ed3fbf728b5816498ecd316d1716eecaced9c0c8d2c5a6740ca214985b" dependencies = [ "cfg-if", "concurrent-queue", - "hermit-abi", + "hermit-abi 0.4.0", "pin-project-lite 0.2.14", "rustix 0.38.34", "tracing", "windows-sys 0.52.0", ] @@ -1730,11 +1726,11 @@ "fast_chemail", "hostname", "log", "lozizol", "memchr", - "nom 6.2.2", + "nom 6.1.2", "pin-project", "pin-utils", "potential", "samotop-core", "serde", @@ -1837,10 +1833,19 @@ dependencies = [ "itoa", "ryu", "serde", ] + +[[package]] +name = "serde_spanned" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +dependencies = [ + "serde", +] [[package]] name = "serde_urlencoded" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1898,11 +1903,11 @@ "pin-project-lite 0.1.12", ] [[package]] name = "smtp2tg" -version = "0.2.1" +version = "0.2.3" dependencies = [ "anyhow", "async-std", "config", "mail-parser", @@ -2204,15 +2209,40 @@ "tokio", ] [[package]] name = "toml" -version = "0.5.11" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ + "indexmap", "serde", + "serde_spanned", + "toml_datetime", + "winnow", ] [[package]] name = "tower-service" version = "0.3.2" @@ -2605,10 +2635,19 @@ [[package]] name = "windows_x86_64_msvc" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "winnow" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +dependencies = [ + "memchr", +] [[package]] name = "winreg" version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" Index: Cargo.toml ================================================================== --- Cargo.toml +++ Cargo.toml @@ -3,15 +3,15 @@ version = "0.2.3" authors = [ "arcade" ] edition = "2021" [dependencies] -anyhow = "*" -async-std = { version = "*", features = [ "tokio1" ] } -config = { version = "*", default-features = false, features = [ "toml" ] } -teloxide = { version = "*", features = [ "rustls", "throttle" ] } -mail-parser = { version = "*", features = ["serde", "serde_support"] } -samotop = { version = "*", default-features = false, features = [ "delivery", "parser-peg" ] } +anyhow = "1.0.86" +async-std = { version = "1.12.0", features = [ "tokio1" ] } +config = { version = "0.14.0", default-features = false, features = [ "toml" ] } +teloxide = { version = "0.12.2", features = [ "rustls", "throttle" ] } +mail-parser = { version = "0.9.3", features = ["serde", "serde_support"] } +samotop = { version = "0.13.2", default-features = false, features = [ "delivery", "parser-peg" ] } [profile.release] lto = true codegen-units = 1 Index: src/main.rs ================================================================== --- src/main.rs +++ src/main.rs @@ -21,10 +21,12 @@ Requester, RequesterExt, }, types::{ ChatId, + InputMedia, + Message, ParseMode::MarkdownV2, }, }; use std::{ @@ -145,13 +147,11 @@ body = text; text_num = 1; } }; reply.push("```".into()); - for line in body.lines() { - reply.push(line.into()); - } + reply.extend(body.lines().map(|x| x.into())); reply.push("```".into()); // and let's collect all other attachment parts let mut files_to_send = vec![]; /* @@ -206,11 +206,11 @@ first_one = false; item.caption(&msg).parse_mode(MarkdownV2) } else { item }; - files.push(teloxide::types::InputMedia::Document(item)); + files.push(InputMedia::Document(item)); } core.sendgroup(chat, files).await?; } else { core.send(chat, &msg).await?; } @@ -250,22 +250,22 @@ tg, recipients, } } - pub async fn debug<'b, S>(&self, msg: S) -> Result + pub async fn debug<'b, S>(&self, msg: S) -> Result where S: Into { Ok(self.tg.send_message(*self.recipients.get("_").unwrap(), msg).await?) } - pub async fn send<'b, S>(&self, to: &ChatId, msg: S) -> Result + pub async fn send<'b, S>(&self, to: &ChatId, msg: S) -> Result where S: Into { Ok(self.tg.send_message(*to, msg).await?) } - pub async fn sendgroup(&self, to: &ChatId, media: M) -> Result> - where M: IntoIterator { + pub async fn sendgroup(&self, to: &ChatId, media: M) -> Result> + where M: IntoIterator { Ok(self.tg.send_media_group(*to, media).await?) } } #[async_std::main]