From 12b6b74c59b605515c76c16f1204421a31d35fb2 Mon Sep 17 00:00:00 2001 From: fdai7374 Date: Sat, 4 Feb 2023 16:11:43 +0100 Subject: [PATCH] feat: rick rolls now get randomly selected --- src/builtins/rick.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/builtins/rick.rs b/src/builtins/rick.rs index 0b84763..ed5dd91 100644 --- a/src/builtins/rick.rs +++ b/src/builtins/rick.rs @@ -1,5 +1,6 @@ use crate::builtins::{Builtin, BuiltinConfig}; use crate::error::ShellError; +use rand::Rng; use webbrowser; @@ -7,7 +8,16 @@ pub struct Rick; impl Builtin for Rick { fn execute(&mut self, _: &mut BuiltinConfig, _: Vec) -> Result<(), ShellError> { - webbrowser::open("https://www.youtube.com/watch?v=dQw4w9WgXcQ").expect("cant open website",); + const RICK_ROLLS: &[&str] = &[ + ("https://www.youtube.com/watch?v=dQw4w9WgXcQ"), + ("https://www.youtube.com/watch?v=MO7bRMa9bmA&t"), + ("https://www.youtube.com/watch?v=cvh0nX08nRw"), + ("https://www.youtube.com/watch?v=JVzVat71LKg"), + ("https://www.youtube.com/watch?v=hvL1339luv0") + ]; + let mut rng = rand::thread_rng(); + let rick = RICK_ROLLS[rng.gen_range(0..RICK_ROLLS.len())]; + webbrowser::open(rick).expect("cant open website",); Ok(()) } } \ No newline at end of file