1 && $argv[1] == "--print-json-command-list") { $out = []; foreach($commands as $k => $v) $out[] = ["command"=>$v["command"],"description"=>$v["description"]]; echo json_encode(array_values($out)); exit(0); } // 2. PROCESS COMMAND extract(json_decode(file_get_contents('php://stdin'),1)["message"]); // from, chat, date, text $submitted_cmd = explode(" ",$text)[0]; if (isset($commands[$submitted_cmd])) { $commands[$submitted_cmd]["callback"]($from, $chat, $date, $text); }