Skip to content

Commit

Permalink
Added proper form handling to /pokemon-command and minor fixes to red…
Browse files Browse the repository at this point in the history
…uce the ammount of PHP notices (pokepark#165)

* Fixed getDB to use a proto file that isn't deprecated

* Added proper form handling to /pokemon-command and minor fixes to reduce the ammount of PHP notices
  • Loading branch information
Ninjasoturi authored Aug 28, 2020
1 parent 8783e9c commit de32432
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.240.1
2.0.240.2
2 changes: 1 addition & 1 deletion commands/pokemon.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
$text .= get_local_pokemon_name($row['pokemon'], $row['pokemon_form']) . SP . '' . SP . (($raid_day == $today) ? '' : ($raid_day . ', ')) . $start . SP . getTranslation('to') . SP . $end . CR . CR;
$keys[] = array(
'text' => $keys_text,
'callback_data' => $row['id'] . ':raid_edit_poke:' . $row['pokemon'],
'callback_data' => $row['id'] . ':raid_edit_poke:' . $row['pokemon'].'-'.$row['pokemon_form'],
);

// Counter++
Expand Down
2 changes: 1 addition & 1 deletion config/config.json.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"VERSION":"2.0.240.1",
"VERSION":"2.0.240.2",
"DB_HOST":"localhost",
"DB_NAME":"your_database_name",
"DB_USER":"your_database_user",
Expand Down
2 changes: 1 addition & 1 deletion logic/alarm.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function alarm($raid, $user, $action, $info = '')
sendalarm($msg_text, $raid, $user);
// Any pokemon
} else {
$msg_text = '<b>' . getTranslation('alert_every_poke') . SP . $poke_name . '</b>' . CR;
$msg_text = '<b>' . getTranslation('alert_every_poke') . '</b>' . CR;
$msg_text .= EMOJI_HERE . SP . $gymname . SP . '(' . $raidtimes . ')' . CR;
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
$msg_text .= EMOJI_CLOCK . SP . check_time($attendtime);
Expand Down
9 changes: 3 additions & 6 deletions logic/show_raid_poll.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function show_raid_poll($raid)
// Get current pokemon
$raid_pokemon_id = $raid['pokemon'];
$raid_pokemon_form = $raid['pokemon_form'];
$raid_pokemon_form_name = get_pokemon_form_name($raid_pokemon_id, $raid_pokemon_form);
($raid_pokemon_form != 0) ? $raid_pokemon_form_name = get_pokemon_form_name($raid_pokemon_id, $raid_pokemon_form) : $raid_pokemon_form_name = '';
$raid_pokemon = $raid_pokemon_id . "-" . $raid_pokemon_form;

// Get raid level
Expand Down Expand Up @@ -267,10 +267,6 @@ function show_raid_poll($raid)
$current_att_time = $row['ts_att'];
$dt_att_time = dt2time($row['attend_time']);
$current_pokemon = $row['pokemon'];

$poke = explode("-",$current_pokemon);
$current_pokemon_id = $poke[0];
$current_pokemon_form = $poke[1];

// Add hint for remote attendances.
if($config->RAID_REMOTEPASS_USERS && $previous_att_time == 'FIRST_RUN' && $cnt_remote > 0) {
Expand Down Expand Up @@ -329,7 +325,8 @@ function show_raid_poll($raid)
// Show attendances when multiple pokemon are selected, unless all attending users voted for the raid boss + any pokemon
if($count_all != ($count_any_pokemon + $count_raid_pokemon)) {
// Add pokemon name.
$msg = raid_poll_message($msg, ($current_pokemon == 0) ? ('<b>' . getPublicTranslation('any_pokemon') . '</b>') : ('<b>' . get_local_pokemon_name($current_pokemon_id,$current_pokemon_form, true) . '</b>'));
$pokemon_id_form = explode("-",$current_pokemon);
$msg = raid_poll_message($msg, ($current_pokemon == 0) ? ('<b>' . getPublicTranslation('any_pokemon') . '</b>') : ('<b>' . get_local_pokemon_name($pokemon_id_form[0],$pokemon_id_form[1], true) . '</b>'));

// Attendance counts by team.
$current_att_time_poke = $cnt_pokemon[$current_att_time . '_' . $current_pokemon];
Expand Down
8 changes: 5 additions & 3 deletions mods/raid_set_poke.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@

// Set the id.
$id = $data['id'];
$pokemon_id_form = explode("-", $data['arg']);

// Update pokemon in the raid table.
my_query(
"
UPDATE raids
SET pokemon = '{$data['arg']}'
SET pokemon = '{$pokemon_id_form[0]}',
pokemon_form = '{$pokemon_id_form[1]}'
WHERE id = {$id}
"
);
Expand Down Expand Up @@ -81,7 +83,7 @@
if($config->RAID_PICTURE) {
require_once(LOGIC_PATH . '/raid_picture.php');
while ($raidmsg = $rs->fetch()) {
$picture_url = $raid_picture_url($raid);
$picture_url = raid_picture_url($raid);
$tg_json[] = editMessageMedia($raidmsg['message_id'], $updated_msg['short'], $updated_keys, $raidmsg['chat_id'], ['disable_web_page_preview' => 'true'], false, $picture_url);
}
} else {
Expand All @@ -98,7 +100,7 @@
$raidtimes = str_replace(CR, '', str_replace(' ', '', get_raid_times($raid, false, true)));
$msg_text = '<b>' . getTranslation('alert_raid_boss') . '</b>' . CR;
$msg_text .= EMOJI_HERE . SP . $raid['gym_name'] . SP . '(' . $raidtimes . ')' . CR;
$msg_text .= EMOJI_EGG . SP . '<b>' . get_local_pokemon_name($raid['pokemon']) . '</b>' . CR;
$msg_text .= EMOJI_EGG . SP . '<b>' . get_local_pokemon_name($raid['pokemon'], $raid['pokemon_form']) . '</b>' . CR;
sendalarm($msg_text, $id, $update['callback_query']['from']['id']);

// Exit.
Expand Down

0 comments on commit de32432

Please sign in to comment.