Initial commit

This commit is contained in:
2025-04-23 21:59:50 +02:00
commit 4458163c6d
9 changed files with 1775 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
use rss::{Channel, Guid, Item};
use std::error::Error;
pub mod discord;
pub async fn get_content(source: &str) -> Result<Channel, Box<dyn Error>> {
let content = reqwest::get(source)
.await?
.bytes()
.await?;
let channel = Channel::read_from(&content[..])?;
Ok(channel)
}
pub fn get_latest(rss: &Channel) -> Option<&Item> {
rss.items().first()
}
pub fn get_new<'a>(rss: &'a Channel, latest: &Guid) -> &'a [Item] {
match rss
.items()
.iter()
.position(|item| item.guid().map(|guid| guid == latest).unwrap_or(false))
.map(|i| &rss.items()[0..i])
{
None => rss.items(),
Some(list) => list,
}
}