forked from pokepark/PokemonRaidBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraid_list.php
66 lines (55 loc) · 1.84 KB
/
raid_list.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
<?php
/**
* Raid list.
* @param $update
*/
function raid_list($update)
{
// Init empty rows array and query type.
$rows = [];
// Init raid id.
$iqq = 0;
// Botname:raid_id received?
if (substr_count($update['inline_query']['query'], ':') == 1) {
// Botname: received, is there a raid_id after : or not?
if(strlen(explode(':', $update['inline_query']['query'])[1]) != 0) {
// Raid ID.
$iqq = intval(explode(':', $update['inline_query']['query'])[1]);
}
}
// Inline list polls.
if ($iqq != 0) {
// Raid by ID.
$rows[0] = get_raid($iqq);
} else {
// Get raid data by user.
$request = my_query(
"
SELECT id
FROM raids
WHERE user_id = {$update['inline_query']['from']['id']}
AND end_time>UTC_TIMESTAMP()
ORDER BY id DESC LIMIT 2
"
);
while ($answer_raids = $request->fetch()) {
$rows[] = get_raid($answer_raids['id']);
}
}
// Init array.
$contents = array();
// For each rows.
foreach ($rows as $key => $row) {
// Get raid poll.
$contents[$key]['text'] = show_raid_poll($row, true)['full'];
// Set the title.
$contents[$key]['title'] = get_local_pokemon_name($row['pokemon'],$row['pokemon_form'], true) . ' ' . getPublicTranslation('from') . ' ' . dt2time($row['start_time']) . ' ' . getPublicTranslation('to') . ' ' . dt2time($row['end_time']);
// Get inline keyboard.
$contents[$key]['keyboard'] = keys_vote($row);
// Set the description.
$contents[$key]['desc'] = strval($row['gym_name']);
}
debug_log($contents);
answerInlineQuery($update['inline_query']['id'], $contents);
}
?>