diff --git a/src/commands/reminder_cmds.rs b/src/commands/reminder_cmds.rs index 1e8a762..d9e6e9e 100644 --- a/src/commands/reminder_cmds.rs +++ b/src/commands/reminder_cmds.rs @@ -28,6 +28,7 @@ use crate::{ REGEX_CHANNEL_USER, MIN_INTERVAL, MAX_TIME, + LOCAL_TIMEZONE, CHARACTERS, }, models::{ @@ -66,7 +67,6 @@ use num_integer::Integer; use std::{ convert::TryInto, default::Default, - env, string::ToString, time::{ SystemTime, @@ -817,7 +817,7 @@ async fn natural(ctx: &Context, msg: &Message, args: String) -> CommandResult { .arg("dp.py") .arg(time_crop) .arg(&user_data.timezone) - .arg(&env::var("LOCAL_TIMEZONE").unwrap_or_else(|_| "UTC".to_string())) + .arg(&*LOCAL_TIMEZONE) .output() .await; @@ -835,7 +835,7 @@ async fn natural(ctx: &Context, msg: &Message, args: String) -> CommandResult { // check other options and then create reminder :) if msg.guild_id.is_some() { - let re_match = Regex::new(&format!(r#"(?P.*) {} (?P((?:<@\d+>)|(?:<@!\d+>)|(?:<#\d+>)|(?:\s+))+)$"#, to_str)) + let re_match = Regex::new(&format!(r#"(?:\s*)(?P.*) {} (?P((?:<@\d+>)|(?:<@!\d+>)|(?:<#\d+>)|(?:\s+))+)$"#, to_str)) .unwrap() .captures(msg_crop); @@ -871,8 +871,8 @@ async fn natural(ctx: &Context, msg: &Message, args: String) -> CommandResult { let python_call = Command::new("venv/bin/python3") .arg("dp.py") .arg(&format!("1 {}", interval_str)) - .arg(&env::var("LOCAL_TIMEZONE").unwrap_or_else(|_| "UTC".to_string())) - .arg(&env::var("LOCAL_TIMEZONE").unwrap_or_else(|_| "UTC".to_string())) + .arg(&*LOCAL_TIMEZONE) + .arg(&*LOCAL_TIMEZONE) .output() .await; diff --git a/src/consts.rs b/src/consts.rs index 6c4385a..5ae04a4 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -43,4 +43,6 @@ lazy_static! { pub static ref MIN_INTERVAL: i64 = env::var("MIN_INTERVAL").ok().map(|inner| inner.parse::().ok()).flatten().unwrap_or(600); pub static ref MAX_TIME: i64 = env::var("MAX_TIME").ok().map(|inner| inner.parse::().ok()).flatten().unwrap_or(60*60*24*365*50); + + pub static ref LOCAL_TIMEZONE: String = env::var("LOCAL_TIMEZONE").unwrap_or_else(|_| "UTC".to_string()); }