diff --git a/.drone.yml b/.drone.yml index 4f6f7f0..8314028 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,6 +7,14 @@ steps: - apt update - apt install -y cmake - cargo test -v + + - name: clippy-linux + image: rust + commands: + - apt update + - apt install -y cmake + - cargo clippy + --- kind: pipeline name: release diff --git a/CHANGELOG.md b/CHANGELOG.md index bf3210d..1b422e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,2 @@ -# 0.2.1 -- added video support -- added `jens` command -- added `party` command -- meme cache now stores data encoded with bincode. **DELETE BEFORE UPDATE** +# 0.2.2 +- meme cache is now updated after reponse has been sent to reduce latency diff --git a/Cargo.toml b/Cargo.toml index c20c221..878f145 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ruff" -version = "0.2.1" +version = "0.2.2" authors = ["LordMZTE "] edition = "2018" diff --git a/src/responder.rs b/src/responder.rs index afafc0f..ab5ec1b 100644 --- a/src/responder.rs +++ b/src/responder.rs @@ -69,10 +69,6 @@ pub async fn on_msg(msg: &str, room: Room, bot: &Bot) -> anyhow::Result<()> { for meme in &bot.config.memes { if meme.matches(msg) { bot.meme_count.fetch_add(1, Ordering::SeqCst); - if bot.meme_count.load(Ordering::SeqCst) >= bot.config.clear_cache_threshold { - bot.jm_client.write().await.clear_cache().await; - bot.meme_count.store(0, Ordering::SeqCst); - } let meme_name = &meme.keyword; if let Some(meme) = meme.get_meme(bot).await? { @@ -129,6 +125,15 @@ pub async fn on_msg(msg: &str, room: Room, bot: &Bot) -> anyhow::Result<()> { error!("Found meme with invalid id! {:?}", &meme); } } + + // we do this after we have responded, in order to not delay the response + if bot.meme_count.load(Ordering::SeqCst) >= bot.config.clear_cache_threshold { + let mut client = bot.jm_client.write().await; + bot.meme_count.store(0, Ordering::SeqCst); + client.clear_cache().await; + // memes requested but not used, but they will be cached + client.get_memes().await?; + } } Ok(())