Index: Cargo.lock ================================================================== --- Cargo.lock +++ Cargo.lock @@ -78,11 +78,11 @@ "brotli", "flate2", "futures-core", "memchr", "pin-project-lite", - "tokio 1.18.2", + "tokio 1.19.2", ] [[package]] name = "async-executor" version = "1.4.1" @@ -108,11 +108,11 @@ "async-io", "async-lock", "blocking", "futures-lite", "once_cell", - "tokio 1.18.2", + "tokio 1.19.2", ] [[package]] name = "async-io" version = "1.7.0" @@ -203,13 +203,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9" [[package]] name = "async-trait" -version = "0.1.53" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6aa3524a2dfcf9fe180c51eae2b58738348d819517ceadf95789c51fff7600" +checksum = "96cf8829f67d2eab0b2dfa42c5d0ef737e0724e4a82b01b3e292456202b19716" dependencies = [ "proc-macro2", "quote", "syn", ] @@ -338,13 +338,13 @@ "alloc-stdlib", ] [[package]] name = "bumpalo" -version = "3.9.1" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" +checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" [[package]] name = "byteorder" version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1103,15 +1103,15 @@ "bytes 1.1.0", "fnv", "futures-core", "futures-sink", "futures-util", - "http 0.2.7", + "http 0.2.8", "indexmap", "slab", - "tokio 1.18.2", - "tokio-util 0.7.2", + "tokio 1.19.2", + "tokio-util 0.7.3", "tracing", ] [[package]] name = "hashbrown" @@ -1184,13 +1184,13 @@ "itoa 0.4.8", ] [[package]] name = "http" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff8670570af52249509a86f5e3e18a08c60b177071826898fde8997cf5f6bfbb" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" dependencies = [ "bytes 1.1.0", "fnv", "itoa 1.0.2", ] @@ -1212,11 +1212,11 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes 1.1.0", - "http 0.2.7", + "http 0.2.8", "pin-project-lite", ] [[package]] name = "httparse" @@ -1269,18 +1269,18 @@ "bytes 1.1.0", "futures-channel", "futures-core", "futures-util", "h2 0.3.13", - "http 0.2.7", + "http 0.2.8", "http-body 0.4.5", "httparse", "httpdate", "itoa 1.0.2", "pin-project-lite", "socket2", - "tokio 1.18.2", + "tokio 1.19.2", "tower-service", "tracing", "want 0.3.0", ] @@ -1304,11 +1304,11 @@ checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes 1.1.0", "hyper 0.14.19", "native-tls", - "tokio 1.18.2", + "tokio 1.19.2", "tokio-native-tls", ] [[package]] name = "ident_case" @@ -1706,13 +1706,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.73" +version = "0.9.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5fd19fb3e0a8191c1e34935718976a3e70c112ab9a24af6d7cadccd9d90bc0" +checksum = "835363342df5fba8354c5b453325b110ffd54044e588c539cf2f20a8014e4cb1" dependencies = [ "autocfg 1.1.0", "cc", "libc", "pkg-config", @@ -2197,11 +2197,11 @@ "bytes 1.1.0", "encoding_rs", "futures-core", "futures-util", "h2 0.3.13", - "http 0.2.7", + "http 0.2.8", "http-body 0.4.5", "hyper 0.14.19", "hyper-tls 0.5.0", "ipnet", "js-sys", @@ -2212,11 +2212,11 @@ "percent-encoding 2.1.0", "pin-project-lite", "serde", "serde_json", "serde_urlencoded 0.7.1", - "tokio 1.18.2", + "tokio 1.19.2", "tokio-native-tls", "tokio-util 0.6.10", "url 2.2.2", "wasm-bindgen", "wasm-bindgen-futures", @@ -2250,11 +2250,11 @@ "reqwest 0.9.24", ] [[package]] name = "rsstg" -version = "0.2.13" +version = "0.2.14" dependencies = [ "anyhow", "async-std", "atom_syndication", "chrono", @@ -2659,13 +2659,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.95" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942" +checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] @@ -2691,11 +2691,11 @@ "futures 0.3.21", "hyper 0.14.19", "hyper-tls 0.5.0", "multipart", "telegram-bot-raw", - "tokio 1.18.2", + "tokio 1.19.2", "tracing", "tracing-futures", ] [[package]] @@ -2788,13 +2788,13 @@ "tokio-timer", ] [[package]] name = "tokio" -version = "1.18.2" +version = "1.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4903bf0427cf68dddd5aa6a93220756f8be0c34fcfa9f5e6191e103e15a31395" +checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439" dependencies = [ "bytes 1.1.0", "libc", "memchr", "mio 0.8.3", @@ -2852,11 +2852,11 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" dependencies = [ "native-tls", - "tokio 1.18.2", + "tokio 1.19.2", ] [[package]] name = "tokio-reactor" version = "0.1.12" @@ -2938,24 +2938,24 @@ "bytes 1.1.0", "futures-core", "futures-sink", "log", "pin-project-lite", - "tokio 1.18.2", + "tokio 1.19.2", ] [[package]] name = "tokio-util" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f988a1a1adc2fb21f9c12aa96441da33a1728193ae0b95d2be22dbd17fcb4e5c" +checksum = "cc463cd8deddc3770d20f9852143d50bf6094e640b485cb2e189a2099085ff45" dependencies = [ "bytes 1.1.0", "futures-core", "futures-sink", "pin-project-lite", - "tokio 1.18.2", + "tokio 1.19.2", "tracing", ] [[package]] name = "toml" @@ -2972,13 +2972,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.34" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09" +checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160" dependencies = [ "cfg-if 1.0.0", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -2995,15 +2995,15 @@ "syn", ] [[package]] name = "tracing-core" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f" +checksum = "7709595b8878a4965ce5e87ebf880a7d39c9afc6837721b21a5a816a8117d921" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] name = "tracing-futures" version = "0.2.5" Index: Cargo.toml ================================================================== --- Cargo.toml +++ Cargo.toml @@ -1,8 +1,8 @@ [package] name = "rsstg" -version = "0.2.13" +version = "0.2.14" authors = ["arcade"] edition = "2018" [dependencies] anyhow = "*" Index: src/command.rs ================================================================== --- src/command.rs +++ src/command.rs @@ -20,23 +20,27 @@ core.send(core.list(sender).await?, Some(sender), Some(telegram_bot::types::ParseMode::MarkdownV2)).await?; Ok(()) } pub async fn command(core: &Core, sender: telegram_bot::UserId, command: Vec<&str>) -> Result<()> { - let msg: Cow = match &command[1].parse::() { - Err(err) => format!("I need a number.\n{}", &err).into(), - Ok(number) => match command[0] { - "/check" => core.check(number, sender, false).await - .context("Channel check failed.")?, - "/clean" => core.clean(number, sender).await?, - "/enable" => core.enable(number, sender).await?.into(), - "/delete" => core.delete(number, sender).await?, - "/disable" => core.disable(number, sender).await?.into(), - _ => bail!("Command {} not handled.", &command[0]), - }, - }; - core.send(msg, Some(sender), None).await?; + if command.len() >= 2 { + let msg: Cow = match &command[1].parse::() { + Err(err) => format!("I need a number.\n{}", &err).into(), + Ok(number) => match command[0] { + "/check" => core.check(number, sender, false).await + .context("Channel check failed.")?, + "/clean" => core.clean(number, sender).await?, + "/enable" => core.enable(number, sender).await?.into(), + "/delete" => core.delete(number, sender).await?, + "/disable" => core.disable(number, sender).await?.into(), + _ => bail!("Command {} not handled.", &command[0]), + }, + }; + core.send(msg, Some(sender), None).await?; + } else { + core.send("This command needs a number.", Some(sender), None).await?; + } Ok(()) } pub async fn update(core: &Core, sender: telegram_bot::UserId, command: Vec<&str>) -> Result<()> { let mut source_id: Option = None;