Implement script to warn about unfinished tasks
[SonOfLokstallBot.git] / tasks.php
index b03ff5a..f58a7d4 100644 (file)
--- a/tasks.php
+++ b/tasks.php
@@ -9,14 +9,14 @@ $mondays = [
     (int)(new DateTimeImmutable('third monday of this month'))->format('d'),
     (int)(new DateTimeImmutable('fourth monday of this month'))->format('d'),
 ];
-$currentMonth = (new DateTimeImmutable())->format('m');
+$currentMonth = (int)(new DateTimeImmutable())->format('m');
 $currentDayOfMonth = closest((new DateTimeImmutable())->format('d'), $mondays);
 $currentWeekOfMonth = array_search($currentDayOfMonth, $mondays);
 
 $taskLists = array_merge(
-    isStartOfSeason($currentMonth, $currentDayOfMonth) ? [unlines(map(getString)(getTasksForTheSeason(getSeason($currentMonth), $taskMatrix)))] : [],
-    isStartOfMonth($currentDayOfMonth) ? [unlines(map(getString)(getTasksForTheMonth($currentMonth, $taskMatrix)))] : [],
-    [unlines(map(getString)(getTasksForTheWeek($currentWeekOfMonth, $currentMonth, $taskMatrix)))]
+    isStartOfSeason($currentMonth, $currentDayOfMonth) ? [unlines(map(getStringAndCode)(getTasksForTheSeason(getSeason($currentMonth), $taskMatrix)))] : [],
+    isStartOfMonth($currentDayOfMonth) ? [unlines(map(getStringAndCode)(getTasksForTheMonth($currentMonth, $taskMatrix)))] : [],
+    [unlines(map(getStringAndCode)(getTasksForTheWeek($currentWeekOfMonth, $currentMonth, $taskMatrix)))]
 );
 
 $taskMessages = [
@@ -41,7 +41,7 @@ $messages = zipWith(
             )
         );
     },
-    // Magic. startOfSeason implis startofMonth so we get 2, start of month without start of season gives 1 and
+    // Magic. startOfSeason implies startofMonth so we get 2, start of month without start of season gives 1 and
     // a regular week (not the start of a season or month) gives 0. And this is how the indicies are ordered in the array.
     $taskMessages[isStartOfSeason($currentMonth, $currentDayOfMonth) + isStartOfMonth($currentDayOfMonth)],
     $taskLists
@@ -51,11 +51,3 @@ foreach ($messages as $message) {
     sendToGroupChat($message);
     sleep(rand(2,4));
 }
-
-$seasonalMemes = [
-    'summer' => ['https://www.youtube.com/watch?v=NqktmrKB3ko']
-];
-
-if (isStartOfSeason($currentMonth, $currentDayOfMonth)) {
-    sendToGroupChat(getString('seasonalMeme', $seasonalMemes[getSeason($currentMonth)][array_rand($seasonalMemes[getSeason($currentMonth)])]));
-}