Fix bug where tasks weren't detected as all done after completing the last one
authorCameron Ball <cameron@cameron1729.xyz>
Sat, 5 Jan 2019 19:58:30 +0000 (03:58 +0800)
committerCameron Ball <cameron@cameron1729.xyz>
Sun, 6 Jan 2019 18:34:13 +0000 (02:34 +0800)
src/purjolok.php

index ab224a3..9f4cacd 100644 (file)
@@ -75,7 +75,7 @@ if ($between = between(reveal($message ?? ''), '[taskid]')) {
         'sticker' => 'CAADBQADOwAD__7RB2i3XcCiO8HuAg'
     ]);
 
-    if (!array_diff($tasksForTheWeek, $completedTasks)) {
+    if (!array_diff($tasksForTheWeek, array_merge($completedTasks, [$between]))) {
         getTelegram()->sendMessage([
             'chat_id' => $chatid,
             'text' => getString('heyTasksAllCompleted')
@@ -300,8 +300,6 @@ getTelegram()->addCommand(
             $completedTasksFile = getFilePathForWeek($yearForThisWeek, $monthForThisWeek, $weekNum);
             $completedTasks = file_exists($completedTasksFile) ? lines(trim(file_get_contents($completedTasksFile))) : [];
 
-
-
             if (!array_diff($tasksForTheWeek, $completedTasks)) {
                 $this->replyWithMessage([
                     'text' => getString('tasksAllCompleted')