From 21c97d4a4010bec271c293b8be4c1c6dc63606fd Mon Sep 17 00:00:00 2001 From: shibedrill <53824200+shibedrill@users.noreply.github.com> Date: Thu, 25 Apr 2024 23:52:03 -0400 Subject: [PATCH] rename whack, add deer --- Cargo.lock | 177 ++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/command/fun.rs | 85 ++++++++++++--------- src/command/util.rs | 6 +- src/main.rs | 3 +- 5 files changed, 235 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c11702f..b0dff4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -409,6 +409,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -657,6 +672,19 @@ dependencies = [ "tokio-rustls 0.24.1", ] +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + [[package]] name = "iana-time-zone" version = "0.1.60" @@ -738,6 +766,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + [[package]] name = "libc" version = "0.2.153" @@ -766,6 +800,17 @@ version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +[[package]] +name = "maybe-async" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cf92c10c7e361d6b99666ec1c6f9805b0bea2c3bd8c78dc6fe98ac5bd78db11" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.59", +] + [[package]] name = "memchr" version = "2.7.2" @@ -823,6 +868,24 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "num-conv" version = "0.1.0" @@ -863,6 +926,50 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "openssl" +version = "0.10.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.59", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "parking_lot" version = "0.12.1" @@ -904,6 +1011,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + [[package]] name = "poise" version = "0.6.1" @@ -1068,11 +1181,13 @@ dependencies = [ "http-body", "hyper", "hyper-rustls", + "hyper-tls", "ipnet", "js-sys", "log", "mime", "mime_guess", + "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -1084,6 +1199,7 @@ dependencies = [ "sync_wrapper", "system-configuration", "tokio", + "tokio-native-tls", "tokio-rustls 0.24.1", "tokio-util", "tower-service", @@ -1111,6 +1227,18 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "roux" +version = "2.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15948b57a15aed182d06fe3810eaf27dda15583c2f714437e1dd88fa12f33b82" +dependencies = [ + "maybe-async", + "reqwest", + "serde", + "serde_json", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -1207,6 +1335,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1233,6 +1370,29 @@ dependencies = [ "zeroize", ] +[[package]] +name = "security-framework" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "1.0.22" @@ -1337,6 +1497,7 @@ dependencies = [ "poise", "pretty_env_logger", "rand", + "roux", "serde", "serde_json", "tokio", @@ -1570,6 +1731,16 @@ dependencies = [ "syn 2.0.59", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.24.1" @@ -1787,6 +1958,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index f6bd9df..37a3844 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,3 +14,4 @@ tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] } rand = "0.8.5" serde = { version = "1.0.198", features = ["serde_derive"] } serde_json = "1.0.116" +roux = "2.2.12" diff --git a/src/command/fun.rs b/src/command/fun.rs index 92ebeec..fc83fe2 100644 --- a/src/command/fun.rs +++ b/src/command/fun.rs @@ -2,21 +2,25 @@ use crate::Context; use crate::Error; use poise::serenity_prelude as serenity; + use rand::prelude::SliceRandom; use rand::*; +use roux::util::*; +use roux::*; + /// mrow #[poise::command(slash_command)] pub async fn meow(ctx: Context<'_>) -> Result<(), Error> { let meows = [ - "meow", - "mrow", - "mrrrp", - "mraaw", - "bwrrrr", - "mrrghh", - "mrowwwwwwwwwwww", - "FUCK", + "meow", + "mrow", + "mrrrp", + "mraaw", + "bwrrrr", + "mrrghh", + "mrowwwwwwwwwwww", + "FUCK", ]; let response = { let mut rng = rand::thread_rng(); @@ -32,18 +36,18 @@ pub async fn meow(ctx: Context<'_>) -> Result<(), Error> { Ok(()) } -/// penis +/// WHACK a user #[poise::command(slash_command)] -pub async fn penis( +pub async fn whack( ctx: Context<'_>, #[description = "The target user"] target: serenity::User, ) -> Result<(), Error> { ctx.say(format!( - "<@{}> has been penised. they must penis another user to become un-penised", + "<@{}> has been whacked. they must whack another user to become un-whacked", target.id )) .await?; - info!("Executed command `penis` successfully"); + info!("Executed command `whack` successfully"); Ok(()) } @@ -51,33 +55,33 @@ pub async fn penis( #[poise::command(slash_command)] pub async fn eightball(ctx: Context<'_>) -> Result<(), Error> { let responses = [ - "It is certain", - "It is decidedly so", - "Without a doubt", - "Yes definitely", - "You may rely on it", - "As I see it, yes", - "Most likely", - "Outlook good", - "Yes", - "Signs point to yes", - "Reply hazy, try again", - "Ask again later", - "Better not to tell you now", - "Cannot predict now", - "Concentrate and ask again", - "Don't count on it", - "My reply is no", - "My sources say no", - "Outlook not so good", - "Very doubtful", + "It is certain", + "It is decidedly so", + "Without a doubt", + "Yes definitely", + "You may rely on it", + "As I see it, yes", + "Most likely", + "Outlook good", + "Yes", + "Signs point to yes", + "Reply hazy, try again", + "Ask again later", + "Better not to tell you now", + "Cannot predict now", + "Concentrate and ask again", + "Don't count on it", + "My reply is no", + "My sources say no", + "Outlook not so good", + "Very doubtful", ]; let response = { let mut rng = rand::thread_rng(); responses.choose(&mut rng).unwrap() }; ctx.say(format!("Magic 8-ball says: '{}'", *response)) - .await?; + .await?; info!("Executed command `eightball` successfully"); Ok(()) } @@ -97,3 +101,18 @@ pub async fn bite( info!("Executed command `bite` successfully"); Ok(()) } + +/// POST A DEER +#[poise::command(slash_command)] +pub async fn deer(ctx: Context<'_>) -> Result<(), Error> { + let subreddit = Subreddit::new("deer"); + let options = FeedOption::new().period(TimePeriod::ThisYear); + let hot = subreddit.hot(50, Some(options)).await?; + let chosen_post = { + let mut rng = rand::thread_rng(); + hot.data.children.choose(&mut rng).unwrap() + }; + ctx.say(format!("https://reddit.com{}", &chosen_post.data.permalink)).await?; + info!("Executed command `deer` successfully"); + Ok(()) +} diff --git a/src/command/util.rs b/src/command/util.rs index 45e3213..c7e5abe 100644 --- a/src/command/util.rs +++ b/src/command/util.rs @@ -96,9 +96,9 @@ pub async fn list_channels(ctx: Context<'_>) -> Result<(), Error> { let config = &mut ctx.data().config_manager.lock().await; let mut channel_ids: Vec = vec![]; config - .channels - .iter() - .for_each(|c| channel_ids.push(u64::from(c.id()))); + .channels + .iter() + .for_each(|c| channel_ids.push(u64::from(c.id()))); ctx.say(format!( "Current channel IDs in registry: \n{:#?}", channel_ids diff --git a/src/main.rs b/src/main.rs index 1937032..b3573a8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -90,9 +90,10 @@ async fn main() { restart(), // Fun meow(), - penis(), + whack(), eightball(), bite(), + deer(), ], initialize_owners: true, ..Default::default()