From 0b8b0594cc82c37abde53cc44dd30a3e9f6d2709 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 29 Jun 2014 08:39:51 +0200 Subject: [PATCH] Handle extra-time & pso This how we work with an API without documentation: learn when it happens :) --- worldCupNotifier.php | 70 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 10 deletions(-) diff --git a/worldCupNotifier.php b/worldCupNotifier.php index c7692ca..48ca0a1 100644 --- a/worldCupNotifier.php +++ b/worldCupNotifier.php @@ -237,21 +237,71 @@ function postToSlack($text, $attachments_text = '') // half time, end game case 'End': - if ('1H' == $post['data']['c_ActionPhase']) + switch ($post['data']['c_ActionPhase']) { - // half time - postToSlack($preText.':toilet: '.$text); + case '1H': + // half time + postToSlack($preText.':toilet: '.$text); + break; + + case '2H': + // end game + postToSlack($preText.':no_good: '.$text, $db[$liveMatch]['score']); + break; + + case '1ET': + // end of first extra time + postToSlack($preText.':smoking: '.$text, $db[$liveMatch]['score']); + break; + + case '2ET': + // end of second extra time + postToSlack($preText.':no_good: '.$text, $db[$liveMatch]['score']); + break; + + case 'PSO': + // end of penalty shout-out + postToSlack($preText.':no_good: '.$text, $db[$liveMatch]['score']); + break; } - elseif ('2H' == $post['data']['c_ActionPhase']) - { - // end game - postToSlack($preText.':no_good: '.$text, $db[$liveMatch]['score']); + break; - // remove match - unset($db['live_matches'][$key]); - unset($db[$liveMatch]); + // halftime, extra time, penalty shout-out + case 'Start': + switch ($post['data']['c_ActionPhase']) + { + case '2H': + // second half time + postToSlack($preText.':runner: '.$text); + break; + + case '1ET': + // extra time starts + postToSlack($preText.':dizzy: '.$text); + break; + + case '2ET': + // second period of extra time + postToSlack($preText.':runner: '.$text); + break; + + case 'PSO': + // penalty shout-out + postToSlack($preText.':dart: '.$text); + break; } break; + + // penalty shout-out + case 'PSG': + // pso goal + postToSlack($preText.':+1: '.$text); + break; + + case 'PSM': + // pso goal + postToSlack($preText.':-1: '.$text); + break; } } }