Change badge labels

This commit is contained in:
Robert Miles 2018-07-08 12:59:09 -04:00
parent f1d8f98c15
commit a1690bf793
1 changed files with 3 additions and 3 deletions

View File

@ -1,14 +1,14 @@
<?php <?php
function get_badge($channel_name=FALSE) { function get_badge($channel_name=FALSE) {
if ($channel_name==FALSE) { if ($channel_name==FALSE) {
return "https://img.shields.io/badge/dynamic/json.svg?url=https://tilde.chat/stats.json&label=chat&query=$.usercount&suffix=%20online"; return "https://img.shields.io/badge/dynamic/json.svg?url=https://tilde.chat/stats.json&label=~chat&query=$.usercount&suffix=%20online";
} }
$stats = json_decode(file_get_contents("https://tilde.chat/stats.json")) ?? array("channels"=>[]); $stats = json_decode(file_get_contents("https://tilde.chat/stats.json")) ?? array("channels"=>[]);
foreach ($stats->channels as $key=>$channel) { foreach ($stats->channels as $key=>$channel) {
if ($channel->name==$channel_name) { if ($channel->name==$channel_name) {
return "https://img.shields.io/badge/dynamic/json.svg?url=https://tilde.chat/stats.json&label=chat&query=$.channels[$key].usercount&suffix=%20online"; return "https://img.shields.io/badge/dynamic/json.svg?url=https://tilde.chat/stats.json&label=~chat&query=$.channels[$key].usercount&suffix=%20online";
} }
} }
return "https://img.shields.io/badge/chat-invalid%20channel-red.svg"; return "https://img.shields.io/badge/~chat-invalid%20channel-red.svg";
} }
?> ?>