Skip to content

Commit

Permalink
Merge branch 'ninjasoturi_ingest' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jinnatar committed Aug 23, 2021
2 parents cf78eef + 396f8f4 commit 3844454
Show file tree
Hide file tree
Showing 203 changed files with 8,347 additions and 6,038 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# These are supported funding model platforms

github: [florianbecker] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ README.md.*
/config/**
!/config/*.json.example
!/config/defaults-*.json
!/config/*.php.example

# Ignore several icon directories + their content
# Ignoring directories itself allows to replace them with symlinks
Expand Down
295 changes: 145 additions & 150 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.232.1
2.1.235.1
2 changes: 1 addition & 1 deletion commands/addgym.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
$msg = '<b>' . getTranslation('invalid_input') . '</b>' . CR . CR;
$msg .= getTranslation('gym_coordinates_format_error') . CR;
$msg .= getTranslation('gym_coordinates_format_example');
sendMessage($update['message']['chat']['id'], $msg);
send_message($update['message']['chat']['id'], $msg);
exit();
}

Expand Down
10 changes: 8 additions & 2 deletions commands/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@

// Count results.
$count = 0;

$own_sql = "";
$own_arr = [];
if(!bot_access_check($update, 'delete', true) && bot_access_check($update,'delete-own',true)) {
$own_sql = "AND users.user_id = :user_id";
$own_arr = [":user_id"=>$update['message']['from']['id']];
}
// Init text and keys.
$text = '';
$keys = [];
Expand All @@ -32,12 +37,13 @@
LEFT JOIN users ON raids.user_id = users.user_id
WHERE
raids.end_time > UTC_TIMESTAMP()
'.$own_sql.'
ORDER BY
raids.end_time ASC
LIMIT 20
';
$statement = $dbh->prepare( $query );
$statement->execute();
$statement->execute($own_arr);
while ($row = $statement->fetch()) {
// Set text and keys.
$text .= $row['gym_name'] . CR;
Expand Down
4 changes: 2 additions & 2 deletions commands/exreport.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
WHEN a.cancel = FALSE
OR a.raid_done = FALSE THEN
(
a.extra_mystic + a.extra_valor + a.extra_instinct + 1
a.extra_in_person + a.extra_alien + 1
)
ELSE
0
Expand All @@ -45,7 +45,7 @@
WHEN a.cancel = FALSE
OR a.raid_done = FALSE THEN
(
a.extra_mystic + a.extra_valor + a.extra_instinct + 1
a.extra_in_person + a.extra_alien + 1
)
ELSE
0
Expand Down
29 changes: 29 additions & 0 deletions commands/friendsearch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
// Write to log.
debug_log('FRIENDSEARCH()');

// For debug.
//debug_log($update);
//debug_log($data);

bot_access_check($update, 'friendsearch');

// Trim away everything before "/FRIENDSEARCH"
$searchterm = $update['message']['text'];
$searchterm = preg_replace('/[^A-Za-z0-9]/','', substr($searchterm, 14));

debug_log($searchterm, 'SEARCHTERM');

$query = "SELECT user_id, name, team, level, trainername FROM users WHERE trainername LIKE :tn";
$statement = $dbh->prepare( $query );
$statement->execute([':tn' => $searchterm]);
if($statement->rowCount() == 1) {
$result = $statement->fetch();
$msg = ($result['team'] === NULL) ? ($GLOBALS['teams']['unknown'] . ' ') : ($GLOBALS['teams'][$result['team']] . ' ');
$msg .= ($result['level'] == 0) ? ('<b>00</b> ') : (($result['level'] < 10) ? ('<b>0' . $result['level'] . '</b> ') : ('<b>' . $result['level'] . '</b> '));
$msg .= "<a href='tg://user?id=".$result['user_id']."'>".$result['name']." - ".$result['trainername']."</a>";
}else {
$msg = $searchterm.CR. getTranslation('trainer_not_found');
}
send_message($update['message']['chat']['id'], $msg, [], ['reply_markup' => ['selective' => true]]);
?>
2 changes: 1 addition & 1 deletion commands/gymgps.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
$msg = '<b>' . getTranslation('invalid_input') . '</b>' . CR . CR;
$msg .= getTranslation('gym_gps_coordinates_format_error') . CR;
$msg .= getTranslation('gym_gps_example');
sendMessage($update['message']['chat']['id'], $msg);
send_message($update['message']['chat']['id'], $msg);
exit();
}

Expand Down
20 changes: 19 additions & 1 deletion commands/help.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,31 @@
if($p == 'access-bot' || strpos($p, 'share-') === 0 || strpos($p, 'ignore-') === 0) continue;
$msg .= getTranslation('help_' . $p) . CR . CR;
}
} elseif($config->TUTORIAL_MODE) {
if(new_user($update['message']['from']['id'])) {
$msg = $tutorial[0]['msg_new'];
}else {
$msg = $tutorial[0]['msg'];
}
$keys = [
[
[
'text' => getTranslation('next'),
'callback_data' => '0:tutorial:0'
]
]
];
$photo = $tutorial[0]['photo'];
send_photo($update['message']['from']['id'],$photo, $msg, $keys, ['disable_web_page_preview' => 'true']);
exit();

// No help for the user.
} else {
$msg = getTranslation('bot_access_denied');
}

// Send message.
sendMessage($update['message']['from']['id'], $msg);
send_message($update['message']['from']['id'], $msg);

?>

25 changes: 25 additions & 0 deletions commands/history.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
// Write to log.
debug_log('HISTORY');

// For debug.
//debug_log($update);
//debug_log($data);

// Check access.
bot_access_check($update, 'history');

require_once(LOGIC_PATH .'/history.php');

$msg_keys = create_history_date_msg_keys();
if($msg_keys === false) {
$msg = getTranslation('history_no_raids_found');
$keys = [];
}else {
$msg = $msg_keys[0];
$keys = $msg_keys[1];
}

send_message($update['message']['chat']['id'], $msg, $keys, ['reply_markup' => ['selective' => true, 'one_time_keyboard' => true], 'disable_web_page_preview' => 'true']);

?>
61 changes: 56 additions & 5 deletions commands/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,66 @@
// Check access.
bot_access_check($update, 'list');

// Include
include(ROOT_PATH . '/logic/get_active_raids.php');

// Init text and keys.
$text = '';
$keys = [];

// Get raids.
$raids = get_active_raids();
$event_permissions = bot_access_check($update, 'event',true);

$tz_diff = tz_diff();

// Get last 12 active raids data.
$rs = my_query(
'
SELECT IF (raids.pokemon = 0,
IF((SELECT count(*)
FROM raid_bosses
WHERE raid_level = raids.level
AND convert_tz(raids.spawn,"+00:00","'.$tz_diff.'") BETWEEN date_start AND date_end) = 1,
(SELECT pokedex_id
FROM raid_bosses
WHERE raid_level = raids.level
AND convert_tz(raids.spawn,"+00:00","'.$tz_diff.'") BETWEEN date_start AND date_end),
(select concat(\'999\', raids.level) as pokemon)
)
,pokemon) as pokemon,
IF (raids.pokemon = 0,
IF((SELECT count(*) as count
FROM raid_bosses
WHERE raid_level = raids.level
AND convert_tz(raids.spawn,"+00:00","'.$tz_diff.'") BETWEEN date_start AND date_end) = 1,
(SELECT pokemon_form_id
FROM raid_bosses
WHERE raid_level = raids.level
AND convert_tz(raids.spawn,"+00:00","'.$tz_diff.'") BETWEEN date_start AND date_end),
\'0\'
),
IF(raids.pokemon_form = 0,
(SELECT pokemon_form_id FROM pokemon
WHERE
pokedex_id = raids.pokemon AND
pokemon_form_name = \'normal\'
LIMIT 1), raids.pokemon_form)
) as pokemon_form,
raids.id, raids.user_id, raids.start_time, raids.end_time, raids.gym_team, raids.gym_id, raids.level, raids.move1, raids.move2, raids.gender, raids.event, raids.event_note,
gyms.lat, gyms.lon, gyms.address, gyms.gym_name, gyms.ex_gym, gyms.gym_note,
start_time, end_time,
TIME_FORMAT(TIMEDIFF(end_time, UTC_TIMESTAMP()) + INTERVAL 1 MINUTE, \'%k:%i\') AS t_left,
(SELECT COUNT(*) FROM raids WHERE end_time>UTC_TIMESTAMP()) AS r_active
FROM raids
LEFT JOIN gyms
ON raids.gym_id = gyms.id
WHERE end_time>UTC_TIMESTAMP()
' . ($event_permissions ? '' : 'AND event IS NULL' ) . '
ORDER BY end_time ASC
LIMIT 12
'
);

// Get the raids.
$raids = $rs->fetchAll();

debug_log($raids);

// Did we get any raids?
if(isset($raids[0]['r_active'])) {
Expand Down
6 changes: 6 additions & 0 deletions commands/pokedex.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
'callback_data' => '0:pokebattler:0'
]
],
[
[
'text' => getTranslation('import') . SP . 'shiny (Pokebattler)',
'callback_data' => '0:import_shinyinfo:0'
]
],
[
[
'text' => getTranslation('import') . SP . '(ccev pogoinfo)',
Expand Down
Loading

0 comments on commit 3844454

Please sign in to comment.