rename whack, add deer

This commit is contained in:
shibedrill 2024-04-25 23:52:03 -04:00
parent b6d6581301
commit 21c97d4a40
5 changed files with 235 additions and 37 deletions

177
Cargo.lock generated
View File

@ -409,6 +409,21 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 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]] [[package]]
name = "form_urlencoded" name = "form_urlencoded"
version = "1.2.1" version = "1.2.1"
@ -657,6 +672,19 @@ dependencies = [
"tokio-rustls 0.24.1", "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]] [[package]]
name = "iana-time-zone" name = "iana-time-zone"
version = "0.1.60" version = "0.1.60"
@ -738,6 +766,12 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.153" version = "0.2.153"
@ -766,6 +800,17 @@ version = "0.4.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" 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]] [[package]]
name = "memchr" name = "memchr"
version = "2.7.2" version = "2.7.2"
@ -823,6 +868,24 @@ dependencies = [
"windows-sys 0.48.0", "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]] [[package]]
name = "num-conv" name = "num-conv"
version = "0.1.0" version = "0.1.0"
@ -863,6 +926,50 @@ version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" 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]] [[package]]
name = "parking_lot" name = "parking_lot"
version = "0.12.1" version = "0.12.1"
@ -904,6 +1011,12 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkg-config"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
[[package]] [[package]]
name = "poise" name = "poise"
version = "0.6.1" version = "0.6.1"
@ -1068,11 +1181,13 @@ dependencies = [
"http-body", "http-body",
"hyper", "hyper",
"hyper-rustls", "hyper-rustls",
"hyper-tls",
"ipnet", "ipnet",
"js-sys", "js-sys",
"log", "log",
"mime", "mime",
"mime_guess", "mime_guess",
"native-tls",
"once_cell", "once_cell",
"percent-encoding", "percent-encoding",
"pin-project-lite", "pin-project-lite",
@ -1084,6 +1199,7 @@ dependencies = [
"sync_wrapper", "sync_wrapper",
"system-configuration", "system-configuration",
"tokio", "tokio",
"tokio-native-tls",
"tokio-rustls 0.24.1", "tokio-rustls 0.24.1",
"tokio-util", "tokio-util",
"tower-service", "tower-service",
@ -1111,6 +1227,18 @@ dependencies = [
"windows-sys 0.52.0", "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]] [[package]]
name = "rustc-demangle" name = "rustc-demangle"
version = "0.1.23" version = "0.1.23"
@ -1207,6 +1335,15 @@ dependencies = [
"winapi-util", "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]] [[package]]
name = "scopeguard" name = "scopeguard"
version = "1.2.0" version = "1.2.0"
@ -1233,6 +1370,29 @@ dependencies = [
"zeroize", "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]] [[package]]
name = "semver" name = "semver"
version = "1.0.22" version = "1.0.22"
@ -1337,6 +1497,7 @@ dependencies = [
"poise", "poise",
"pretty_env_logger", "pretty_env_logger",
"rand", "rand",
"roux",
"serde", "serde",
"serde_json", "serde_json",
"tokio", "tokio",
@ -1570,6 +1731,16 @@ dependencies = [
"syn 2.0.59", "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]] [[package]]
name = "tokio-rustls" name = "tokio-rustls"
version = "0.24.1" version = "0.24.1"
@ -1787,6 +1958,12 @@ version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
[[package]]
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.4" version = "0.9.4"

View File

@ -14,3 +14,4 @@ tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
rand = "0.8.5" rand = "0.8.5"
serde = { version = "1.0.198", features = ["serde_derive"] } serde = { version = "1.0.198", features = ["serde_derive"] }
serde_json = "1.0.116" serde_json = "1.0.116"
roux = "2.2.12"

View File

@ -2,21 +2,25 @@ use crate::Context;
use crate::Error; use crate::Error;
use poise::serenity_prelude as serenity; use poise::serenity_prelude as serenity;
use rand::prelude::SliceRandom; use rand::prelude::SliceRandom;
use rand::*; use rand::*;
use roux::util::*;
use roux::*;
/// mrow /// mrow
#[poise::command(slash_command)] #[poise::command(slash_command)]
pub async fn meow(ctx: Context<'_>) -> Result<(), Error> { pub async fn meow(ctx: Context<'_>) -> Result<(), Error> {
let meows = [ let meows = [
"meow", "meow",
"mrow", "mrow",
"mrrrp", "mrrrp",
"mraaw", "mraaw",
"bwrrrr", "bwrrrr",
"mrrghh", "mrrghh",
"mrowwwwwwwwwwww", "mrowwwwwwwwwwww",
"FUCK", "FUCK",
]; ];
let response = { let response = {
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
@ -32,18 +36,18 @@ pub async fn meow(ctx: Context<'_>) -> Result<(), Error> {
Ok(()) Ok(())
} }
/// penis /// WHACK a user
#[poise::command(slash_command)] #[poise::command(slash_command)]
pub async fn penis( pub async fn whack(
ctx: Context<'_>, ctx: Context<'_>,
#[description = "The target user"] target: serenity::User, #[description = "The target user"] target: serenity::User,
) -> Result<(), Error> { ) -> Result<(), Error> {
ctx.say(format!( 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 target.id
)) ))
.await?; .await?;
info!("Executed command `penis` successfully"); info!("Executed command `whack` successfully");
Ok(()) Ok(())
} }
@ -51,33 +55,33 @@ pub async fn penis(
#[poise::command(slash_command)] #[poise::command(slash_command)]
pub async fn eightball(ctx: Context<'_>) -> Result<(), Error> { pub async fn eightball(ctx: Context<'_>) -> Result<(), Error> {
let responses = [ let responses = [
"It is certain", "It is certain",
"It is decidedly so", "It is decidedly so",
"Without a doubt", "Without a doubt",
"Yes definitely", "Yes definitely",
"You may rely on it", "You may rely on it",
"As I see it, yes", "As I see it, yes",
"Most likely", "Most likely",
"Outlook good", "Outlook good",
"Yes", "Yes",
"Signs point to yes", "Signs point to yes",
"Reply hazy, try again", "Reply hazy, try again",
"Ask again later", "Ask again later",
"Better not to tell you now", "Better not to tell you now",
"Cannot predict now", "Cannot predict now",
"Concentrate and ask again", "Concentrate and ask again",
"Don't count on it", "Don't count on it",
"My reply is no", "My reply is no",
"My sources say no", "My sources say no",
"Outlook not so good", "Outlook not so good",
"Very doubtful", "Very doubtful",
]; ];
let response = { let response = {
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
responses.choose(&mut rng).unwrap() responses.choose(&mut rng).unwrap()
}; };
ctx.say(format!("Magic 8-ball says: '{}'", *response)) ctx.say(format!("Magic 8-ball says: '{}'", *response))
.await?; .await?;
info!("Executed command `eightball` successfully"); info!("Executed command `eightball` successfully");
Ok(()) Ok(())
} }
@ -97,3 +101,18 @@ pub async fn bite(
info!("Executed command `bite` successfully"); info!("Executed command `bite` successfully");
Ok(()) 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(())
}

View File

@ -96,9 +96,9 @@ pub async fn list_channels(ctx: Context<'_>) -> Result<(), Error> {
let config = &mut ctx.data().config_manager.lock().await; let config = &mut ctx.data().config_manager.lock().await;
let mut channel_ids: Vec<u64> = vec![]; let mut channel_ids: Vec<u64> = vec![];
config config
.channels .channels
.iter() .iter()
.for_each(|c| channel_ids.push(u64::from(c.id()))); .for_each(|c| channel_ids.push(u64::from(c.id())));
ctx.say(format!( ctx.say(format!(
"Current channel IDs in registry: \n{:#?}", "Current channel IDs in registry: \n{:#?}",
channel_ids channel_ids

View File

@ -90,9 +90,10 @@ async fn main() {
restart(), restart(),
// Fun // Fun
meow(), meow(),
penis(), whack(),
eightball(), eightball(),
bite(), bite(),
deer(),
], ],
initialize_owners: true, initialize_owners: true,
..Default::default() ..Default::default()