/* ************************************************** Random array of responses for use by the bot (so the user knows their chat was received and is being processed) ************************************************** */ function makeHangOnString($strRequestType) { $aH = array("Sure thing, lemme build that {$strRequestType} for you. Hang on a sec...", "Let me get that {$strRequestType} for you, hang on a sec...", "Let me get that {$strRequestType} for you, hang tight...", "One {$strRequestType} coming right up, just a sec...", "Gotta put that {$strRequestType} together, hold on...", "Let me look that up and make a {$strRequestType} for you, hold on...", "Got it, lemme get the info for a {$strRequestType}. Hold on..."); return aRand($aH); } if (!iStr($p['name'], array('WordBot'))) { // This post wasn't made by the bot, so we'll continue (prevents infinite loop) if (strlen(trim($p['text'])) == 1) { $p['text'] = trim($p['text']); if (ctype_alpha($p['text'])) { if (validGuess($p['user_id'], strtolower($p['text']))) { makeGuess($p['user_id'], strtolower($p['text'])); $strResponse = displayGame($p['user_id']); sleep(1); $groupMe->botPost($groupId, $botId, $p['name'] . "\n" . $strResponse); } else { sleep(1); $groupMe->botPost($groupId, $botId, "Hey " . $p['name'] . "! That's not a valid guess!" . $strResponse); } } else { sleep(1); $groupMe->botPost($groupId, $botId, "Hey " . $p['name'] . "! Letters only please!" . $strResponse); } } // Did the user mention the bot by name? Check multiple variations of the bot's name if (iStr($text, array("wordbot", "word bot", "hangbot5000"))) { /* **************************************************
$_SESSION['word'] = $_POST['word']; } if (!isset($_SESSION['word'])) { //Om vi inte valt ord printChooseWordForm(); $_SESSION['lifes'] = 5; } else { //om vi valt ord printGuessForm(); $word = $_SESSION['word']; if (isset($_POST['guess'])) { $guess = $_POST['guess']; } else { $guess = NULL; } makeGuess($word, $guess); printLifes(); printWord($word, $_SESSION['guesses']); gameCheck(); } ### FUNCTIONS ### function gameCheck() { if (strlen($_SESSION['word']) == count($_SESSION['guesses'])) { echo "Du vann!"; resetGame(); } elseif ($_SESSION['lifes'] == 0) { echo "Du förlorade!"; resetGame(); } }