Unverified Commit b783b165 authored by tec's avatar tec
Browse files

Refactor cowsay

parent d0cc9ca7
......@@ -56,25 +56,23 @@ impl Commands {
pub fn cowsay(ctx: Context, msg: Message, content: &str) {
let output;
if !content.trim().is_empty() {
let output = if !content.trim().is_empty() {
let mut text = content.to_owned();
// Guess what buddy! You definitely are passing a string to cowsay
text.insert(0, '\'');
text.insert(text.len(), '\'');
output = std::process::Command::new("cowsay")
// btw, if we can't execute cowsay we crash
.expect("failed to execute cowsay");
.expect("failed to execute cowsay")
} else {
output = std::process::Command::new("sh")
.arg("sh -c fortune | cowsay -f \"/usr/share/cowsay/cows/$(echo 'www\nhellokitty\nbud-frogs\nkoala\nsuse\nthree-eyes\npony-smaller\nsheep\nvader\ncower\nmoofasa\nelephant\nflaming-sheep\nskeleton\nsnowman\ntux\napt\nmoose' | shuf -n 1).cow\"")
.expect("failed to execute fortune/cowsay");
.expect("failed to execute fortune/cowsay")
let mut message = MessageBuilder::new();
String::from_utf8(output.stdout).expect("unable to parse stdout to String"),
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment