From ab69488340af2133cf99d67b11e619b5cac467b5 Mon Sep 17 00:00:00 2001 From: Nathan Perry Date: Sat, 26 Sep 2020 16:13:43 -0400 Subject: implement piano man --- src/commands/today/pianoman.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/commands/today/pianoman.rs (limited to 'src/commands/today/pianoman.rs') diff --git a/src/commands/today/pianoman.rs b/src/commands/today/pianoman.rs new file mode 100644 index 0000000..d2f11a5 --- /dev/null +++ b/src/commands/today/pianoman.rs @@ -0,0 +1,26 @@ +use super::prelude::*; + +lazy_static! { + static ref TARGET_TIME: chrono::NaiveTime = chrono::NaiveTime::from_hms(21, 0, 0); +} + +pub fn pianoman(dt: chrono::NaiveDateTime) -> TodayIter { + if dt.weekday() != chrono::Weekday::Fri { + return Box::new(empty()); + } + + let diff = { + let result = *TARGET_TIME - dt.time(); + if result < chrono::Duration::zero() { + -result + } else { + result + } + }; + + if diff > Duration::minutes(5) { + return Box::new(empty()); + } + + Box::new(once(by_url("https://www.youtube.com/watch?v=gxEPV4kolz0"))) +} -- cgit v1.3.1