component models
This commit is contained in:
@ -1,23 +1,23 @@
|
||||
mod sender;
|
||||
|
||||
use std::env;
|
||||
|
||||
use log::info;
|
||||
use serenity::client::Context;
|
||||
use sqlx::{Executor, MySql};
|
||||
use std::env;
|
||||
use tokio::time::sleep_until;
|
||||
use tokio::time::{Duration, Instant};
|
||||
use tokio::time::{sleep_until, Duration, Instant};
|
||||
|
||||
type Database = MySql;
|
||||
|
||||
pub async fn initialize(ctx: Context, pool: impl Executor<'_, Database = Database> + Copy) {
|
||||
let REMIND_INTERVAL = env::var("REMIND_INTERVAL")
|
||||
let remind_interval = env::var("REMIND_INTERVAL")
|
||||
.map(|inner| inner.parse::<u64>().ok())
|
||||
.ok()
|
||||
.flatten()
|
||||
.unwrap_or(10);
|
||||
|
||||
loop {
|
||||
let sleep_to = Instant::now() + Duration::from_secs(REMIND_INTERVAL);
|
||||
let sleep_to = Instant::now() + Duration::from_secs(remind_interval);
|
||||
let reminders = sender::Reminder::fetch_reminders(pool).await;
|
||||
|
||||
if reminders.len() > 0 {
|
||||
|
@ -1,4 +1,3 @@
|
||||
use crate::Database;
|
||||
use chrono::Duration;
|
||||
use chrono_tz::Tz;
|
||||
use lazy_static::lazy_static;
|
||||
@ -20,6 +19,8 @@ use sqlx::{
|
||||
Executor,
|
||||
};
|
||||
|
||||
use crate::Database;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref TIMEFROM_REGEX: Regex =
|
||||
Regex::new(r#"<<timefrom:(?P<time>\d+):(?P<format>.+)?>>"#).unwrap();
|
||||
|
Reference in New Issue
Block a user