From 43ba899c7a26b29b312316fc81c445a46733ad5c Mon Sep 17 00:00:00 2001 From: jellywx Date: Sun, 17 Jan 2021 00:39:48 +0000 Subject: [PATCH] removed forward check bc it doesnt work. added an environment variable to configure if dm responses should be enabled --- Cargo.lock | 45 ++++++++++++++++++----------------- Cargo.toml | 2 +- README.md | 1 + src/commands/reminder_cmds.rs | 6 ++--- src/consts.rs | 2 +- src/framework.rs | 34 ++++++++++++++++---------- src/main.rs | 1 + 7 files changed, 52 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aef5aac..6f9fd2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -401,9 +401,9 @@ checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" [[package]] name = "futures" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "309f13e3f4be6d5917178c84db67c0b9a09177ac16d4f9a7313a767a68adaa77" +checksum = "90fa4cc29d25b0687b8570b0da86eac698dcb525110ad8b938fe6712baa711ec" dependencies = [ "futures-channel", "futures-core", @@ -416,9 +416,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a3b03bd32f6ec7885edeb99acd1e47e20e34fd4dfd3c6deed6fcac8a9d28f6a" +checksum = "31ebc390c6913de330e418add60e1a7e5af4cb5ec600d19111b339cafcdcc027" dependencies = [ "futures-core", "futures-sink", @@ -426,15 +426,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed8aeae2b6ab243ebabe6f54cd4cf53054d98883d5d326128af7d57a9ca5cd3d" +checksum = "089bd0baf024d3216916546338fffe4fc8dfffdd901e33c278abb091e0d52111" [[package]] name = "futures-executor" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f7836b36b7533d16fd5937311d98ba8965ab81030de8b0024c299dd5d51fb9b" +checksum = "d0cb59f15119671c94cd9cc543dc9a50b8d5edc468b4ff5f0bb8567f66c6b48a" dependencies = [ "futures-core", "futures-task", @@ -443,15 +443,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d41234e71d5e8ca73d01563974ef6f50e516d71e18f1a2f1184742e31f5d469f" +checksum = "3868967e4e5ab86614e2176c99949eeef6cbcacaee737765f6ae693988273997" [[package]] name = "futures-macro" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3520e0eb4e704e88d771b92d51273ee212997f0d8282f17f5d8ff1cb39104e42" +checksum = "95778720c3ee3c179cd0d8fd5a0f9b40aa7d745c080f86a8f8bed33c4fd89758" dependencies = [ "proc-macro-hack", "proc-macro2", @@ -461,24 +461,24 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c72d188479368953c6c8c7140e40d7a4401674ab3b98a41e60e515d6cbdbe5de" +checksum = "d4e0f6be0ec0357772fd58fb751958dd600bd0b3edfd429e77793e4282831360" [[package]] name = "futures-task" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08944cea9021170d383287169859c0ca8147d9ec285978393109954448f33cc7" +checksum = "868090f28a925db6cb7462938c51d807546e298fb314088239f0e52fb4338b96" dependencies = [ "once_cell", ] [[package]] name = "futures-util" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd206efbe2ca683b2ce138ccdf61e1b0a63f5816dcedc9d8654c500ba0cea6" +checksum = "cad5e82786df758d407932aded1235e24d8e2eb438b6adafd37930c2462fb5d1" dependencies = [ "futures-channel", "futures-core", @@ -623,9 +623,9 @@ checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" [[package]] name = "humantime" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c1ad908cc71012b7bea4d0c53ba96a8cba9962f048fa68d143376143d863b7a" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" @@ -1161,9 +1161,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro-nested" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" @@ -1321,6 +1321,7 @@ dependencies = [ "chrono-tz", "dotenv", "env_logger", + "humantime", "lazy_static", "levenshtein", "log", diff --git a/Cargo.toml b/Cargo.toml index 7575dc8..aea3116 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] dotenv = "0.15" -# chrono-english = "0.1.4" +humantime = "2.1" tokio = { version = "1.0", features = ["process"] } reqwest = { version = "0.11", features = ["rustls-tls"] } regex = "1.4" diff --git a/README.md b/README.md index 023bf8b..c50801f 100644 --- a/README.md +++ b/README.md @@ -42,3 +42,4 @@ __Other Variables__ * `CASE_INSENSITIVE` - default `1`, if `1`, commands will be treated with case insensitivity (so both `$help` and `$HELP` will work) * `SHARD_COUNT` - default `None`, accepts the number of shards that are being ran * `SHARD_RANGE` - default `None`, if `SHARD_COUNT` is specified, specifies what range of shards to start on this process +* `DM_ENABLED` - default `1`, if `1`, Reminder Bot will respond to direct messages diff --git a/src/commands/reminder_cmds.rs b/src/commands/reminder_cmds.rs index 194e821..904292a 100644 --- a/src/commands/reminder_cmds.rs +++ b/src/commands/reminder_cmds.rs @@ -1243,9 +1243,9 @@ async fn natural(ctx: &Context, msg: &Message, args: String) { let interval = if let Some(interval_crop) = captures.name("interval") { if subscribed { - natural_parser(interval_crop.as_str(), &user_data.timezone) - .await - .map(|i| i - since_epoch.as_secs() as i64) + humantime::parse_duration(interval_crop.as_str()) + .map(|duration| duration.as_secs() as i64) + .ok() } else { None } diff --git a/src/consts.rs b/src/consts.rs index 13acdca..d7126a1 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -55,7 +55,7 @@ lazy_static! { .unwrap(); pub static ref REGEX_NATURAL_COMMAND: Regex = Regex::new( - r#"(?P