tidy up webhook

This commit is contained in:
Ben Harris 2020-06-17 13:45:52 -04:00
parent 4a80f45e1e
commit 53e64bb1eb
1 changed files with 13 additions and 5 deletions

View File

@ -1,14 +1,22 @@
<?php
$debug = false;
$input = file_get_contents("php://input");
$tilderadio = json_decode($input, true);
$json = json_decode(file_get_contents('php://input'));
if ($debug) {
$timestamp = date("c");
file_put_contents("$timestamp.json", $input);
print_r($tilderadio);
}
$msg = "";
if ($json->live->is_live)
$msg .= "({$json->live->streamer_name}) ";
if ($tilderadio["live"]["is_live"])
$msg .= "({$tilderadio["live"]["streamer_name"]}) ";
$msg .= "now playing: ";
$msg .= $json->now_playing->song->text . " ";
$msg .= "~~ {$json->listeners->current} listeners";
$msg .= $tilderadio["now_playing"]["song"]["text"] . " ";
$msg .= "~~ {$tilderadio["listeners"]["current"]} listeners";
echo $msg;
file_put_contents(__DIR__."/../now_playing.txt", $msg);