prepare('SELECT c.*, cp.*
FROM channels c
LEFT JOIN channel_preferences cp ON cp.id = c.id
WHERE c.alias_id = ?
');
$stmt->execute([$_GET['alias_id']]);
$channel = $stmt->fetch(PDO::FETCH_ASSOC) ?: null;
if (!isset($channel)) {
http_response_code(404);
exit;
}
// fetching custom commands
$stmt = $db->prepare('SELECT *
FROM custom_commands
WHERE channel_id = ?
');
$stmt->execute([$channel['id']]);
$channel['commands'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
// fetching timers
$stmt = $db->prepare('SELECT *
FROM timers
WHERE channel_id = ?
');
$stmt->execute([$channel['id']]);
$channel['timers'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
// fetching events
$stmt = $db->prepare('SELECT e.*, COUNT(es.id) as subscription_count
FROM events e
LEFT JOIN event_subscriptions es ON es.event_id = e.id
WHERE e.channel_id = ?
GROUP BY e.id
ORDER BY subscription_count DESC
');
$stmt->execute([$channel['id']]);
$channel['events'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
// fetching event names
$twitch_types = [0, 1, 2, 3, 8];
$channel_ids = [];
foreach ($channel['events'] as &$e) {
if (in_array($e['event_type'], $twitch_types)) {
array_push($channel_ids, $e['name']);
}
$e['event_type_translated'] = match ($e['event_type']) {
0 => 'Live (Twitch)',
1 => 'Offline (Twitch)',
2 => 'Title change (Twitch)',
3 => 'Game change (Twitch)',
4 => 'Live (Kick)',
5 => 'Offline (Kick)',
6 => 'Title change (Kick)',
7 => 'Game change (Kick)',
8 => 'Chat message (Twitch)',
10 => 'Emote creation (7TV)',
11 => 'Emote deletion (7TV)',
12 => 'Emote update (7TV)',
13 => 'Emote creation (BTTV)',
14 => 'Emote deletion (BTTV)',
15 => 'Emote update (BTTV)',
40 => 'GitHub',
default => 'Custom'
};
}
unset($e);
if (!empty($channel_ids)) {
$event_users = get_twitch_users(implode('&id=', $channel_ids));
foreach ($event_users as $user) {
foreach ($channel['events'] as &$e) {
if ($e['name'] == $user['id']) {
$e['name'] = $user['login'];
}
}
unset($e);
}
}
if ($response = get_twitch_users($channel['alias_id'])) {
$user = $response[0];
$channel['pfp'] = $user['profile_image_url'];
$channel['description'] = $user['description'] ?: null;
}
$has_content = !empty($channel['events']) || !empty($channel['commands']) || !empty($channel['timers']);
} else if (!SHOW_CHANNEL_LIST) {
http_response_code(403);
exit;
} else {
$stmt = $db->query('SELECT c.alias_id, c.alias_name FROM channels c
INNER JOIN channel_preferences cp ON cp.id = c.id
WHERE c.opted_out_at IS NULL AND cp.silent_mode = FALSE ORDER BY c.joined_at DESC');
$stmt->execute();
$channels = $stmt->fetchAll(PDO::FETCH_ASSOC) ?: [];
}
// fetching user pfps
if (!empty($channels)) {
$channel_ids = [];
foreach ($channels as $c) {
array_push($channel_ids, $c['alias_id']);
}
$response = get_twitch_users(implode('&id=', $channel_ids));
if (!empty($response)) {
foreach ($response as $c) {
$index = array_search($c['id'], array_column($channels, 'alias_id'));
$channels[$index]['pfp'] = $c['profile_image_url'];
}
}
}
?>
= $channel['alias_name'] ?>
Channels
- = BOT_USERNAME_FORMATTED ?>
About = $channel['alias_name'] ?>
= $channel['description'] ?>
Language:
= ucfirst($channel['language']) ?>
Prefix: = $channel['prefix'] ?>
Silent mode
Joined
= format_timestamp(time() - strtotime($channel['joined_at'])) ?> ago
Opted out!
Events
| Name |
Type |
Message |
Massping |
Subscribers |
|
= $e['name'] ?>
= $e['name'] ?>
= $e['name'] ?>
|
= $e['event_type_translated'] ?> |
= $e['message'] ?> |
= $e['is_massping'] ? '✅' : '❌' ?> |
= $e['subscription_count'] ?> |
Custom commands
| Name |
Message |
| = $c['name'] ?> |
= $c['message'] ?> |
Timers
| Name |
Message |
Interval |
Last executed |
| = $t['name'] ?> |
= $t['message'] ?> |
= format_timestamp($t['interval_sec']) ?> |
= format_timestamp(time() - strtotime($t['last_executed_at'])) ?> ago |
Nothing found...