use crate::{Client, EngineError};
pub fn get_date_time() -> String {
return chrono::Utc::now()
.format("%Y-%m-%dT%H:%M:%S.%3fZ")
.to_string();
}
pub fn get_table_name() -> Result<String, EngineError> {
match std::env::var("AWS_DYNAMODB_TABLE") {
Ok(val) => return Ok(val),
_ => {
return Err(EngineError::Manager(
"Missing AWS_DYNAMODB_TABLE env var".to_owned(),
))
}
}
}
pub fn make_hash(client: &Client) -> String {
format!(
"bot_id:{}#channel_id:{}#user_id:{}",
client.bot_id, client.channel_id, client.user_id
)
}
pub fn make_range(args: &[&str]) -> String {
let mut res = "".to_owned();
for arg in args.iter() {
if res.len() > 0 {
res = res + "#";
}
res = res + arg.to_owned();
}
res.to_owned()
}