Ejemplo n.º 1
0
switch ($text) {
    case "help":
        $response = "These are the things you can ask me:\n" . "help => this info\n" . "remove me => remove my phone number from the system\n" . "send me a photo => invite system to send a photo\n" . "tell me a joke => I send to you something funny\n" . "say me the time => I send to you the current time on my timezone\n" . "weather => I send to you the weather where I live\n";
        break;
    case "weather":
        $weather = new OpenWeatherApi();
        $response = $weather->getWeatherInfoAsString();
        break;
    case "say me the time":
        $response = sprintf("The current time here is %s", date("l, F jS Y h:ia"));
        break;
    case "tell me a joke":
        $response = IcndbApi::getAJoke();
        break;
    case "remove me":
        $t->msg($user->phone, "You have been deleted from my contact list");
        $t->del_contact($user->phone);
        $userStorage->remove($user->phone);
        unset($_SESSION['user']);
        header("location: index.php");
        die;
        break;
    case "send me a photo":
        $t->send_photo($user->phone, MediaSelector::getRandomPicture());
        break;
    default:
        $response = "I'm so sorry.\nI'm not ready yet to understand you";
        break;
}
$t->msg($user->phone, $response);
return Response::ok();