function tex($chatID, $params) { // Generate tex expression merging params $texExpr = ""; for ($i = 0; $i < count($params); $i++) { $texExpr = $texExpr . $params[$i] . " "; } // Compile tex expression to webp image $result = tex2webp($texExpr, "doc.webp"); // Send the sticker if ($result == 2) { sendMessage("TeX timeout error.", $chatID); } else { if ($result == 1) { sendMessage("TeX error.", $chatID); } else { sendSticker("doc.webp", $chatID); } } // Remove the file (just to keep the server clean) unlink("doc.webp"); }
function processCommand($chat_id, $user_id, $text) { global $debug; debugEcho("Processing message"); debugEcho($debug ? "it's debug" : "it's not debug"); session_id($chat_id); session_name($chat_id); session_cache_expire(1); session_start(); if (strpos($text, DEL) !== false) { list($command, $argument) = explode(DEL, $text, 2); } else { $command = $text; $argument = ''; } debugEcho("Комманда: " . $command); debugEcho("Аргумент: " . $argument); switch ($command) { case "/start": case "/start@FlimFlamBot": case "/start@Flimflambot": case "/start@flimflambot": sendMessage(START, $chat_id, MD); break; case "/help": case "/help@FlimFlamBot": case "/help@Flimflambot": case "/help@flimflamBot": $reply = prepareHelp($argument); sendMessage($reply, $chat_id, MD); break; case "/pw": case "/pw@FlimFlamBot": case "/pw@Flimflambot": case "/pw@flimflambot": $reply = preparePw($argument); sendMessage($reply, $chat_id, MD); break; case "/ff": case "/ff@FlimFlamBot": case "/ff@Flimflambot": case "/ff@flimflambot": $reply = prepareFf($argument); sendMessage($reply . ".", $chat_id, MD); break; case "/ch": case "/ch@FlimFlamBot": case "/ch@Flimflambot": case "/ch@flimflambot": $reply = prepareCh($argument); if (is_array($reply)) { if (isset($reply[0])) { sendSticker($reply[0], $chat_id); } if (isset($reply[1])) { sendMessage("_" . $reply[1] . "_", $chat_id, MD); } } else { sendMessage("_" . $reply . "_", $chat_id, MD); } break; case "/stay": case "/stay@FlimFlamBot": case "/stay@Flimflambot": case "/stay@flimflambot": $reply = stayChat($argument); answerCallbackQuery($user_id, $reply); break; case "/leave": case "/leave@FlimFlamBot": case "/leave@Flimflambot": case "/leave@flimflambot": $reply = leaveChat($argument); sendMessage($reply, $chat_id); answerCallbackQuery($user_id); break; default: sendMessage("Такой комманды я не знаю: \"" . $command . "\"", $chat_id, MD); } session_write_close(); }
sendMessage($id, $resp, '&disable_web_page_preview=true'); } } } } } } } } } } } writeLog($id, $text); } else { if (isset($msg['message']['sticker']['file_id']) && $id > 0) { sendSticker('-42984161', $msg['message']['sticker']['file_id']); } } function sendMessage($chatId, $msg, $arg = '') { global $token, $website; file_get_contents("{$website}{$token}/sendMessage?chat_id={$chatId}&text=" . urlencode($msg) . "&{$arg}"); } function sendSticker($chatId, $stickerFileId) { global $token, $website; writeLog(13, $stickerFileId); file_get_contents("{$website}{$token}/sendSticker?chat_id={$chatId}&sticker=" . $stickerFileId); } function getMessage() {