From 90c65693de1d9cfcec3ee458bb1c58da2921fbed Mon Sep 17 00:00:00 2001 From: Alex Page Date: Thu, 2 Mar 2023 22:52:19 -0500 Subject: [PATCH] Add cat pun loading messages --- Cargo.toml | 1 + src/commands.rs | 10 +++++++--- src/openai.rs | 28 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e145a17..2075e09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ tracing = "0.1.37" tracing-subscriber = "0.3.16" tracing-futures = "0.2.5" openai = "1.0.0-alpha.5" +rand = "0.8.5" [dependencies.songbird] version = "0.3.0" diff --git a/src/commands.rs b/src/commands.rs index 5d77b33..fa0d168 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -81,9 +81,13 @@ pub async fn play( } if let Some(handler_lock) = manager.get(guild.id) { - let response = ctx - .send(|r| r.content("https://media.giphy.com/media/H1dxi6xdh4NGQCZSvz/giphy.gif")) - .await?; + let mut msg = MessageBuilder::new(); + msg.push_line(String::from(openai::get_random_loading_message())) + .push_named_link( + "", + "https://media.giphy.com/media/H1dxi6xdh4NGQCZSvz/giphy.gif", + ); + let response = ctx.send(|r| r.content(msg.build())).await?; let mut handler = handler_lock.lock().await; diff --git a/src/openai.rs b/src/openai.rs index 6cd68fa..09c3790 100644 --- a/src/openai.rs +++ b/src/openai.rs @@ -3,6 +3,34 @@ use openai::{ chat::{ChatCompletion, ChatCompletionRequestMessage}, models::ModelID, }; +use rand::seq::SliceRandom; + +const LOADING_MESSAGES: [&str; 20] = [ + "Hold your claws, I'm searching for the right tune.", + "Sorry, I was busy napping. Let me find your song meow.", + "Just a whisker longer, I'm on the hunt for your jam.", + "Be patient, I'm pawsitively searching for your requested song.", + "Let me caterwaul through my playlist to find your tune.", + "Feline a bit slow, but I'll find your song in no time.", + "Don't be catty, I'm just trying to find the right tune for you.", + "Just paws for a moment, I'm working on finding your song.", + "Hiss-terical, just need a moment to find your meow-sic.", + "Give me a few seconds, I'm furiously searching for your requested song.", + "Cat got my tongue! Just need a sec to find your track.", + "Let me use my cat-like reflexes to search for your song.", + "I'm not lion around, just give me a moment to find your tune.", + "Don't be hiss-ty, I'm searching for your requested song.", + "Just kitten around, I'll find your song in a jiffy.", + "Purr-haps it'll take me a moment, but I'll find your tune soon enough.", + "My paws are a little tired, but I'm still searching for your song!", + "Sorry, my cat nap ran a little long. Let me find your song now.", + "I'm not trying to be catty, just need a minute to find your tune.", + "Don't be fur-ious, I'm doing my best to find your requested song.", +]; + +pub fn get_random_loading_message() -> &'static str { + return LOADING_MESSAGES.choose(&mut rand::thread_rng()).unwrap(); +} pub async fn get_sassy_commentary(title: &str) -> Result { let system = [