Exemplo n.º 1
0
 if (strpos($tg->getText(), "/") === 0) {
     $command = strtolower(ltrim($tg->getCommand()["command"], "/"));
     if (isset($commandAlias[$command])) {
         $command = $commandAlias[$command];
     }
     if (in_array($command, $availableCommands)) {
         include_once "commands/" . $command . ".php";
     }
 } else {
     if ($tg->getChatType() == "private") {
         // Special commands/action on private messages?
     } else {
         // Normal message. Add to statistics
     }
 }
 echo $tg->webhookAnswer();
 // Chat statistics
 if (!file_exists("data/stats/st" . $tg->getChatID() . ".json")) {
     file_put_contents("data/stats/st" . $tg->getChatID() . ".json", json_encode([]));
 }
 $stats = json_decode(file_get_contents("data/stats/st" . $tg->getChatID() . ".json"), true);
 if (!isset($stats[$tg->getUserID()])) {
     $stats[$tg->getUserID()] = ["messages" => 1, "date" => time(), "username" => $tg->getUserName()];
 } else {
     if (is_numeric($stats[$tg->getUserID()])) {
         $stats[$tg->getUserID()] = ["messages" => $stats[$tg->getUserID()]];
         unset($stats[$tg->getUserID() . "_date"]);
         unset($stats[$tg->getUserID() . "_username"]);
     }
     $stats[$tg->getUserID()] = ["messages" => intval($stats[$tg->getUserID()]["messages"]) + 1, "date" => time(), "username" => $tg->getUserName()];
 }