diff --git a/flake.nix b/flake.nix index 300dda6..b98e820 100644 --- a/flake.nix +++ b/flake.nix @@ -41,6 +41,7 @@ ++ (with pkgs; [ openssl cargo + rustc rustfmt ]); diff --git a/youmubot-osu/src/discord/hook.rs b/youmubot-osu/src/discord/hook.rs index 0f7d6de..e323f0d 100644 --- a/youmubot-osu/src/discord/hook.rs +++ b/youmubot-osu/src/discord/hook.rs @@ -45,7 +45,7 @@ pub fn dot_osu_hook<'a>( async move { let data = ctx.data.read().await; let oppai = data.get::().unwrap(); - let (beatmap, _) = oppai.download_beatmap_from_url(&url, None).await.ok()?; + let (beatmap, _) = oppai.download_beatmap_from_url(&url).await.ok()?; let embed_fn = crate::discord::embeds::beatmap_offline_embed( &beatmap, Mode::from(beatmap.content.mode as u8), /*For now*/ diff --git a/youmubot-osu/src/discord/oppai_cache.rs b/youmubot-osu/src/discord/oppai_cache.rs index b8b14f0..b2c64d2 100644 --- a/youmubot-osu/src/discord/oppai_cache.rs +++ b/youmubot-osu/src/discord/oppai_cache.rs @@ -9,7 +9,6 @@ use youmubot_prelude::*; /// the information collected from a download/Oppai request. #[derive(Debug)] pub struct BeatmapContent { - id: Option, pub metadata: MetadataSection, pub content: Arc, } @@ -131,13 +130,12 @@ impl BeatmapCache { BeatmapCache { client, pool } } - fn parse_beatmap(content: impl AsRef, id: Option) -> Result { + fn parse_beatmap(content: impl AsRef) -> Result { let content = content.as_ref(); let metadata = osuparse::parse_beatmap(content) .map_err(|e| Error::msg(format!("Cannot parse metadata: {:?}", e)))? .metadata; Ok(BeatmapContent { - id, metadata, content: Arc::new(Beatmap::parse(content.as_bytes())?), }) @@ -172,7 +170,7 @@ impl BeatmapCache { }; let mut content = String::new(); v.read_to_string(&mut content).pls_ok()?; - Self::parse_beatmap(content, None).pls_ok() + Self::parse_beatmap(content).pls_ok() }) .collect::>(); Ok(osu_files) @@ -183,7 +181,6 @@ impl BeatmapCache { pub async fn download_beatmap_from_url( &self, url: impl reqwest::IntoUrl, - id: Option, ) -> Result<(BeatmapContent, String)> { let content = self .client @@ -194,13 +191,13 @@ impl BeatmapCache { .await? .text() .await?; - let bm = Self::parse_beatmap(&content, id)?; + let bm = Self::parse_beatmap(&content)?; Ok((bm, content)) } async fn download_beatmap(&self, id: u64) -> Result { let (bm, content) = self - .download_beatmap_from_url(&format!("https://osu.ppy.sh/osu/{}", id), Some(id)) + .download_beatmap_from_url(&format!("https://osu.ppy.sh/osu/{}", id)) .await?; let mut bc = models::CachedBeatmapContent { @@ -215,7 +212,7 @@ impl BeatmapCache { async fn get_beatmap_db(&self, id: u64) -> Result> { Ok(models::CachedBeatmapContent::by_id(id as i64, &self.pool) .await? - .map(|v| Self::parse_beatmap(String::from_utf8(v.content)?, Some(id))) + .map(|v| Self::parse_beatmap(String::from_utf8(v.content)?)) .transpose()?) }