feat: add basic rss feat support
This commit is contained in:
parent
183b2c2c88
commit
452b8b49c3
13 changed files with 232 additions and 166 deletions
|
|
@ -3,6 +3,9 @@ name = "noisebell-discord"
|
|||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
axum = "0.8"
|
||||
|
|
|
|||
|
|
@ -87,10 +87,7 @@ async fn post_webhook(
|
|||
}
|
||||
|
||||
fn unix_now() -> u64 {
|
||||
std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs()
|
||||
std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_secs()
|
||||
}
|
||||
|
||||
fn format_timestamp(ts: u64) -> String {
|
||||
|
|
@ -106,11 +103,9 @@ async fn handle_status(
|
|||
|
||||
let embed = match resp {
|
||||
Ok(resp) if resp.status().is_success() => match resp.json::<CacheStatusResponse>().await {
|
||||
Ok(data) => build_embed(
|
||||
data.status,
|
||||
data.since.unwrap_or(unix_now()),
|
||||
&state.image_base_url,
|
||||
),
|
||||
Ok(data) => {
|
||||
build_embed(data.status, data.since.unwrap_or(unix_now()), &state.image_base_url)
|
||||
}
|
||||
Err(e) => {
|
||||
error!(error = %e, "failed to parse status response");
|
||||
CreateEmbed::new()
|
||||
|
|
@ -137,7 +132,8 @@ impl serenity::all::EventHandler for Handler {
|
|||
async fn ready(&self, ctx: serenity::all::Context, ready: serenity::model::gateway::Ready) {
|
||||
info!(user = %ready.user.name, "Discord bot connected");
|
||||
|
||||
let commands = vec![CreateCommand::new("status").description("Show the current door status")];
|
||||
let commands =
|
||||
vec![CreateCommand::new("status").description("Show the current door status")];
|
||||
|
||||
if let Err(e) = serenity::all::Command::set_global_commands(&ctx.http, commands).await {
|
||||
error!(error = %e, "failed to register slash commands");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue