Feature: BotNotificator #18
@ -157,7 +157,6 @@ where
|
|||||||
|
|
||||||
let thread =
|
let thread =
|
||||||
spawn_bot_thread(controller.bot.clone(), controller.db.clone(), handler).await?;
|
spawn_bot_thread(controller.bot.clone(), controller.db.clone(), handler).await?;
|
||||||
println!("Starting notificator");
|
|
||||||
let notificator = spawn_notificator_thread(controller.clone()).await?;
|
let notificator = spawn_notificator_thread(controller.clone()).await?;
|
||||||
let notificator = NotificatorThread::Running(Some(notificator));
|
let notificator = NotificatorThread::Running(Some(notificator));
|
||||||
|
|
||||||
@ -235,8 +234,6 @@ pub async fn spawn_notificator_thread(
|
|||||||
match notifications {
|
match notifications {
|
||||||
Some(n) => {
|
Some(n) => {
|
||||||
// waiting time to send notification
|
// waiting time to send notification
|
||||||
println!("Will send notification after {:?}", n.wait_for());
|
|
||||||
println!("Notifications: {:#?}", n.notifications());
|
|
||||||
tokio::time::sleep(n.wait_for()).await;
|
tokio::time::sleep(n.wait_for()).await;
|
||||||
'n: for n in n.notifications().into_iter() {
|
'n: for n in n.notifications().into_iter() {
|
||||||
for user in n.get_users(&c.db).await?.into_iter() {
|
for user in n.get_users(&c.db).await?.into_iter() {
|
||||||
|
|||||||
@ -625,12 +625,10 @@ impl NotificationTime {
|
|||||||
delta_minutes,
|
delta_minutes,
|
||||||
} => {
|
} => {
|
||||||
let delta = TimeDelta::minutes((delta_minutes + delta_hours * 60).into());
|
let delta = TimeDelta::minutes((delta_minutes + delta_hours * 60).into());
|
||||||
println!("Delta: {delta}");
|
|
||||||
|
|
||||||
let mut estimation = *start_time;
|
let mut estimation = *start_time;
|
||||||
// super non-optimal, but fun :)
|
// super non-optimal, but fun :)
|
||||||
loop {
|
loop {
|
||||||
println!("Adding delta to estimation");
|
|
||||||
if estimation < now + Duration::from_secs(1) {
|
if estimation < now + Duration::from_secs(1) {
|
||||||
estimation += delta;
|
estimation += delta;
|
||||||
} else {
|
} else {
|
||||||
@ -807,7 +805,6 @@ impl BotNotification {
|
|||||||
// immidate notification if time to do it passed
|
// immidate notification if time to do it passed
|
||||||
let duration = (next - now).to_std().unwrap_or(Duration::from_secs(1));
|
let duration = (next - now).to_std().unwrap_or(Duration::from_secs(1));
|
||||||
|
|
||||||
println!("Left time: {duration:?}");
|
|
||||||
// Rounding partitions of seconds
|
// Rounding partitions of seconds
|
||||||
Duration::from_secs(duration.as_secs())
|
Duration::from_secs(duration.as_secs())
|
||||||
}
|
}
|
||||||
@ -890,7 +887,6 @@ impl RunnerConfig {
|
|||||||
.filter(|f| f.left_time(&start_time, &now) > Duration::from_secs(1))
|
.filter(|f| f.left_time(&start_time, &now) > Duration::from_secs(1))
|
||||||
.sorted_by_key(|f| f.left_time(&start_time, &now))
|
.sorted_by_key(|f| f.left_time(&start_time, &now))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
println!("Orederd: {:#?}", ordered);
|
|
||||||
|
|
||||||
let left = match ordered.first() {
|
let left = match ordered.first() {
|
||||||
Some(notification) => notification.left_time(&start_time, &now),
|
Some(notification) => notification.left_time(&start_time, &now),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user