Created
June 16, 2018 00:01
-
-
Save Wruczek/02113179c249768c020ffd25a98907ab to your computer and use it in GitHub Desktop.
This simple PHP script lets you know the time of your VAC ban with ± 30 second precision. Valve shows only the "days since last ban" on your profile, but not the precise time. This script watches when the number of days changes and sends you a Telegram message. With this, you know precisely when the number of days change on the steam page = when…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$saveFile = __DIR__ . "/vacwatch.txt"; | |
$steamApiKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; | |
$steamProfileIds = [765611984466XXXXX, 765611981505XXXXX]; | |
$telegramBotToken = "376243970:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; | |
$telegramChatId = "-1001135186648"; | |
$apiUrl = "https://api.steampowered.com/ISteamUser/GetPlayerBans/v1/?key=$steamApiKey&steamids=" . implode(",", $steamProfileIds); | |
// Create file if it doesnt exists | |
if (!file_exists($saveFile)) { | |
touch($saveFile) or die("cannot create $saveFile"); | |
} | |
while (true) { | |
$responseArray = json_decode(file_get_contents($apiUrl), true)["players"]; | |
$saveFileArray = json_decode(file_get_contents($saveFile), true); | |
foreach ($steamProfileIds as $profileId) { | |
if (getProfile($responseArray, $profileId) != getProfile($saveFileArray, $profileId)) { | |
// Nicely formatted array to JSON string | |
$responseText = json_encode($responseArray, JSON_PRETTY_PRINT); | |
// Send telegram message | |
$data = [ | |
"text" => "```\n$responseText\n```", | |
"chat_id" => $telegramChatId, | |
"parse_mode" => "Markdown" | |
]; | |
file_get_contents("https://api.telegram.org/bot$telegramBotToken/sendMessage?" . http_build_query($data)); | |
// Save the new data | |
file_put_contents($saveFile, $responseText); | |
// Stop checking for changes in this iteration | |
break; | |
} | |
} | |
// Wait 30 seconds before next check | |
sleep(30); | |
} | |
function getProfile($playersArray, $profileId) { | |
foreach ($playersArray as $player) { | |
if ($player["SteamId"] == $profileId) | |
return $player; | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment