forked from pokepark/PokemonRaidBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEW: Set shiny (or not shiny) via /pokedex :)
🎁 Merry X-MAS everyone! 🎁
- Loading branch information
Showing
10 changed files
with
219 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.0.357.4 | ||
2.0.359.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* Get pokemon shiny status. | ||
* @param $pokemon_id | ||
* @param $pokemon_form_id | ||
* @return string | ||
*/ | ||
function get_pokemon_shiny_status($pokemon_id, $pokemon_form_id) | ||
{ | ||
if($pokemon_id !== "NULL" && $pokemon_id != 0) { | ||
// Get pokemon shiny status from database | ||
$rs = my_query( | ||
" | ||
SELECT shiny | ||
FROM pokemon | ||
WHERE pokedex_id = {$pokemon_id} | ||
AND pokemon_form_id = '{$pokemon_form_id}' | ||
" | ||
); | ||
|
||
// Fetch the row. | ||
$shiny = $rs->fetch(); | ||
debug_log($shiny, 'Per db, shiny status is:'); | ||
|
||
return $shiny['shiny']; | ||
} else { | ||
return 0; | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?php | ||
// Write to log. | ||
debug_log('pokedex_set_shiny()'); | ||
|
||
// For debug. | ||
//debug_log($update); | ||
//debug_log($data); | ||
|
||
// Check access. | ||
bot_access_check($update, 'pokedex'); | ||
|
||
// Set the id. | ||
$pokedex_id = $data['id']; | ||
|
||
// Get the shiny status. | ||
$arg = $data['arg']; | ||
|
||
// Split pokedex_id and form | ||
$dex_id_form = explode('-',$pokedex_id,2); | ||
$dex_id = $dex_id_form[0]; | ||
$dex_form = $dex_id_form[1]; | ||
|
||
// Set shiny or ask to set? | ||
if($data['arg'] == "setshiny") { | ||
// Get current shiny status from database. | ||
$shiny = get_pokemon_shiny_status($dex_id, $dex_form); | ||
|
||
// Init empty keys array. | ||
$keys = []; | ||
|
||
// Create keys array. | ||
if($shiny == 0) { | ||
// Enable shiny. | ||
$old_shiny_status = getTranslation('not_shiny'); | ||
$keys[] = [ | ||
array( | ||
'text' => getTranslation('shiny'), | ||
'callback_data' => $pokedex_id . ':pokedex_set_shiny:1' | ||
) | ||
]; | ||
|
||
} else { | ||
// Disable shiny. | ||
$old_shiny_status = getTranslation('shiny'); | ||
$keys[] = [ | ||
array( | ||
'text' => getTranslation('not_shiny'), | ||
'callback_data' => $pokedex_id . ':pokedex_set_shiny:0' | ||
) | ||
]; | ||
} | ||
|
||
// Back and abort. | ||
$keys[] = [ | ||
[ | ||
'text' => getTranslation('back'), | ||
'callback_data' => $pokedex_id . ':pokedex_edit_pokemon:0' | ||
], | ||
[ | ||
'text' => getTranslation('abort'), | ||
'callback_data' => '0:exit:0' | ||
] | ||
]; | ||
|
||
// Build callback message string. | ||
$callback_response = getTranslation('select_shiny_status'); | ||
|
||
// Set the message. | ||
$msg = getTranslation('raid_boss') . ': <b>' . get_local_pokemon_name($dex_id, $dex_form) . ' (#' . $dex_id . ')</b>' . CR; | ||
$msg .= getTranslation('pokedex_current_status') . SP . $old_shiny_status . CR . CR; | ||
$msg .= '<b>' . getTranslation('pokedex_new_status') . ':</b>'; | ||
} else { | ||
// Update shiny status of pokemon. | ||
$rs = my_query( | ||
" | ||
UPDATE pokemon | ||
SET shiny = '{$arg}' | ||
WHERE pokedex_id = {$dex_id} | ||
AND pokemon_form_id = '{$dex_form}' | ||
" | ||
); | ||
|
||
// Init empty keys array. | ||
$keys = []; | ||
|
||
// Back to pokemon and done keys. | ||
$keys = [ | ||
[ | ||
[ | ||
'text' => getTranslation('back') . ' (' . get_local_pokemon_name($dex_id, $dex_form) . ')', | ||
'callback_data' => $pokedex_id . ':pokedex_edit_pokemon:0' | ||
], | ||
[ | ||
'text' => getTranslation('done'), | ||
'callback_data' => '0:exit:1' | ||
] | ||
] | ||
]; | ||
|
||
// Build callback message string. | ||
$callback_response = getTranslation('pokemon_saved') . ' ' . get_local_pokemon_name($dex_id, $dex_form); | ||
|
||
// Set the message. | ||
$msg = getTranslation('pokemon_saved') . CR; | ||
$msg .= '<b>' . get_local_pokemon_name($dex_id, $dex_form) . ' (#' . $dex_id . ')</b>' . CR . CR; | ||
$msg .= getTranslation('pokedex_new_status') . ':' . CR; | ||
$msg .= '<b>' . (($arg == 1) ? (getTranslation('shiny')) : (getTranslation('not_shiny'))) . '</b>'; | ||
} | ||
|
||
// Telegram JSON array. | ||
$tg_json = array(); | ||
|
||
// Answer callback. | ||
$tg_json[] = answerCallbackQuery($update['callback_query']['id'], $callback_response, true); | ||
|
||
// Edit message. | ||
$tg_json[] = edit_message($update, $msg, $keys, false, true); | ||
|
||
// Telegram multicurl request. | ||
curl_json_multi_request($tg_json); | ||
|
||
// Exit. | ||
exit(); |