2022-01-22 21:02:51 +00:00
|
|
|
use imgurs::api::rate_limit::*;
|
2022-01-22 22:10:11 +00:00
|
|
|
use imgurs::api::ImgurHandle;
|
2022-01-22 21:02:51 +00:00
|
|
|
|
2022-01-22 21:14:26 +00:00
|
|
|
use log::{error, info};
|
2022-01-22 21:02:51 +00:00
|
|
|
|
|
|
|
use chrono::prelude::DateTime;
|
|
|
|
use chrono::Utc;
|
2022-01-22 21:14:26 +00:00
|
|
|
use std::time::{Duration, UNIX_EPOCH};
|
2022-01-22 21:02:51 +00:00
|
|
|
|
|
|
|
pub async fn credits(client: ImgurHandle) {
|
|
|
|
match rate_limit(client).await {
|
|
|
|
Ok(i) => {
|
|
|
|
let d = UNIX_EPOCH + Duration::from_secs(i.data.user_reset.try_into().unwrap());
|
|
|
|
let datetime = DateTime::<Utc>::from(d);
|
|
|
|
let timestamp_str = datetime.format("%Y-%m-%d %H:%M:%S").to_string();
|
|
|
|
|
|
|
|
info!("User Limit {}", i.data.user_limit);
|
|
|
|
info!("User Remaining {}", i.data.user_remaining);
|
|
|
|
info!("User Reset {} (UTC)", timestamp_str);
|
|
|
|
info!("Client Limit {}", i.data.client_limit);
|
|
|
|
info!("Client Remaining {}", i.data.client_remaining);
|
|
|
|
}
|
|
|
|
|
|
|
|
Err(e) => {
|
|
|
|
error!("{}", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|