forked from tildeverse/tilde.chat
Add links to badges
This commit is contained in:
parent
b4c6d97783
commit
9cac6b7714
@ -1,13 +1,14 @@
|
||||
<?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";
|
||||
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%2Fweb.tilde.chat";
|
||||
}
|
||||
$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}";
|
||||
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%2Fweb.tilde.chat%2F%3Fjoin%3D{$name_link}";
|
||||
}
|
||||
}
|
||||
return "https://img.shields.io/badge/~chat-invalid%20channel-red.svg";
|
||||
|
Loading…
Reference in New Issue
Block a user