forked from pokepark/PokemonRaidBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow_raid_poll_small.php
72 lines (63 loc) · 2.18 KB
/
show_raid_poll_small.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* Show small raid poll.
* @param $raid
* @param $override_language
* @return string
*/
function show_raid_poll_small($raid, $override_language = false)
{
// Build message string.
$msg = '';
// Gym Name
if(!empty($raid['gym_name'])) {
$msg .= '<b>' . $raid['gym_name'] . '</b>' . CR;
}
// Address found.
if (!empty($raid['address'])) {
$msg .= '<i>' . $raid['address'] . '</i>' . CR2;
}
// Pokemon
if(!empty($raid['pokemon'])) {
$msg .= '<b>' . get_local_pokemon_name($raid['pokemon'], $raid['pokemon_form']) . '</b> ' . CR;
}
// Start time and end time
if(!empty($raid['start_time']) && !empty($raid['end_time'])) {
// Get raid times message.
$msg .= get_raid_times($raid, $override_language);
}
// Count attendances
$rs = my_query(
"
SELECT count(attend_time) AS count,
sum(remote = 0) AS count_in_person,
sum(remote = 1) AS count_remote,
sum(extra_alien) AS extra_alien
FROM attendance
LEFT JOIN users
ON attendance.user_id = users.user_id
WHERE raid_id = {$raid['id']}
AND attend_time IS NOT NULL
AND raid_done != 1
AND cancel != 1
"
);
$row = $rs->fetch();
// Add to message.
if ($row['count'] > 0) {
// Count by team.
$count_in_person = $row['count_in_person'];
$count_remote = $row['count_remote'];
$extra_alien = $row['extra_alien'];
// Add to message.
$msg .= EMOJI_GROUP . '<b> ' . ($row['count'] + $row['count_in_person'] + $row['count_remote'] + $row['extra_alien']) . '</b> — ';
$msg .= (($count_in_person > 0) ? EMOJI_IN_PERSON . $count_in_person . ' ' : '');
$msg .= (($count_remote > 0) ? EMOJI_REMOTE . $count_remote . ' ' : '');
$msg .= (($extra_alien > 0) ? EMOJI_ALIEN . $extra_alien . ' ' : '');
$msg .= CR;
} else {
$msg .= getTranslation('no_participants') . CR;
}
return $msg;
}
?>