fix for people not collected all types
1 parent 0c753e0 commit 68bde988ad11225b08cde21865cada1c8c81659c
root authored on 6 Aug 2021
Showing 1 changed file
View
20
bot.php
$devResponse = $serial->readPort();
$serial->deviceClose();
 
$toReturn = trim(preg_replace('/\s+/', ' ', $devResponse));
if(strpos($toReturn, "Thank you for doing your part") !== false){ // have sent more than 20 signals
$toReturn = trim(string_between_two_string($toReturn, 'Shared the Signal: ', 'Thank you for doing your part'));
}else{
$toReturn = trim(string_between_two_string($toReturn, 'Shared the Signal: ', 'se try again'));
if(strpos($toReturn, "Shared the Signal") !== false){ // are sharing the signal
if(strpos($toReturn, "Thank you for doing your part") !== false){ // have sent more than 20 signals
$toReturn = trim(string_between_two_string($toReturn, 'Shared the Signal: ', 'Thank you for doing your part'));
}else{
$toReturn = trim(string_between_two_string($toReturn, 'Shared the Signal: ', 'se try again'));
}
//echo $toReturn; // DEBUG
}else{ // you havent collected all badge types
$toReturn = 0;
}
//echo $toReturn; // DEBUG
 
return $toReturn;
}
function string_between_two_string($str, $starting_word, $ending_word){
$subtring_start = strpos($str, $starting_word);
Buy Me A Coffee