fix for bulk setting reminders

This commit is contained in:
jude 2020-10-27 12:11:05 +00:00
parent b08848d272
commit a380c1f139
4 changed files with 7 additions and 6 deletions

2
Cargo.lock generated
View File

@ -1175,7 +1175,7 @@ dependencies = [
[[package]] [[package]]
name = "reminder_rs" name = "reminder_rs"
version = "1.1.3" version = "1.1.4"
dependencies = [ dependencies = [
"Inflector", "Inflector",
"async-trait", "async-trait",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "reminder_rs" name = "reminder_rs"
version = "1.1.3" version = "1.1.4"
authors = ["jellywx <judesouthworth@pm.me>"] authors = ["jellywx <judesouthworth@pm.me>"]
edition = "2018" edition = "2018"

View File

@ -1071,6 +1071,7 @@ async fn natural(ctx: &Context, msg: &Message, args: String) {
content = captures.name("msg").unwrap().as_str(); content = captures.name("msg").unwrap().as_str();
let mentions = captures.name("mentions").unwrap().as_str(); let mentions = captures.name("mentions").unwrap().as_str();
location_ids = REGEX_CHANNEL_USER location_ids = REGEX_CHANNEL_USER
.captures_iter(mentions) .captures_iter(mentions)
.map(|i| { .map(|i| {
@ -1154,7 +1155,7 @@ async fn natural(ctx: &Context, msg: &Message, args: String) {
let _ = msg.channel_id.say(&ctx, &str_response).await; let _ = msg.channel_id.say(&ctx, &str_response).await;
} else { } else {
let mut issue_count = 0_u8; let mut ok_count = 0_u8;
for location in location_ids { for location in location_ids {
let res = create_reminder( let res = create_reminder(
@ -1170,14 +1171,14 @@ async fn natural(ctx: &Context, msg: &Message, args: String) {
.await; .await;
if res.is_ok() { if res.is_ok() {
issue_count += 1; ok_count += 1;
} }
} }
let content = user_data let content = user_data
.response(&pool, "natural/bulk_set") .response(&pool, "natural/bulk_set")
.await .await
.replace("{count}", &issue_count.to_string()); .replace("{}", &ok_count.to_string());
let _ = msg.channel_id.say(&ctx, content).await; let _ = msg.channel_id.say(&ctx, content).await;
} }

View File

@ -28,7 +28,7 @@ lazy_static! {
pub static ref REGEX_COMMANDS: Regex = Regex::new(r#"([a-z]+)"#).unwrap(); pub static ref REGEX_COMMANDS: Regex = Regex::new(r#"([a-z]+)"#).unwrap();
pub static ref REGEX_ALIAS: Regex = pub static ref REGEX_ALIAS: Regex =
Regex::new(r#"(?P<name>[\S]{1,12})(?:(?: (?P<cmd>.*)$)|$)"#).unwrap(); Regex::new(r#"(?P<name>[\S]{1,12})(?:(?: (?P<cmd>.*)$)|$)"#).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") pub static ref MIN_INTERVAL: i64 = env::var("MIN_INTERVAL")
.ok() .ok()
.map(|inner| inner.parse::<i64>().ok()) .map(|inner| inner.parse::<i64>().ok())