added support for language files

This commit is contained in:
2025-04-06 15:43:35 +02:00
parent eb0991df53
commit 0c87e5f56a
28 changed files with 1087 additions and 973 deletions
+35
View File
@@ -0,0 +1,35 @@
use std::future::Future;
use std::pin::Pin;
use std::time::Duration;
use tokio::task::JoinHandle;
use tokio::time;
use crate::{lang, rs_println};
pub type Schedule = (Duration, fn() -> Pin<Box<dyn Future<Output = ()> + Send>>);
pub async fn run_schedule<F: Fn() -> Pin<Box<dyn Future<Output = ()> + Send>>>(d: Duration, f: F) {
let mut ticker = time::interval(d);
loop {
ticker.tick().await;
f().await;
}
}
pub async fn run_schedules(schedules: Vec<Schedule>) {
let mut handles: Vec<JoinHandle<()>> = vec![];
rs_println!("{}", lang!("starting_schedules"));
for (d, f) in schedules {
let handle = tokio::spawn(run_schedule(d, f));
handles.push(handle);
}
for handle in handles {
let _ = handle.await;
}
}