forked from Ninjasoturi/PokemonRaidBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpokedex.php
89 lines (81 loc) · 2.5 KB
/
pokedex.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
// Write to log.
debug_log('POKEDEX()');
// For debug.
//debug_log($update);
//debug_log($data);
// Check access.
bot_access_check($update, 'pokedex');
// Get pokemon name or dex id.
$pokemon = trim(substr($update['message']['text'], 8));
// Init empty keys array.
$keys = [];
// Check if we recived pokemon name or dex id.
if(!empty($pokemon)) {
// Pokedex_id received?
if(is_numeric($pokemon)) {
$pokedex_id = $pokemon;
// Pokemon name received?
} else {
$pokemon_name_form = get_pokemon_id_by_name($pokemon);
$pokedex_id = explode("-", $pokemon_name_form)[0];
}
$statement = $dbh->prepare("SELECT pokedex_id, pokemon_form_id FROM pokemon WHERE pokedex_id = :pokedex_id");
$statement->execute([":pokedex_id" => $pokedex_id]);
while ($pokemon = $statement->fetch()) {
$keys[] = [
[
'text' => get_local_pokemon_name($pokemon['pokedex_id'], $pokemon['pokemon_form_id']),
'callback_data' => $pokemon['pokedex_id'] . '-' . $pokemon['pokemon_form_id'] . ':pokedex_edit_pokemon:0'
]
];
}
// Set message.
$msg = '<b>' . getTranslation('pokedex_edit_pokemon') . '</b>';
}
if(count($keys) == 0 ) {
// Create keys array.
$keys = [
[
[
'text' => getTranslation('pokedex_raid_pokemon'),
'callback_data' => '0:pokedex_list_raids:0'
]
],
[
[
'text' => getTranslation('edit_pokemon'),
'callback_data' => '0:pokedex:0'
]
],
[
[
'text' => getTranslation('disable_raid_level'),
'callback_data' => '0:pokedex_disable_raids:0'
]
],
[
[
'text' => getTranslation('import') . SP . '(Pokebattler)',
'callback_data' => '0:pokebattler:0'
]
],
[
[
'text' => getTranslation('import') . SP . '(ccev pogoinfo)',
'callback_data' => '0:pogoinfo:0'
]
]
];
// Set message.
$msg = '<b>' . getTranslation('pokedex_start') . ':</b>';
}
$keys[] = [
[
'text' => getTranslation('abort'),
'callback_data' => '0:exit:0'
]
];
// Send message.
send_message($update['message']['chat']['id'], $msg, $keys, ['reply_markup' => ['selective' => true, 'one_time_keyboard' => true]]);
?>