site for the tildeverse irc network https://tilde.chat
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

16 lines
938 B

<?php
function get_badge($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&link=https:%2F%2Ftilde.chat&link=https:%2F%2Fkiwi.tilde.chat&colorB=%2300cc00";
}
$name_url = urlencode($channel_name);
$name_link = urlencode(substr($channel_name,1));
$stats = json_decode(file_get_contents("https://tilde.chat/stats.json")) ?? array("channels"=>[]);
foreach ($stats->channels as $key=>$channel) {
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%20on%20{$name_url}&link=https:%2F%2Ftilde.chat&link=https:%2F%2Fkiwi.tilde.chat%2F{$name_link}&colorB=%2300cc00";
}
}
return "https://img.shields.io/badge/~chat-invalid%20channel-red.svg";
}
?>