From a380c1f139d014ddc875dea29476c474bed23966 Mon Sep 17 00:00:00 2001 From: jude Date: Tue, 27 Oct 2020 12:11:05 +0000 Subject: [PATCH] fix for bulk setting reminders --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/commands/reminder_cmds.rs | 7 ++++--- src/consts.rs | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 076a8ac..eaf4109 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1175,7 +1175,7 @@ dependencies = [ [[package]] name = "reminder_rs" -version = "1.1.3" +version = "1.1.4" dependencies = [ "Inflector", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index fccfea1..976fe29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "reminder_rs" -version = "1.1.3" +version = "1.1.4" authors = ["jellywx "] edition = "2018" diff --git a/src/commands/reminder_cmds.rs b/src/commands/reminder_cmds.rs index 9dee337..5e9e66a 100644 --- a/src/commands/reminder_cmds.rs +++ b/src/commands/reminder_cmds.rs @@ -1071,6 +1071,7 @@ async fn natural(ctx: &Context, msg: &Message, args: String) { content = captures.name("msg").unwrap().as_str(); let mentions = captures.name("mentions").unwrap().as_str(); + location_ids = REGEX_CHANNEL_USER .captures_iter(mentions) .map(|i| { @@ -1154,7 +1155,7 @@ async fn natural(ctx: &Context, msg: &Message, args: String) { let _ = msg.channel_id.say(&ctx, &str_response).await; } else { - let mut issue_count = 0_u8; + let mut ok_count = 0_u8; for location in location_ids { let res = create_reminder( @@ -1170,14 +1171,14 @@ async fn natural(ctx: &Context, msg: &Message, args: String) { .await; if res.is_ok() { - issue_count += 1; + ok_count += 1; } } let content = user_data .response(&pool, "natural/bulk_set") .await - .replace("{count}", &issue_count.to_string()); + .replace("{}", &ok_count.to_string()); let _ = msg.channel_id.say(&ctx, content).await; } diff --git a/src/consts.rs b/src/consts.rs index f04cb7d..347f3e4 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -28,7 +28,7 @@ lazy_static! { pub static ref REGEX_COMMANDS: Regex = Regex::new(r#"([a-z]+)"#).unwrap(); pub static ref REGEX_ALIAS: Regex = Regex::new(r#"(?P[\S]{1,12})(?:(?: (?P.*)$)|$)"#).unwrap(); - pub static ref REGEX_CHANNEL_USER: Regex = Regex::new(r#"^\s*<(#|@)(?:!)?(\d+)>\s*$"#).unwrap(); + pub static ref REGEX_CHANNEL_USER: Regex = Regex::new(r#"\s*<(#|@)(?:!)?(\d+)>\s*"#).unwrap(); pub static ref MIN_INTERVAL: i64 = env::var("MIN_INTERVAL") .ok() .map(|inner| inner.parse::().ok())