mirror of
https://github.com/jakejarvis/spoons.git
synced 2025-09-15 04:35:34 -04:00
update twilio hook for mysqli
This commit is contained in:
@@ -18,7 +18,7 @@ else
|
||||
|
||||
if(strlen($text) > strlen($command)) {
|
||||
$subject = substr($text, strlen($command) + 1);
|
||||
$subject_id = getIDByLooseName($subject);
|
||||
$subject_id = getIDByLooseName($subject, $conn);
|
||||
}
|
||||
|
||||
$help = 'List of commands:' . "\n" . '"Spoon (name)" to spoon.' . "\n" . '"Status (name)" to check.' . "\n" . '"Remaining" for number of alive spooners.';
|
||||
@@ -28,23 +28,25 @@ if($subject && $subject_id == "multiple") {
|
||||
} else if($subject && $subject_id == "none") {
|
||||
$response = "There were no spooners by the name " . $subject . " found in the system. Sorry (but not really).";
|
||||
} else if($subject && strcasecmp($command, "spoon") == 0) {
|
||||
spoonByID($subject_id);
|
||||
$response = getNameByID($subject_id) . ' has been spooned! ' . getNameByID(getSpoonedByIDByID($subject_id)) . '\'s new target is ' . getNameByID(getTargetByID(getSpoonedByIDByID($subject_id))) . '.';
|
||||
spoonByID($subject_id, $conn);
|
||||
$response = getNameByID($subject_id, $conn) . ' has been spooned! ' . getNameByID(getSpoonedByIDByID($subject_id, $conn), $conn) . '\'s new target is ' . getNameByID(getTargetByID(getSpoonedByIDByID($subject_id, $conn), $conn), $conn) . '.';
|
||||
} else if($subject && strcasecmp($command, "status") == 0) {
|
||||
if(checkSpoonedByID($subject_id)) {
|
||||
$response = getNameByID($subject_id) . ' was spooned by ' . getNameByID(getSpoonedByIDByID($subject_id)) . ' on ' . date('l', strtotime(getTimeSpoonedByID($subject_id))) . ' at ' . date('g:i A', strtotime(getTimeSpoonedByID($subject_id))) . '.';
|
||||
if(checkSpoonedByID($subject_id, $conn)) {
|
||||
$response = getNameByID($subject_id, $conn) . ' was spooned by ' . getNameByID(getSpoonedByIDByID($subject_id, $conn), $conn) . ' on ' . date('l', strtotime(getTimeSpoonedByID($subject_id, $conn))) . ' at ' . date('g:i A', strtotime(getTimeSpoonedByID($subject_id, $conn))) . '.';
|
||||
} else {
|
||||
$response = getNameByID($subject_id) . ' has not been spooned. ' . getFirstNameByID($subject_id) . '\'s target is ' . getNameByID(getTargetByID($subject_id)) . ' and is targeted by ' . getNameByID(getReverseTargetByID($subject_id)) . '.';
|
||||
$response = getNameByID($subject_id, $conn) . ' has not been spooned. ' . getFirstNameByID($subject_id, $conn) . '\'s target is ' . getNameByID(getTargetByID($subject_id, $conn), $conn) . ' and is targeted by ' . getNameByID(getReverseTargetByID($subject_id, $conn), $conn) . '.';
|
||||
}
|
||||
} else if(strcasecmp($command, "remaining") == 0) {
|
||||
$response = "There are " . getNumActiveSpooners() . " of " . getNumTotalSpooners() . " spooners remaining. (" . getNumActiveCamperSpooners() . " campers, " . getNumActiveStaffSpooners() . " staff)";
|
||||
$response = "There are " . getNumActiveSpooners($conn) . " of " . getNumTotalSpooners($conn) . " spooners remaining. (" . getNumActiveCamperSpooners($conn) . " campers, " . getNumActiveStaffSpooners($conn) . " staff)";
|
||||
} else if(strcasecmp($command, "commands") == 0 || strcasecmp($command, "command") == 0) {
|
||||
$response = $help;
|
||||
} else {
|
||||
$response = "Invalid command. " . $help;
|
||||
}
|
||||
|
||||
logSMS($_REQUEST['Body'], $response, $_REQUEST['From']);
|
||||
logSMS($_REQUEST['Body'], $response, $_REQUEST['From'], $conn);
|
||||
|
||||
mysqli_close($conn);
|
||||
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>';
|
||||
?>
|
||||
|
Reference in New Issue
Block a user