diff --git a/README.md b/README.md
index 299c4f59..00869a58 100644
--- a/README.md
+++ b/README.md
@@ -459,7 +459,7 @@ Set `RAID_LATE_TIME` to the amount of minutes the local community will may be wa
Set `RAID_POLL_HIDE_USERS_TIME` to the amount of minutes when a previous raid slot should be hidden. For example if there are 2 slots, 18:00 and 18:15, and you set the time to 10 minutes the first group of participants from 18:00 will be hidden once we reach 18:10. This helps to keep the raid poll message smaller and clearer if there are multiple groups. Set the value to 0 to always show all slots.
-Set `RAID_POLL_UI_TEMPLATE` to the customize the order of the buttons for the raid polls. Supported elementa are `alone, extra, extra_alien, remote, inv_plz, can_inv, ex_inv, teamlvl, time, pokemon, refresh, alarm, here, late, done, cancel`. Some elements may be hidden by some other config values even if they are set in the template.
+Edit `RAID_POLL_UI_TEMPLATE` to customize the order of the buttons for the raid polls. Supported elementa are `alone, extra, extra_alien, remote, inv_plz, can_inv, ex_inv, teamlvl, time, pokemon, refresh, alarm, here, late, done, cancel`. Some elements may be hidden by some other config values even if they are set in the template.
Set `RAID_POLL_HIDE_BUTTONS_RAID_LEVEL` to the raid levels (1-5) for which the voting buttons under the raid poll should be hidden. For example a level 1 raid can be done by a single player, but it is maybe interesting to be shared as some pokemon are only available in raids.
@@ -1171,6 +1171,7 @@ To keep local data, such as `pokemon` table and Pokemon icons directory, up to d
| RAID_LATE_TIME| How many minutes to advise waiting in `RAID_LATE_MSG` |
| RAID_LOCATION| Bool, Send a separate attached location message in addition to a raid poll |
| RAID_PICTURE | Bool, enable picture based raid polls instead of default text mode |
+| RAID_PICTURE_AUTOEXTEND | Bool, send the picture and poll as separate messages |
| RAID_PICTURE_STORE_GYM_IMAGES_LOCALLY | Bool, option to store gym photos in `images/gyms` instead of fetching them from cloud every time |
| RAID_PICTURE_BG_COLOR| List of RGB values for `RAID_PICTURE` poll background color, e.g. "0,0,0" for black |
| RAID_PICTURE_FILE_FORMAT| Format for raid pictures for `RAID_PICTURE`, valid values are gif, jpg, jpeg, png |
diff --git a/VERSION b/VERSION
index 1d6e6ce3..d0be22aa 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.1.230.1
+2.1.230.2
diff --git a/commands/addgym.php b/commands/addgym.php
index 1607bd0a..460b8cd6 100644
--- a/commands/addgym.php
+++ b/commands/addgym.php
@@ -33,7 +33,7 @@
$msg = '' . getTranslation('invalid_input') . '' . 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();
}
diff --git a/commands/gymgps.php b/commands/gymgps.php
index 11d293b8..7a76007f 100644
--- a/commands/gymgps.php
+++ b/commands/gymgps.php
@@ -56,7 +56,7 @@
$msg = '' . getTranslation('invalid_input') . '' . 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();
}
diff --git a/commands/help.php b/commands/help.php
index ee84de22..f31dcb09 100644
--- a/commands/help.php
+++ b/commands/help.php
@@ -77,7 +77,7 @@
}
// Send message.
-sendMessage($update['message']['from']['id'], $msg);
+send_message($update['message']['from']['id'], $msg);
?>
diff --git a/commands/raid_from_webhook.php b/commands/raid_from_webhook.php
index c063e667..d132d188 100644
--- a/commands/raid_from_webhook.php
+++ b/commands/raid_from_webhook.php
@@ -237,32 +237,10 @@ function isPointInsidePolygon($point, $vertices) {
}
}
- // Get raid data.
- $raid = get_raid($raid_id);
-
- // Set text.
- $text = show_raid_poll($raid);
-
- // Set keys.
- $keys = keys_vote($raid);
-
if($send_updates == true) {
- $cleanup_query = '
- SELECT *
- FROM cleanup
- WHERE raid_id = :id
- ';
- $cleanup_statement = $dbh->prepare( $cleanup_query );
- $cleanup_statement->execute(['id' => $raid_id]);
- while ($row = $cleanup_statement->fetch()) {
- if($config->RAID_PICTURE) {
- require_once(LOGIC_PATH . '/raid_picture.php');
- $picture_url = raid_picture_url($raid);
- $tg_json[] = editMessageMedia($row['message_id'], $text['short'], $keys, $row['chat_id'], ['disable_web_page_preview' => 'true'],true, $picture_url);
- }else {
- $tg_json[] = editMessageText($row['message_id'], $text['full'], $keys, $row['chat_id'], ['disable_web_page_preview' => 'true'],true);
- }
- }
+ require_once(LOGIC_PATH .'/update_raid_poll.php');
+ $update = update_raid_poll($raid_id, false, false, $tg_json); // update_raid_poll() will return false if the raid isn't shared to any chat
+ if($update != false) $tg_json = $update;
}else {
// Get chats to share to by raid level and geofence id
$chats_geofence = [];
@@ -293,28 +271,8 @@ function isPointInsidePolygon($point, $vertices) {
}
$chats = array_merge($chats_geofence, $chats_raidlevel, $webhook_chats);
- // Post raid polls.
- foreach ($chats as $chat) {
- debug_log('Posting poll to chat: ' . $chat);
-
- // Send location.
- if ($config->RAID_LOCATION) {
-
- $msg_text = !empty($raid['address']) ? $raid['address'] . ', ' . substr(strtoupper($config->BOT_ID), 0, 1) . '-ID = ' . $raid['id'] : $raid['pokemon'] . ', ' . substr(strtoupper($config->BOT_ID), 0, 1) . '-ID = ' . $raid['id']; // DO NOT REMOVE ' ID = ' --> NEEDED FOR $config->CLEANUP PREPARATION!
- $loc = send_venue($chat, $raid['lat'], $raid['lon'], '', $msg_text, true);
- $tg_json[] = $loc;
- debug_log($loc, 'Location:');
- }
-
- // Send the message.
- if($config->RAID_PICTURE) {
- require_once(LOGIC_PATH . '/raid_picture.php');
- $picture_url = raid_picture_url($raid);
- $tg_json[] = send_photo($chat, $picture_url, $text['short'], $keys, ['disable_web_page_preview' => 'true'], true);
- } else {
- $tg_json[] = send_message($chat, $text['full'], $keys, ['disable_web_page_preview' => 'true'], true);
- }
- }
+ require_once(LOGIC_PATH .'/send_raid_poll.php');
+ $tg_json = send_raid_poll($raid_id, $chats, $tg_json);
}
}
diff --git a/commands/team.php b/commands/team.php
index 81362aaa..30489775 100644
--- a/commands/team.php
+++ b/commands/team.php
@@ -36,12 +36,12 @@
);
// Send the message.
- sendMessage($update['message']['chat']['id'], getTranslation('gym_team_set_to') . ' ' . ucfirst($teams[$gym_team]));
+ send_message($update['message']['chat']['id'], getTranslation('gym_team_set_to') . ' ' . ucfirst($teams[$gym_team]));
// Invalid team name.
} else {
// Send the message.
- sendMessage($update['message']['chat']['id'], getTranslation('invalid_team'));
+ send_message($update['message']['chat']['id'], getTranslation('invalid_team'));
}
?>
diff --git a/config/config.json.example b/config/config.json.example
index 63c55e6e..55b2d5db 100644
--- a/config/config.json.example
+++ b/config/config.json.example
@@ -1,5 +1,5 @@
{
- "VERSION":"2.1.230.1",
+ "VERSION":"2.1.230.2",
"DB_HOST":"localhost",
"DB_NAME":"your_database_name",
"DB_USER":"your_database_user",
diff --git a/config/defaults-config.json b/config/defaults-config.json
index e5e25f79..f1c04fc7 100644
--- a/config/defaults-config.json
+++ b/config/defaults-config.json
@@ -22,7 +22,7 @@
"BOT_ID":"R",
"BOT_NAME":"",
"BOT_ADMINS":"",
- "LANGUAGE_PRIVATE":"EN",
+ "LANGUAGE_PRIVATE":"",
"LANGUAGE_PUBLIC":"EN",
"TIMEZONE":"UTC",
"MAPS_LOOKUP": false,
@@ -52,9 +52,10 @@
"RAID_WANT_INVITE": true,
"RAID_CODE_POKEMON":"1,7,4,25,12,143,19,16,52",
"RAID_PICTURE": false,
+ "RAID_PICTURE_AUTOEXTEND": false,
"RAID_AUTOMATIC_ALARM": false,
"SHOW_GYM_NAME_IN_ADDRESS": false,
- "RAID_PICTURE_HIDE_LEVEL":"X",
+ "RAID_PICTURE_HIDE_LEVEL":"",
"RAID_PICTURE_HIDE_POKEMON":"",
"RAID_PICTURE_BG_COLOR":"0,0,0",
"RAID_PICTURE_TEXT_COLOR":"255,255,255",
@@ -70,7 +71,7 @@
"RAID_PICTURE_POKEMON_ICONS":"pokemon,PokeMiners,ZeChrales",
"RAID_PICTURE_POKEMON_FALLBACK":"images/shadow_pika.png",
"RAID_PICTURE_POKEMON_TYPES": true,
- "RAID_POLL_UI_TEMPLATE":[["alone","extra","extra_alien","remote","inv_plz","can_inv","ex_inv"],["teamlvl"],["time"],["pokemon"],["refresh","alarm","here","late","done","cancel"]],
+ "RAID_POLL_UI_TEMPLATE":[["alone","extra","extra_alien","can_inv","remote","inv_plz","ex_inv"],["teamlvl"],["time"],["pokemon"],["refresh","alarm","here","late","done","cancel"]],
"RAID_POLL_HIDE_USERS_TIME":"10",
"RAID_POLL_HIDE_BUTTONS_RAID_LEVEL":"1,2,3",
"RAID_POLL_HIDE_BUTTONS_POKEMON":"",
diff --git a/core/bot/cleanup_collect.php b/core/bot/cleanup_collect.php
index c553f365..1071d59e 100644
--- a/core/bot/cleanup_collect.php
+++ b/core/bot/cleanup_collect.php
@@ -8,34 +8,26 @@
// Channel
if(isset($update['channel_post']['text'])) {
- // Get chat_id and message_id
- $chat_id = $update['channel_post']['chat']['id'];
- $message_id = $update['channel_post']['message_id'];
-
- // Get id from text.
- $cleanup_id = substr(strrchr($update['channel_post']['text'], substr(strtoupper($config->BOT_ID), 0, 1) . '-ID = '), 7);
+ $message = $update['channel_post'];
// Supergroup
-} else if (isset($update['message']['text']) && $update['message']['chat']['type'] == "supergroup") {
- // Get chat_id and message_id
- $chat_id = $update['message']['chat']['id'];
- $message_id = $update['message']['message_id'];
-
+} else if (isset($update['message']['text']) && ($update['message']['chat']['type'] == "supergroup" || $update['message']['chat']['type'] == "group")) {
+ $message = $update['message'];
+}
+// Get chat_id and message_id
+$chat_id = $message['chat']['id'];
+$message_id = $message['message_id'];
+if(isset($message['reply_markup']['inline_keyboard'])) {
+ $split_data = explode(':', $message['reply_markup']['inline_keyboard'][0][0]['callback_data']);
+ $cleanup_id = $split_data[0];
+}else {
// Get id from text.
- $cleanup_id = substr(strrchr($update['message']['text'], substr(strtoupper($config->BOT_ID), 0, 1) . '-ID = '), 7);
+ $cleanup_id = substr($message['text'],strpos($message['text'], substr(strtoupper($config->BOT_ID), 0, 1) . '-ID = ') + 7);
}
-if (function_exists('insert_cleanup')) {
- // Write cleanup info to database.
- cleanup_log('Calling cleanup preparation now!');
- cleanup_log('Cleanup_ID: ' . $cleanup_id);
- if($cleanup_id != 0) {
- insert_cleanup($chat_id, $message_id, $cleanup_id);
- }
-} else {
- info_log('No function found to insert cleanup data to database!', 'ERROR:');
- info_log('Add a function named "insert_cleanup" to add cleanup info to the database!', 'ERROR:');
- info_log('Arguments of that function need to be the chat_id $chat_id, the message_id $message_id and the cleanup id $cleanup_id.', 'ERROR:');
- info_log('For example: function insert_cleanup($chat_id, $message_id, $cleanup_id)', 'ERROR:');
+// Write cleanup info to database.
+cleanup_log('Calling cleanup preparation now!');
+cleanup_log('Cleanup_ID: ' . $cleanup_id);
+if($cleanup_id != 0) {
+ insert_cleanup($chat_id, $message_id, $cleanup_id, 'inline_poll_text');
}
-
diff --git a/core/bot/commands.php b/core/bot/commands.php
index b2f7f38d..624dff5c 100644
--- a/core/bot/commands.php
+++ b/core/bot/commands.php
@@ -15,7 +15,7 @@
}
if($config->TUTORIAL_MODE && isset($update['message']['chat']['id']) && new_user($update['message']['chat']['id']) && $com != 'start') {
- sendMessage($update['message']['chat']['id'], getTranslation("tutorial_command_failed"));
+ send_message($update['message']['chat']['id'], getTranslation("tutorial_command_failed"));
$dbh = null;
exit();
}
@@ -52,6 +52,6 @@
// Include start file and exit.
include_once($startcommand);
} else {
- sendMessage($update['message']['chat']['id'], '' . getTranslation('not_supported') . '');
+ send_message($update['message']['chat']['id'], '' . getTranslation('not_supported') . '');
}
}
diff --git a/core/bot/importal.php b/core/bot/importal.php
index 55510499..979eb1c0 100644
--- a/core/bot/importal.php
+++ b/core/bot/importal.php
@@ -66,7 +66,7 @@
// Invalid input or unknown bot - send message and end.
$msg = '' . getTranslation('invalid_input') . '';
$msg .= CR . CR . getTranslation('not_supported') . SP . getTranslation('or') . SP . getTranslation('internal_error');
- sendMessage($update['message']['from']['id'], $msg);
+ send_message($update['message']['from']['id'], $msg);
exit();
}
diff --git a/core/bot/logic/bot_access_check.php b/core/bot/logic/bot_access_check.php
index 63e6e3b1..c6d30104 100644
--- a/core/bot/logic/bot_access_check.php
+++ b/core/bot/logic/bot_access_check.php
@@ -339,7 +339,7 @@ function bot_access_check($update, $permission = 'access-bot', $return_result =
// Telegram multicurl request.
curl_json_multi_request($tg_json);
} else {
- sendMessage($update[$update_type]['from']['id'], $response_msg);
+ send_message($update[$update_type]['from']['id'], $response_msg);
}
exit;
}
diff --git a/core/bot/logic/language.php b/core/bot/logic/language.php
index e191bafd..6dff2597 100644
--- a/core/bot/logic/language.php
+++ b/core/bot/logic/language.php
@@ -1,8 +1,8 @@
diff --git a/core/commands/set.php b/core/commands/set.php
index 660bd4ed..3b43fc9c 100644
--- a/core/commands/set.php
+++ b/core/commands/set.php
@@ -177,6 +177,6 @@
}
// Send message.
-sendMessage($update['message']['chat']['id'], $msg);
+send_message($update['message']['chat']['id'], $msg);
?>
diff --git a/core/telegram/functions.php b/core/telegram/functions.php
index 42b9cc17..3bfdceb3 100644
--- a/core/telegram/functions.php
+++ b/core/telegram/functions.php
@@ -24,49 +24,18 @@ function is_valid_target($chat_id, $message_id, $no_chat = false, $no_message =
info_log("chat_id:{$chat_id}, message_id:{$message_id}", 'ERROR: Unhandled pair of chat_id & message_id, this is a bug:');
return true;
}
-/**
- * Send message.
- * @param $chat_id
- * @param array $text
- * @param $multicurl
- */
-function sendMessage($chat_id, $text = [], $multicurl = false)
-{
- // Create response content array.
- $reply_content = [
- 'method' => 'sendMessage',
- 'chat_id' => $chat_id,
- 'parse_mode' => 'HTML',
- 'text' => $text
- ];
- if(!is_valid_target($chat_id, null, false, true)){
- info_log($chat_id, 'ERROR: Cannot send to invalid chat id:');
- info_log($reply_content, 'ERROR: data would have been:');
- exit();
- }
-
- // Encode data to json.
- $reply_json = json_encode($reply_content);
-
- // Set header to json.
- header('Content-Type: application/json');
-
- // Write to log.
- debug_log($reply_json, '>');
-
- // Send request to telegram api.
- return curl_request($reply_json, $multicurl);
-}
/**
* Send message.
- * @param $chat_id
+ * @param int $chat_id
* @param array $text
* @param mixed $inline_keyboard
* @param array $merge_args
- * @param $multicurl
- */
-function send_message($chat_id, $text = [], $inline_keyboard = false, $merge_args = [], $multicurl = false)
+ * @param array|false $multicurl
+ * @param int|string $identifier
+ * @return mixed
+*/
+function send_message($chat_id, $text = [], $inline_keyboard = false, $merge_args = [], $multicurl = false, $identifier = false)
{
// Create response content array.
$reply_content = [
@@ -85,7 +54,7 @@ function send_message($chat_id, $text = [], $inline_keyboard = false, $merge_arg
debug_log('KEYS');
debug_log($inline_keyboard);
- if (isset($inline_keyboard)) {
+ if ($inline_keyboard != false) {
$reply_content['reply_markup'] = ['inline_keyboard' => $inline_keyboard];
}
@@ -103,52 +72,7 @@ function send_message($chat_id, $text = [], $inline_keyboard = false, $merge_arg
debug_log($reply_json, '>');
// Send request to telegram api.
- return curl_request($reply_json, $multicurl);
-}
-
-/**
- * Send location.
- * @param $chat_id
- * @param $lat
- * @param $lon
- * @param bool $inline_keyboard
- * @param $multicurl
- * @return mixed
- */
-function send_location($chat_id, $lat, $lon, $inline_keyboard = false, $multicurl = false)
-{
- // Create reply content array.
- $reply_content = [
- 'method' => 'sendLocation',
- 'chat_id' => $chat_id,
- 'latitude' => $lat,
- 'longitude' => $lon
- ];
- if(!is_valid_target($chat_id, null, false, true)){
- info_log($chat_id, 'ERROR: Cannot send to invalid chat id:');
- info_log($reply_content, 'ERROR: data would have been:');
- exit();
- }
-
- // Write to log.
- debug_log('KEYS');
- debug_log($inline_keyboard);
-
- if (is_array($inline_keyboard)) {
- $reply_content['reply_markup'] = ['inline_keyboard' => $inline_keyboard];
- }
-
- // Encode data to json.
- $reply_json = json_encode($reply_content);
-
- // Set header to json.
- header('Content-Type: application/json');
-
- // Write to log.
- debug_log($reply_json, '>');
-
- // Send request to telegram api and return response.
- return curl_request($reply_json, $multicurl);
+ return curl_request($reply_json, $multicurl, $identifier);
}
/**
@@ -160,9 +84,10 @@ function send_location($chat_id, $lat, $lon, $inline_keyboard = false, $multicur
* @param $address
* @param bool $inline_keyboard
* @param $multicurl
+ * @param $identifier
* @return mixed
*/
-function send_venue($chat_id, $lat, $lon, $title, $address, $inline_keyboard = false, $multicurl = false)
+function send_venue($chat_id, $lat, $lon, $title, $address, $inline_keyboard = false, $multicurl = false, $identifier = false)
{
// Create reply content array.
$reply_content = [
@@ -197,7 +122,7 @@ function send_venue($chat_id, $lat, $lon, $title, $address, $inline_keyboard = f
debug_log($reply_json, '>');
// Send request to telegram api and return response.
- return curl_request($reply_json, $multicurl);
+ return curl_request($reply_json, $multicurl, $identifier);
}
/**
@@ -671,8 +596,9 @@ function get_chatmember($chat_id, $user_id, $multicurl = false)
* @param mixed $inline_keyboard
* @param array $merge_args
* @param array $multicurl
+ * @param int $identifier
*/
-function send_photo($chat_id, $photo_url, $text = array(), $inline_keyboard = false, $merge_args = [], $multicurl = false)
+function send_photo($chat_id, $photo_url, $text = array(), $inline_keyboard = false, $merge_args = [], $multicurl = false, $identifier = false)
{
// Create response content array.
$reply_content = [
@@ -705,7 +631,7 @@ function send_photo($chat_id, $photo_url, $text = array(), $inline_keyboard = fa
debug_log($reply_json, '>');
// Send request to telegram api.
- return curl_request($reply_json, $multicurl);
+ return curl_request($reply_json, $multicurl, $identifier);
}
/**
@@ -765,25 +691,27 @@ function editMessageMedia($id_val, $text_val, $markup_val, $chat_id = NULL, $mer
* Send request to telegram api - single or multi?.
* @param $json
* @param $multicurl
+ * @param $identifier
* @return mixed
*/
-function curl_request($json, $multicurl = false)
+function curl_request($json, $multicurl = false, $identifier = false)
{
// Send request to telegram api.
if($multicurl == true) {
- return $json;
+ return ['json' => $json, 'identifier' => $identifier];
} else {
- return curl_json_request($json);
+ return curl_json_request($json, $identifier);
}
}
/**
* Send request to telegram api.
* @param $json
+ * @param $identifier
* @return mixed
*/
-function curl_json_request($json)
+function curl_json_request($json, $identifier)
{
global $config;
// Bridge mode?
@@ -826,7 +754,7 @@ function curl_json_request($json)
curl_close($curl);
// Process response from telegram api.
- $response = curl_json_response($json_response, $json);
+ $response = curl_json_response($json_response, $json, $identifier);
// Return response.
return $response;
@@ -852,9 +780,6 @@ function curl_json_multi_request($json)
// Init multi handle.
$mh = curl_multi_init();
- // Init $data as array - since php 5.2 the CURLOPT_POSTFIELDS wants an array
- $data = array();
-
// Loop through json array, create curl handles and add them to the multi-handle.
foreach ($json as $id => $data) {
// Init.
@@ -879,18 +804,18 @@ function curl_json_multi_request($json)
debug_log('Adding bot folder name "' . basename(ROOT_PATH) . '" to callback data');
$search = '"callback_data":"';
$replace = $search . basename(ROOT_PATH) . ':';
- array_push($data, str_replace($search,$replace,$data));
+ array_push($data['json'], str_replace($search,$replace,$data['json']));
}
// Curl post.
curl_setopt($curly[$id], CURLOPT_POST, true);
- curl_setopt($curly[$id], CURLOPT_POSTFIELDS, $data);
+ curl_setopt($curly[$id], CURLOPT_POSTFIELDS, $data['json']);
// Add multi handle.
curl_multi_add_handle($mh, $curly[$id]);
// Write to log.
- debug_log($data, '->');
+ debug_log($data['json'], '->');
}
// Execute the handles.
@@ -915,15 +840,7 @@ function curl_json_multi_request($json)
// Process response from telegram api.
foreach($response as $id => $json_response) {
- // Bot specific funtion to process response from telegram api.
- if (function_exists('curl_json_response')) {
- $response[$id] = curl_json_response($json_response, $response[$id]);
- } else {
- info_log('No function found to process response from Telegram API!', 'ERROR:');
- info_log('Add a function named "curl_json_response" to process them!', 'ERROR:');
- info_log('Arguments of that function need to be the response $json_response and the send data $json.', 'ERROR:');
- info_log('For example: function curl_json_response($json_response, $json)', 'ERROR:');
- }
+ $response[$id] = curl_json_response($response[$id], $json[$id]['json'], $json[$id]['identifier']);
debug_log_incoming($json_response, '<-');
}
diff --git a/logic.php b/logic.php
index e116e4a7..62b0019b 100644
--- a/logic.php
+++ b/logic.php
@@ -54,7 +54,6 @@
include('logic/raid_poll_message.php');
include('logic/run_cleanup.php');
include('logic/sendalarmnotice.php');
-include('logic/send_response_vote.php');
include('logic/send_trainerinfo.php');
include('logic/send_vote_remote_users_limit_reached.php');
include('logic/send_vote_time_first.php');
diff --git a/logic/alarm.php b/logic/alarm.php
index ac004dbe..5505afd2 100644
--- a/logic/alarm.php
+++ b/logic/alarm.php
@@ -85,7 +85,6 @@ function alarm($raid_id_array, $user_id, $action, $info = '')
$msg_text .= EMOJI_SINGLE . SP . $username . SP . '+' . $icons[$info] . CR;
$msg_text .= EMOJI_CLOCK . SP . check_time($attendtime);
$msg_text .= create_traincode_msg($trainercode);
- $tg_json[] = sendMessage($answer['user_id'], $msg_text, true);
// Updating status - here or cancel
} else if($action == "status") {
@@ -98,14 +97,12 @@ function alarm($raid_id_array, $user_id, $action, $info = '')
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
$msg_text .= EMOJI_CLOCK . SP . check_time($attendtime);
$msg_text .= create_traincode_msg($trainercode);
- $tg_json[] = sendMessage($answer['user_id'], $msg_text, true);
} else if($info == 'cancel') {
debug_log('Alarm cancel: ' . $info);
$msg_text = '' . getTranslation('alert_cancel', true, $recipient_language) . '' . CR;
$msg_text .= TEAM_CANCEL . SP . $gymname . SP . '(' . $raidtimes . ')' . CR;
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
$msg_text .= EMOJI_CLOCK . SP . check_time($attendtime);
- $tg_json[] = sendMessage($answer['user_id'], $msg_text, true);
}
// Updating pokemon
@@ -121,7 +118,6 @@ function alarm($raid_id_array, $user_id, $action, $info = '')
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
$msg_text .= EMOJI_CLOCK . SP . check_time($attendtime);
$msg_text .= create_traincode_msg($trainercode);
- $tg_json[] = sendMessage($answer['user_id'], $msg_text, true);
// Any pokemon
} else {
$msg_text = '' . getTranslation('alert_every_poke', true, $recipient_language) . '' . CR;
@@ -129,7 +125,6 @@ function alarm($raid_id_array, $user_id, $action, $info = '')
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
$msg_text .= EMOJI_CLOCK . SP . check_time($attendtime);
$msg_text .= create_traincode_msg($trainercode);
- $tg_json[] = sendMessage($answer['user_id'], $msg_text, true);
}
// Cancel pokemon
@@ -142,13 +137,11 @@ function alarm($raid_id_array, $user_id, $action, $info = '')
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
$msg_text .= EMOJI_CLOCK . SP . check_time($attendtime);
$msg_text .= create_traincode_msg($trainercode);
- $tg_json[] = sendMessage($answer['user_id'], $msg_text, true);
} else if($action == "new_boss") {
$msg_text = '' . getTranslation('alert_raid_boss') . '' . CR;
$msg_text .= EMOJI_HERE . SP . $gymname . SP . '(' . $raidtimes . ')' . CR;
$msg_text .= EMOJI_EGG . SP . '' . get_local_pokemon_name($raid['pokemon'], $raid['pokemon_form']) . '' . CR;
- $tg_json[] = sendMessage($answer['user_id'], $msg_text, true);
// New attendance
} else if($action == "new_att") {
@@ -159,7 +152,6 @@ function alarm($raid_id_array, $user_id, $action, $info = '')
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
$msg_text .= EMOJI_CLOCK . SP . check_time($info);
$msg_text .= create_traincode_msg($trainercode);
- $tg_json[] = sendMessage($answer['user_id'], $msg_text, true);
// Attendance time change
} else if($action == "change_time") {
@@ -170,7 +162,6 @@ function alarm($raid_id_array, $user_id, $action, $info = '')
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
$msg_text .= EMOJI_CLOCK . SP . '' . check_time($info) . '';
$msg_text .= create_traincode_msg($trainercode);
- $tg_json[] = sendMessage($answer['user_id'], $msg_text, true);
// Attendance from remote
} else if($action == "remote") {
@@ -181,7 +172,6 @@ function alarm($raid_id_array, $user_id, $action, $info = '')
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
$msg_text .= EMOJI_CLOCK . SP . '' . check_time($attendtime) . '';
$msg_text .= create_traincode_msg($trainercode);
- $tg_json[] = sendMessage($answer['user_id'], $msg_text, true);
// Attendance no longer from remote
} else if($action == "no_remote") {
@@ -191,7 +181,6 @@ function alarm($raid_id_array, $user_id, $action, $info = '')
$msg_text .= EMOJI_REMOTE . SP . $gymname . SP . '(' . $raidtimes . ')' . CR;
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
$msg_text .= EMOJI_CLOCK . SP . '' . check_time($attendtime) . '';
- $tg_json[] = sendMessage($answer['user_id'], $msg_text, true);
// No additional trainer
} else if($action == "extra_alone") {
@@ -201,7 +190,6 @@ function alarm($raid_id_array, $user_id, $action, $info = '')
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
$msg_text .= EMOJI_CLOCK . SP . check_time($attendtime);
$msg_text .= create_traincode_msg($trainercode);
- $tg_json[] = sendMessage($answer['user_id'], $msg_text, true);
// Group code public
} else if($action == "group_code_public") {
@@ -211,7 +199,6 @@ function alarm($raid_id_array, $user_id, $action, $info = '')
$msg_text .= EMOJI_HERE . SP . $gymname . SP . '(' . $raidtimes . ')' . CR;
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
$msg_text .= EMOJI_REMOTE . SP . $info;
- $tg_json[] = sendMessage($answer['user_id'], $msg_text, true);
// Group code private
} else if($action == "group_code_private") {
@@ -222,17 +209,13 @@ function alarm($raid_id_array, $user_id, $action, $info = '')
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
// Send code to remote raiders
- $msg_text_remote = $msg_text;
- $msg_text_remote .= EMOJI_REMOTE . SP . '' . $info . '';
if($answer['remote'] == 1) {
- $tg_json[] = sendMessage($answer['user_id'], $msg_text_remote, true);
+ $msg_text .= EMOJI_REMOTE . SP . '' . $info . '';
}
// Send message to local raiders
- $msg_text_local = $msg_text;
- $msg_text_local .= EMOJI_REMOTE . SP . '' . getTranslation('group_code_only_for_remote_raiders', true, $recipient_language) . '';
if($answer['remote'] == 0) {
- $tg_json[] = sendMessage($answer['user_id'], $msg_text_local, true);
+ $msg_text .= EMOJI_REMOTE . SP . '' . getTranslation('group_code_only_for_remote_raiders', true, $recipient_language) . '';
}
// Attendance from remote
} else if($action == "want_invite") {
@@ -242,7 +225,6 @@ function alarm($raid_id_array, $user_id, $action, $info = '')
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
$msg_text .= EMOJI_CLOCK . SP . '' . check_time($attendtime) . '';
$msg_text .= create_traincode_msg($trainercode);
- $tg_json[] = sendMessage($answer['user_id'], $msg_text, true);
// Attendance no longer from remote
} else if($action == "no_want_invite") {
@@ -252,7 +234,6 @@ function alarm($raid_id_array, $user_id, $action, $info = '')
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
$msg_text .= EMOJI_CLOCK . SP . '' . check_time($attendtime) . '';
$msg_text .= create_traincode_msg($trainercode);
- $tg_json[] = sendMessage($answer['user_id'], $msg_text, true);
// Let others know you are not playing, but can invite others
} else if($action == "can_invite") {
@@ -262,7 +243,6 @@ function alarm($raid_id_array, $user_id, $action, $info = '')
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
$msg_text .= EMOJI_CLOCK . SP . '' . check_time($attendtime) . '';
$msg_text .= create_traincode_msg($trainercode);
- $tg_json[] = sendMessage($answer['user_id'], $msg_text, true);
// Let others know you are not longer able to invite them
} else if($action == "no_can_invite") {
@@ -272,8 +252,8 @@ function alarm($raid_id_array, $user_id, $action, $info = '')
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
$msg_text .= EMOJI_CLOCK . SP . '' . check_time($attendtime) . '';
$msg_text .= create_traincode_msg($trainercode);
- $tg_json[] = sendMessage($answer['user_id'], $msg_text, true);
}
+ $tg_json[] = send_message($answer['user_id'], $msg_text, false, false, true);
}
if(count($tg_json) > 0) curl_json_multi_request($tg_json);
}
diff --git a/logic/curl_json_response.php b/logic/curl_json_response.php
index 718b25e1..7c0855e8 100644
--- a/logic/curl_json_response.php
+++ b/logic/curl_json_response.php
@@ -1,11 +1,12 @@
{$json_response}", 'ERROR:');
} else {
- // Result seems ok, get message_id and chat_id if supergroup or channel message
- if (isset($response['result']['chat']['type']) && ($response['result']['chat']['type'] == "channel" || $response['result']['chat']['type'] == "supergroup")) {
- // Init cleanup_id
- $cleanup_id = 0;
-
- // Set chat and message_id
- $chat_id = $response['result']['chat']['id'];
- $message_id = $response['result']['message_id'];
-
- // Get raid id from $json
- $json_message = json_decode($json, true);
-
- // Write to log that message was shared with channel or supergroup
- debug_log('Message was shared with ' . $response['result']['chat']['type'] . ' ' . $response['result']['chat']['title']);
- debug_log('Checking input for cleanup info now...');
-
- // Check if callback_data is present to get the cleanup id
- if (!empty($response['result']['reply_markup']['inline_keyboard']['0']['0']['callback_data'])) {
- debug_log('Callback Data of this message likely contains cleanup info!');
- $split_callback_data = explode(':', $response['result']['reply_markup']['inline_keyboard']['0']['0']['callback_data']);
- // Get raid_id, but check for $config->BRIDGE_MODE first
- if($config->BRIDGE_MODE) {
- $cleanup_id = $split_callback_data[1];
- } else {
- $cleanup_id = $split_callback_data[0];
- }
-
- // Check if it's a venue and get raid id
- } else if (isset($response['result']['venue']['address']) && !empty($response['result']['venue']['address'])) {
- // Get raid_id from address.
- debug_log('Venue address message likely contains cleanup info!');
- if(strpos($response['result']['venue']['address'], substr(strtoupper($config->BOT_ID), 0, 1) . '-ID = ') !== false) {
- $cleanup_id = substr($response['result']['venue']['address'],strpos($response['result']['venue']['address'], substr(strtoupper($config->BOT_ID), 0, 1) . '-ID = ') + 7);
- } else {
- debug_log('BOT_ID ' . $config->BOT_ID . ' not found in venue address message!');
- }
+ if($identifier != false) {
+ if (isset($response['result']['chat']['type']) && in_array($response['result']['chat']['type'], ['channel','group','supergroup'])) {
+ // Set chat and message_id
+ $chat_id = $response['result']['chat']['id'];
+ $message_id = $response['result']['message_id'];
+ debug_log('Return data: Chat id: '.$chat_id.', message_id: '.$message_id.', type: '.$identifier);
+ if($identifier == 'trainer') {
+ debug_log('Adding trainermessage info to database now!');
+ insert_trainerinfo($chat_id, $message_id);
+ }else if ($identifier == 'overview') {
+ debug_log('Adding overview info to database now!');
+ $chat_title = $response['result']['chat']['title'];
+ $chat_username = isset($response['result']['chat']['username']) ? $response['result']['chat']['username'] : '';
- // Check if it's a text and get raid id
- } else if (!empty($response['result']['text'])) {
- debug_log('Text message likely contains cleanup info!');
- if(isset($response['result']['venue']['address']) && strpos($response['result']['venue']['address'], substr(strtoupper($config->BOT_ID), 0, 1) . '-ID = ') !== false) {
- $cleanup_id = substr($response['result']['text'],strpos($response['result']['text'], substr(strtoupper($config->BOT_ID), 0, 1) . '-ID = ') + 7);
- } else if(strpos($response['result']['text'], substr(strtoupper($config->BOT_ID), 0, 1) . '-ID = ') !== false) {
- $cleanup_id = substr($response['result']['text'],strpos($response['result']['text'], substr(strtoupper($config->BOT_ID), 0, 1) . '-ID = ') + 7);
+ insert_overview($chat_id, $message_id, $chat_title, $chat_username);
}else {
- debug_log('BOT_ID ' . $config->BOT_ID . ' not found in text message!');
+ if(isset($response['result']['text']) && !empty($response['result']['text'])) {
+ $type = 'poll_text';
+ } else if(isset($response['result']['caption']) && !empty($response['result']['caption'])) {
+ $type = 'poll_photo';
+ } else if(isset($response['result']['venue']) && !empty($response['result']['venue'])) {
+ $type = 'poll_venue';
+ }else if(isset($response['result']['photo']) && !isset($response['result']['caption'])) {
+ $type = 'photo';
+ }
+ insert_cleanup($chat_id, $message_id, $identifier, $type);
}
- // Check if it's a caption and get raid id
- } else if (!empty($response['result']['caption'])) {
- debug_log('Caption in a message likely contains cleanup info!');
- if(strpos($response['result']['caption'], substr(strtoupper($config->BOT_ID), 0, 1) . '-ID = ') !== false) {
- $cleanup_id = substr($response['result']['caption'],strpos($response['result']['caption'], substr(strtoupper($config->BOT_ID), 0, 1) . '-ID = ') + 7);
- } else {
- debug_log('BOT_ID ' . $config->BOT_ID . ' not found in caption of message!');
- }
- }
- debug_log('Cleanup ID: ' . $cleanup_id);
-
- // Trigger Cleanup when raid_id was found
- if($cleanup_id != 0 && $cleanup_id != 'trainer') {
- debug_log('Found ID for cleanup preparation from callback_data or venue!');
- debug_log('Chat_ID: ' . $chat_id);
- debug_log('Message_ID: ' . $message_id);
-
- // Trigger cleanup preparation process when necessary id's are not empty and numeric
- if (!empty($chat_id) && !empty($message_id) && !empty($cleanup_id)) {
- debug_log('Calling cleanup preparation now!');
- insert_cleanup($chat_id, $message_id, $cleanup_id);
- } else {
- info_log($cleanup_id, 'Missing input! Cannot call cleanup preparation for raid:');
- }
- } else if($cleanup_id != '0' && $cleanup_id == 'trainer') {
- debug_log('Detected trainer info message from callback_data!');
- debug_log('Chat_ID: ' . $chat_id);
- debug_log('Message_ID: ' . $message_id);
-
- // Add trainer info message details to database.
- if (!empty($chat_id) && !empty($message_id)) {
- debug_log('Adding trainer info to database now!');
- insert_trainerinfo($chat_id, $message_id);
- } else {
- info_log("Missing input! Cannot add trainer info. chat: '{$chat_id}', message: '{$message_id}'");
- }
- } else {
- debug_log('No cleanup info found! Skipping cleanup preparation!');
- }
-
- // Check if text starts with getTranslation('raid_overview_for_chat') and inline keyboard is empty
- $translation = !empty($config->LANGUAGE_PUBLIC) ? getPublicTranslation('raid_overview_for_chat') : '';
- $translation_length = strlen($translation);
- $text = !empty($response['result']['text']) ? substr($response['result']['text'], 0, $translation_length) : '';
- // Add overview message details to database.
- if (!empty($text) && !empty($translation) && $text === $translation && empty($json_message['reply_markup']['inline_keyboard'])) {
- debug_log('Detected overview message!');
- debug_log('Text: ' . $text);
- debug_log('Translation: ' . $translation);
- debug_log('Chat_ID: ' . $chat_id);
- debug_log('Message_ID: ' . $message_id);
-
- // Write raid overview data to database
- debug_log('Adding overview info to database now!');
- $chat_title = $response['result']['chat']['title'];
- $chat_username = isset($response['result']['chat']['username']) ? $response['result']['chat']['username'] : '';
-
- insert_overview($chat_id, $message_id, $chat_title, $chat_username);
}
}
}
diff --git a/logic/insert_cleanup.php b/logic/insert_cleanup.php
index a86d5441..b77b6fdc 100644
--- a/logic/insert_cleanup.php
+++ b/logic/insert_cleanup.php
@@ -4,57 +4,28 @@
* @param $chat_id
* @param $message_id
* @param $raid_id
+ * @param $type
*/
-function insert_cleanup($chat_id, $message_id, $raid_id)
+function insert_cleanup($chat_id, $message_id, $raid_id, $type)
{
// Log ID's of raid, chat and message
debug_log('Raid_ID: ' . $raid_id);
debug_log('Chat_ID: ' . $chat_id);
debug_log('Message_ID: ' . $message_id);
+ debug_log('Type: ' . $type);
if ((is_numeric($chat_id)) && (is_numeric($message_id)) && (is_numeric($raid_id)) && ($raid_id > 0)) {
- // Get raid times.
- $raid = get_raid($raid_id);
-
- // Init found.
- $found = false;
-
- // Insert cleanup info to database
- if ($raid) {
- // Check if cleanup info is already in database or not
- // Needed since raids can be shared to multiple channels / supergroups!
- $rs = my_query(
- "
- SELECT *
- FROM cleanup
- WHERE raid_id = '{$raid_id}'
- "
- );
-
- // Chat_id and message_id equal to info from database
- while ($cleanup = $rs->fetch()) {
- // Leave while loop if cleanup info is already in database
- if(($cleanup['chat_id'] == $chat_id) && ($cleanup['message_id'] == $message_id)) {
- debug_log('Cleanup preparation info is already in database!');
- $found = true;
- break;
- }
- }
- }
-
- // Insert into database when raid found but no cleanup info found
- if ($raid && !$found) {
- // Build query for cleanup table to add cleanup info to database
- debug_log('Adding cleanup info to database:');
- $rs = my_query(
- "
- INSERT INTO cleanup
- SET raid_id = '{$raid_id}',
- chat_id = '{$chat_id}',
- message_id = '{$message_id}'
- "
- );
- }
+ // Build query for cleanup table to add cleanup info to database
+ debug_log('Adding cleanup info to database:');
+ $rs = my_query(
+ "
+ INSERT INTO cleanup
+ SET raid_id = '{$raid_id}',
+ chat_id = '{$chat_id}',
+ message_id = '{$message_id}',
+ type = '{$type}'
+ "
+ );
} else {
debug_log('Invalid input for cleanup preparation!');
}
diff --git a/logic/raid_list.php b/logic/raid_list.php
index 0684f646..904f6546 100644
--- a/logic/raid_list.php
+++ b/logic/raid_list.php
@@ -22,48 +22,24 @@ function raid_list($update)
// Inline list polls.
if ($iqq != 0) {
-
// Raid by ID.
- $request = my_query(
- "
- SELECT raids.*,
- raids.id AS iqq_raid_id,
- gyms.lat, gyms.lon, gyms.address, gyms.gym_name, gyms.ex_gym, gyms.gym_note,
- TIME_FORMAT(TIMEDIFF(end_time, UTC_TIMESTAMP()) + INTERVAL 1 MINUTE, '%k:%i') AS t_left,
- users.name
- FROM raids
- LEFT JOIN gyms
- ON raids.gym_id = gyms.id
- LEFT JOIN users
- ON raids.user_id = users.user_id
- WHERE raids.id = {$iqq}
- AND end_time>UTC_TIMESTAMP()
- "
- );
+ $rows[0] = get_raid($iqq);
} else {
// Get raid data by user.
$request = my_query(
"
- SELECT raids.*,
- raids.id AS iqq_raid_id,
- gyms.lat, gyms.lon, gyms.address, gyms.gym_name, gyms.ex_gym, gyms.gym_note,
- TIME_FORMAT(TIMEDIFF(end_time, UTC_TIMESTAMP()) + INTERVAL 1 MINUTE, '%k:%i') AS t_left,
- users.name
- FROM raids
- LEFT JOIN gyms
- ON raids.gym_id = gyms.id
- LEFT JOIN users
- ON raids.user_id = users.user_id
- WHERE raids.user_id = {$update['inline_query']['from']['id']}
- AND end_time>UTC_TIMESTAMP()
- ORDER BY iqq_raid_id DESC LIMIT 2
+ 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']);
+ }
}
- while ($answer_raids = $request->fetch()) {
- $rows[] = $answer_raids;
- }
// Init array.
$contents = array();
@@ -71,7 +47,7 @@ function raid_list($update)
// For each rows.
foreach ($rows as $key => $row) {
// Get raid poll.
- $contents[$key]['text'] = show_raid_poll($row)['full'];
+ $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']);
diff --git a/logic/raid_picture.php b/logic/raid_picture.php
index 3244f6fe..c434b766 100644
--- a/logic/raid_picture.php
+++ b/logic/raid_picture.php
@@ -2,10 +2,11 @@
/**
* Get full raidpicture.php URL
- * @param $raid
+ * @param array $raid Raid array from get_raid()
+ * @param bool $standalone Clear the bottom right corner of the photo from text
* @return string
*/
-function raid_picture_url($raid)
+function raid_picture_url($raid, $standalone = false)
{
global $config;
@@ -19,6 +20,7 @@ function raid_picture_url($raid)
$dedupe = strtotime($raid['end_time']); // added to the end to prevent Telegram caching raids that have a different end_time
$picture_url = "{$config->RAID_PICTURE_URL}?pokemon={$raid['pokemon']}-{$raid['pokemon_form']}&raid={$raid['id']}&h={$dedupe}";
+ if($standalone) $picture_url .= '&sa=1';
debug_log('raid_picture_url: ' . $picture_url);
return $picture_url;
}
diff --git a/logic/send_raid_poll.php b/logic/send_raid_poll.php
new file mode 100644
index 00000000..57afbd3f
--- /dev/null
+++ b/logic/send_raid_poll.php
@@ -0,0 +1,63 @@
+RAID_PICTURE) {
+ require_once(LOGIC_PATH . '/raid_picture.php');
+ $picture_url = raid_picture_url($raid, $config->RAID_PICTURE_AUTOEXTEND);
+ }
+
+ // Send the message.
+ $raid_picture_hide_level = explode(",",$config->RAID_PICTURE_HIDE_LEVEL);
+ $raid_picture_hide_pokemon = explode(",",$config->RAID_PICTURE_HIDE_POKEMON);
+
+ $raid_pokemon_id = $raid['pokemon'];
+ $raid_level = $raid['level'];
+ $raid_pokemon_form_name = get_pokemon_form_name($raid_pokemon_id,$raid['pokemon_form']);
+ $raid_pokemon = $raid_pokemon_id . "-" . $raid_pokemon_form_name;
+
+ if(!is_array($chats)) $chats = [$chats];
+ foreach($chats as $chat_id) {
+ // Send location.
+ if ($config->RAID_LOCATION) {
+ // Send location.
+ $msg_text = !empty($raid['address']) ? $raid['address'] : $raid['pokemon'];
+ // Sending venue together with raid poll can't be multicurled since they would appear to the chat in random order
+ send_venue($chat_id, $raid['lat'], $raid['lon'], '', $msg_text, false, false, $raid_id);
+ send_message($chat_id, $text['full'], $keys, ['disable_web_page_preview' => 'true'], false, $raid_id);
+ }else {
+ if($config->RAID_PICTURE && $raid['event_hide_raid_picture'] == 0 && !in_array($raid_level, $raid_picture_hide_level) && !in_array($raid_pokemon, $raid_picture_hide_pokemon) && !in_array($raid_pokemon_id, $raid_picture_hide_pokemon)) {
+ if($config->RAID_PICTURE_AUTOEXTEND) {
+ send_photo($chat_id, $picture_url, '', [], [], false, $raid_id);
+ send_message($chat_id, $text['short'], $keys, ['disable_web_page_preview' => 'true'], false, $raid_id);
+ } else {
+ $tg_json[] = send_photo($chat_id, $picture_url, $text['short'], $keys, ['disable_web_page_preview' => 'true'], true, $raid_id);
+ }
+ } else {
+ $tg_json[] = send_message($chat_id, $text['full'], $keys, ['disable_web_page_preview' => 'true'], true, $raid_id);
+ }
+ }
+ }
+ return $tg_json;
+}
+?>
\ No newline at end of file
diff --git a/logic/send_response_vote.php b/logic/send_response_vote.php
deleted file mode 100644
index 26b1a426..00000000
--- a/logic/send_response_vote.php
+++ /dev/null
@@ -1,147 +0,0 @@
-true]];
- else $chats_to_update = get_all_active_raid_channels($update, $data);
- // Initial text status
- $initial_text = $text;
- // Get the raid data by id.
- $raid = get_raid($data['id']);
- // Message - make sure to not exceed Telegrams 1024 characters limit for caption
- $msg = show_raid_poll($raid);
- $full_msg = $msg['full'];
- $msg_full_len = strlen(utf8_decode($msg['full']));
- debug_log($msg_full_len, 'Raid poll full message length:');
- if(array_key_exists('short', $msg)) {
- $msg_short_len = strlen(utf8_decode($msg['short']));
- debug_log($msg_short_len, 'Raid poll short message length:');
- // Message short enough?
- if($msg_short_len < 1024) {
- $msg = $msg['short'];
- } else {
- // Use full text and reset text to true regardless of prior value
- $msg = $msg['full'];
- $text = true;
- }
- } else {
- // Use full text and reset text to true regardless of prior value
- $msg = $msg['full'];
- $text = true;
- }
- $keys = keys_vote($raid);
-
- // Write to log.
- // debug_log($keys);
-
- if ($new) {
- $loc = send_location($update['callback_query']['message']['chat']['id'], $raid['lat'], $raid['lon']);
-
- // Write to log.
- debug_log('location:');
- debug_log($loc);
-
- // Telegram JSON array.
- $tg_json = array();
-
- // Send the message.
- $tg_json[] = send_message($update['callback_query']['message']['chat']['id'], $msg . "\n", $keys, ['disable_web_page_preview' => 'true'], true);
-
- // Answer the callback.
- $tg_json[] = answerCallbackQuery($update['callback_query']['id'], $msg, true);
-
- } else {
- // Change message string.
- $callback_msg = getPublicTranslation('vote_updated');
-
- // Telegram JSON array.
- $tg_json = array();
-
- // Answer the callback.
- $tg_json[] = answerCallbackQuery($update['callback_query']['id'], $callback_msg, true, true);
-
- foreach($chats_to_update as $chat_id_msg_id) {
- if(!isset($chat_id_msg_id['inline'])) {
- $chat = $chat_id_msg_id['chat_id'];
- $message = $chat_id_msg_id['message_id'];
- // Modify the $update to also handle messages in other chats than the one where the vote came from
- $update['callback_query']['message']['message_id'] = $message;
- $update['callback_query']['message']['chat']['id'] = $chat;
- }
- if($text) {
- // Make sure to only send if picture with caption and not text message
- if($initial_text == false && !(isset($update['callback_query']['message']['text']))) {
- // Delete raid picture and caption.
- delete_message($chat, $message);
-
- // Resend raid poll as text message.
- $tg_json[] = send_message($chat, $full_msg . "\n", $keys, ['disable_web_page_preview' => 'true'], true);
- } else {
- // Edit the message.
- $tg_json[] = edit_message($update, $full_msg, $keys, ['disable_web_page_preview' => 'true'], true);
- }
- } else {
- // Make sure it's a picture with caption.
- if(isset($update['callback_query']['message']['caption'])) {
- // Edit the caption.
- $tg_json[] = edit_caption($update, $msg, $keys, ['disable_web_page_preview' => 'true'], true);
-
- // Edit the picture - raid ended.
- $time_now = utcnow();
- if($time_now > $raid['end_time'] && $data['arg'] == 0) {
- require_once(LOGIC_PATH . '/raid_picture.php');
- $raid['pokemon'] = 'ended';
- $picture_url = raid_picture_url($raid);
- $tg_json[] = editMessageMedia($message, $msg, $keys, $chat, ['disable_web_page_preview' => 'true'], true, $picture_url);
- }
- } else {
- // Do not switch back to picture with caption. Only allow switch from picture with caption to text message.
- // Edit the message.
- $tg_json[] = edit_message($update, $full_msg, $keys, ['disable_web_page_preview' => 'true'], true);
- }
- }
- }
- }
-
- // Telegram multicurl request.
- curl_json_multi_request($tg_json);
-
- // Exit.
- $dbh = null;
- exit();
-}
-
-/**
- * Delivers all Raid channel got to be updated
- * @param $update
- * @param $data
- * @return array $channel_id
- */
-
-function get_all_active_raid_channels($update,$data){
- global $config;
- $channel_id = [];
- $rs_chann = my_query(
- "
- SELECT *
- FROM cleanup
- WHERE raid_id = {$data['id']}
- AND chat_id <> 0
- ");
- if ($rs_chann->rowCount() > 0) {
- $answer = $rs_chann->fetchAll();
- foreach($answer as $channel){
- array_push($channel_id,['chat_id' => $channel['chat_id'],'message_id' => $channel['message_id']]);
- }
- }
- return $channel_id;
-}
-
-?>
diff --git a/logic/sendalarmnotice.php b/logic/sendalarmnotice.php
index 0cac528c..924d3c30 100644
--- a/logic/sendalarmnotice.php
+++ b/logic/sendalarmnotice.php
@@ -3,30 +3,25 @@
/**
* Sends notification to user if Alarm is on or off
* @param int $raid_id
- * @param array $update
+ * @param array $user_id
* @param boolean $alarm
- * @param string $gymname
- * @param string $raidtimes
+ * @param array $raid Raid array from get_raid()
*/
-function sendAlertOnOffNotice($data, $update, $alarm = null, $gymname = null, $raidtimes = null){
-
- if(empty($gymname)){
- // request gym name
- $request = my_query("SELECT * FROM raids as r left join gyms as g on r.gym_id = g.id WHERE r.id = {$data['id']}");
- $answer = $request->fetch();
- $gymname = '' . $answer['gym_name'] . '';
- if(empty($raidtimes)){
- // parse raidtimes
- $raidtimes = str_replace(CR, '', str_replace(' ', '', get_raid_times($answer, false, true)));
- }
- }
-
- if(empty($raidtimes)){
- //request raidtimes
- $request = my_query("SELECT * FROM raids as r left join gyms as g on r.gym_id = g.id WHERE r.id = {$data['id']}");
- $answer = $request->fetch();
- $raidtimes = str_replace(CR, '', str_replace(' ', '', get_raid_times($answer, false, true)));
+function sendAlertOnOffNotice($raid_id, $user_id, $alarm = null, $raid = null){
+ if(empty($raid)){
+ // Request limited raid info
+ $request = my_query("
+ SELECT g.gym_name, r.start_time, r.end_time
+ FROM raids as r
+ LEFT JOIN gyms as g
+ ON r.gym_id = g.id
+ WHERE r.id = {$raid_id}
+ ");
+ $raid = $request->fetch();
}
+ $gymname = '' . $raid['gym_name'] . '';
+ // parse raidtimes
+ $raidtimes = str_replace(CR, '', str_replace(' ', '', get_raid_times($raid, false, true)));
if(empty($alarm)){
// Get the new value
@@ -34,8 +29,8 @@ function sendAlertOnOffNotice($data, $update, $alarm = null, $gymname = null, $r
"
SELECT alarm
FROM attendance
- WHERE raid_id = {$data['id']}
- AND user_id = {$update['callback_query']['from']['id']}
+ WHERE raid_id = {$raid_id}
+ AND user_id = {$user_id}
"
);
$answer = $rs->fetch();
@@ -50,7 +45,7 @@ function sendAlertOnOffNotice($data, $update, $alarm = null, $gymname = null, $r
$msg_text = EMOJI_NO_ALARM . SP . '' . getTranslation('alert_no_updates') . '' . CR;
}
$msg_text .= EMOJI_HERE . SP . $gymname . SP . '(' . $raidtimes . ')';
- sendmessage($update['callback_query']['from']['id'], $msg_text);
+ send_message($user_id, $msg_text);
}
?>
diff --git a/logic/show_raid_poll.php b/logic/show_raid_poll.php
index 6525ab8c..0e3411e5 100644
--- a/logic/show_raid_poll.php
+++ b/logic/show_raid_poll.php
@@ -1,10 +1,11 @@
fetch()) {
// Attendance found
$cnt_all = 1;
@@ -465,11 +467,10 @@ function show_raid_poll($raid)
}
// Add update time and raid id to message.
- if(!$buttons_hidden) {
- $msg = raid_poll_message($msg, CR . '' . getPublicTranslation('updated') . ': ' . dt2time('now', 'H:i:s') . '');
- }else {
- $msg = raid_poll_message($msg, SP . SP . substr(strtoupper($config->BOT_ID), 0, 1) . '-ID = ' . $raid['id']); // DO NOT REMOVE! --> NEEDED FOR $config->CLEANUP PREPARATION!
- // Ninjasoturi: This is only needed when the message doesn't have inline keyboard attached to it
+ $msg = raid_poll_message($msg, CR . '' . getPublicTranslation('updated') . ': ' . dt2time('now', 'H:i:s') . '');
+ if($inline && ($buttons_hidden or ($raid['end_time'] < $time_now && $config->RAID_ENDED_HIDE_KEYS))) {
+ // Only case this is needed anymore is a poll shared via inline that has no vote keys
+ $msg = raid_poll_message($msg, SP . SP . substr(strtoupper($config->BOT_ID), 0, 1) . '-ID = ' . $raid['id']);
}
// Return the message.
return $msg;
diff --git a/logic/update_raid_poll.php b/logic/update_raid_poll.php
new file mode 100644
index 00000000..dbe05a52
--- /dev/null
+++ b/logic/update_raid_poll.php
@@ -0,0 +1,110 @@
+ null,
+ 'message_id' => $update['callback_query']['inline_message_id'],
+ 'type' => 'poll_text',
+ ];
+ // For updating a poll
+ }else if(isset($update['push'])) {
+ $chat_and_message[] = [
+ 'chat_id' => $update['push']['chat_id'],
+ 'message_id' => $update['push']['message_id'],
+ 'type' => $update['push']['type'],
+ ];
+ }
+ // If neither of the methods above yielded results, or update came from a inline poll, check cleanup table for chat messages to update
+ if(empty($chat_and_message) or isset($update['callback_query']['inline_message_id'])) {
+ $rs_chann = my_query('
+ SELECT chat_id, message_id, type
+ FROM cleanup
+ WHERE raid_id = ' . $raid_id
+ );
+ if ($rs_chann->rowCount() > 0) {
+ while($chat = $rs_chann->fetch()) {
+ $chat_and_message[] = ['chat_id' => $chat['chat_id'], 'message_id' => $chat['message_id'], 'type' => $chat['type']];
+ }
+ }else {
+ return false;
+ }
+ }
+ // Get the raid data by id.
+ if($raid == false) $raid = get_raid($raid_id);
+
+ // Message - make sure to not exceed Telegrams 1024 characters limit for caption
+ $text = show_raid_poll($raid);
+ $post_text = false;
+ if(array_key_exists('short', $text)) {
+ $msg_short_len = strlen(utf8_decode($text['short']));
+ debug_log($msg_short_len, 'Raid poll short message length:');
+ // Message short enough?
+ if($msg_short_len >= 1024) {
+ // Use full text and reset text to true regardless of prior value
+ $post_text = true;
+ }
+ } else {
+ // Use full text and reset text to true regardless of prior value
+ $post_text = true;
+ }
+ $keys = keys_vote($raid);
+
+ // Telegram JSON array.
+ if($tg_json == false) $tg_json = [];
+
+ foreach($chat_and_message as $chat_id_msg_id) {
+ $chat = $chat_id_msg_id['chat_id'];
+ $message = $chat_id_msg_id['message_id'];
+ $type = $chat_id_msg_id['type'];
+ if($type == 'poll_photo') {
+ // If the poll message gets too long, we'll replace it with regular text based poll
+ if($post_text == true) {
+ // Delete raid picture and caption.
+ $tg_json[] = delete_message($chat, $message, true);
+
+ // Resend raid poll as text message.
+ $tg_json[] = send_message($chat, $text['full'], $keys, ['disable_web_page_preview' => 'true'], true);
+ } else {
+ // Edit the caption.
+ $tg_json[] = editMessageCaption($message, $text['short'], $keys, $chat, ['disable_web_page_preview' => 'true'], true);
+
+ // Edit the picture - raid ended.
+ $time_now = utcnow();
+ if($time_now > $raid['end_time'] && !$skip_picture_update) {
+ require_once(LOGIC_PATH . '/raid_picture.php');
+ $raid['pokemon'] = 'ended';
+ $picture_url = raid_picture_url($raid);
+ $tg_json[] = editMessageMedia($message, $msg['short'], $keys, $chat, ['disable_web_page_preview' => 'true'], true, $picture_url);
+ }
+ }
+ }else if ($type == 'poll_text') {
+ $raid_picture_hide_level = explode(",",$config->RAID_PICTURE_HIDE_LEVEL);
+ $raid_picture_hide_pokemon = explode(",",$config->RAID_PICTURE_HIDE_POKEMON);
+
+ // If poll type was text, and RAID_PICUTRE_AUTO_EXTEND is set true in config, we most likely want to update the poll with the short message
+ // Exceptions are: inline poll (chat = null) and events with raid picture hidden
+ if($config->RAID_PICTURE && $config->RAID_PICTURE_AUTOEXTEND && $raid['event_hide_raid_picture'] != 1 && $chat != null && !in_array($raid['level'], $raid_picture_hide_level) && !in_array($raid['pokemon'], $raid_picture_hide_pokemon) && !in_array($raid['pokemon'].'-'.$raid['pokemon_form'], $raid_picture_hide_pokemon)) {
+ $tg_json[] = editMessageText($message, $text['short'], $keys, $chat, ['disable_web_page_preview' => 'true'], true);
+ }else {
+ $tg_json[] = editMessageText($message, $text['full'], $keys, $chat, ['disable_web_page_preview' => 'true'], true);
+ }
+ }
+ }
+ return $tg_json;
+}
+?>
\ No newline at end of file
diff --git a/mods/change_trainercode.php b/mods/change_trainercode.php
index 6832a323..b8aa396b 100644
--- a/mods/change_trainercode.php
+++ b/mods/change_trainercode.php
@@ -38,6 +38,6 @@
send_message($target_user_id, getTranslation('trainercode_success').' '.$trainercode.'', $keys);
}else{
// Trainer Code got unallowed Chars -> Error-Message
- sendMessage($target_user_id, getTranslation('trainercode_fail'));
+ send_message($target_user_id, getTranslation('trainercode_fail'));
exit();
}
diff --git a/mods/change_trainername.php b/mods/change_trainername.php
index 51d02e5a..7d0abb4a 100644
--- a/mods/change_trainername.php
+++ b/mods/change_trainername.php
@@ -38,7 +38,7 @@
send_message($userid, getTranslation('trainername_success').' '.$trainername.'', $keys);
}else{
// Trainer Name got unallowed Chars -> Error-Message
- sendMessage($userid, getTranslation('trainername_fail'));
+ send_message($userid, getTranslation('trainername_fail'));
exit();
}
diff --git a/mods/edit_save.php b/mods/edit_save.php
index a445209d..0c55b065 100644
--- a/mods/edit_save.php
+++ b/mods/edit_save.php
@@ -73,128 +73,104 @@
// Telegram JSON array.
$tg_json = array();
-// Build msg.
-if ($update['callback_query']['message']['chat']['type'] == 'private') {
- // Init keys.
- $keys = [];
+// Init keys.
+$keys = [];
- // Add delete to keys.
- $keys = [
+// Add delete to keys.
+$keys = [
+ [
+ [
+ 'text' => getTranslation('delete'),
+ 'callback_data' => $id . ':raids_delete:0'
+ ]
+ ]
+];
+
+// Check access level prior allowing to change raid time
+$admin_access = bot_access_check($update, 'raid-duration', true);
+if($admin_access) {
+ // Add time change to keys.
+ $keys_time = [
[
[
- 'text' => getTranslation('delete'),
- 'callback_data' => $id . ':raids_delete:0'
+ 'text' => getTranslation('change_raid_duration'),
+ 'callback_data' => $id . ':edit_time:0,0,0,0,more,1'
]
]
];
+ $keys = array_merge($keys, $keys_time);
+}
- // Check access level prior allowing to change raid time
- $admin_access = bot_access_check($update, 'raid-duration', true);
- if($admin_access) {
- // Add time change to keys.
- $keys_time = [
- [
- [
- 'text' => getTranslation('change_raid_duration'),
- 'callback_data' => $id . ':edit_time:0,0,0,0,more,1'
- ]
- ]
- ];
- $keys = array_merge($keys, $keys_time);
- }
+// Get raid times.
+$raid = get_raid($data['id']);
- // Get raid times.
- $raid = get_raid($data['id']);
+// Get raid level.
+$raid_level = $raid['level'];
+$const = 'SHARE_CHATS_LEVEL_' . $raid_level;
+$const_chats = $config->{$const};
- // Get raid level.
- $raid_level = $raid['level'];
- $const = 'SHARE_CHATS_LEVEL_' . $raid_level;
- $const_chats = $config->{$const};
+// Debug.
+//debug_log($const,'CONSTANT NAME:');
+//debug_log(constant($const),'CONSTANT VALUE:');
- // Debug.
- //debug_log($const,'CONSTANT NAME:');
- //debug_log(constant($const),'CONSTANT VALUE:');
+// Special sharing keys for raid level?
+if(!empty($const_chats)) {
+ $chats = $const_chats;
+ debug_log('Special sharing keys detected for raid level ' . $raid_level);
+} else {
+ $chats = '';
+}
- // Special sharing keys for raid level?
- if(!empty($const_chats)) {
- $chats = $const_chats;
- debug_log('Special sharing keys detected for raid level ' . $raid_level);
- } else {
- $chats = '';
+if($raid['event']!==NULL) {
+ if($raid['event_note']==NULL) {
+ $event_button_text = getTranslation("event_note_add");
+ }else {
+ $event_button_text = getTranslation("event_note_edit");
}
-
- if($raid['event']!==NULL) {
- if($raid['event_note']==NULL) {
- $event_button_text = getTranslation("event_note_add");
- }else {
- $event_button_text = getTranslation("event_note_edit");
- }
- $keys_edit_event_note = [
+ $keys_edit_event_note = [
+ [
[
- [
- 'text' => $event_button_text,
- 'callback_data' => $id . ':edit_event_note:0'
- ]
+ 'text' => $event_button_text,
+ 'callback_data' => $id . ':edit_event_note:0'
]
- ];
- $keys = array_merge($keys, $keys_edit_event_note);
- }
-
- // Add keys to share.
- $keys_share = share_keys($id, 'raid_share', $update, $chats);
- $keys = array_merge($keys, $keys_share);
-
- // Build message string.
- $msg = '';
- $msg .= getTranslation('raid_saved') . CR;
- $msg .= show_raid_poll_small($raid, false) . CR;
-
- // User_id tag.
- $user_id_tag = '#' . $update['callback_query']['from']['id'];
-
- // Gym Name
- if(!empty($raid['gym_name']) && ($raid['gym_name'] != $user_id_tag)) {
- $msg .= getTranslation('set_gym_team') . CR2;
- } else {
- $msg .= getTranslation('set_gym_name_and_team') . CR2;
- $msg .= getTranslation('set_gym_name_command') . CR;
- }
- $msg .= getTranslation('set_gym_team_command');
+ ]
+ ];
+ $keys = array_merge($keys, $keys_edit_event_note);
+}
- // Build callback message string.
- if($arg == 0) {
- $callback_response = 'OK';
- }else {
- $callback_response = getTranslation('end_time') . ' ' . $data['arg'] . ' ' . getTranslation('minutes');
- }
+// Add keys to share.
+$keys_share = share_keys($id, 'raid_share', $update, $chats);
+$keys = array_merge($keys, $keys_share);
- // Answer callback.
- $tg_json[] = answerCallbackQuery($update['callback_query']['id'], $callback_response, true);
+// Build message string.
+$msg = '';
+$msg .= getTranslation('raid_saved') . CR;
+$msg .= show_raid_poll_small($raid, false) . CR;
- // Edit message.
- $tg_json[] = edit_message($update, $msg, $keys, false, true);
+// User_id tag.
+$user_id_tag = '#' . $update['callback_query']['from']['id'];
+// Gym Name
+if(!empty($raid['gym_name']) && ($raid['gym_name'] != $user_id_tag)) {
+$msg .= getTranslation('set_gym_team') . CR2;
} else {
- // Get raid times.
- $raid = get_raid($data['id']);
-
- // Get text and keys.
- $text = show_raid_poll($raid);
- $keys = keys_vote($raid);
+ $msg .= getTranslation('set_gym_name_and_team') . CR2;
+ $msg .= getTranslation('set_gym_name_command') . CR;
+}
+$msg .= getTranslation('set_gym_team_command');
- // Build callback message string.
+// Build callback message string.
+if($arg == 0) {
+ $callback_response = 'OK';
+}else {
$callback_response = getTranslation('end_time') . ' ' . $data['arg'] . ' ' . getTranslation('minutes');
+}
- // Answer callback.
- $tg_json[] = answerCallbackQuery($update['callback_query']['id'], $callback_response, true);
+// Answer callback.
+$tg_json[] = answerCallbackQuery($update['callback_query']['id'], $callback_response, true);
- // Edit message.
- if($config->RAID_PICTURE) {
- send_response_vote($update, $data,false,false);
- } else {
- send_response_vote($update, $data);
- }
-}
+// Edit message.
+$tg_json[] = edit_message($update, $msg, $keys, false, true);
// Telegram multicurl request.
curl_json_multi_request($tg_json);
diff --git a/mods/end_remote_raid.php b/mods/end_remote_raid.php
index 2d5cdc99..2a4469b8 100644
--- a/mods/end_remote_raid.php
+++ b/mods/end_remote_raid.php
@@ -4,18 +4,11 @@
my_query('UPDATE raids SET end_time = date_sub(UTC_TIMESTAMP(),interval 1 minute) WHERE id = \'' . $raid_id . '\'');
-if($config->RAID_PICTURE) {
- // This needs to be defined for send_response_vote to handle these hacked calls
- $update['callback_query']['message']['caption'] = true;
-}
+require_once(LOGIC_PATH . '/update_raid_poll.php');
+$tg_json = update_raid_poll($raid_id, false, $update);
-edit_message($update, getTranslation('raid_done'), []);
-answerCallbackQuery($update['callback_query']['id'], getTranslation("remote_raid_marked_ended"));
+$tg_json[] = edit_message($update, getTranslation('raid_done'), [], false, true);
+$tg_json[] = answerCallbackQuery($update['callback_query']['id'], getTranslation("remote_raid_marked_ended"), true);
-// Send vote response.
-if($config->RAID_PICTURE) {
- send_response_vote($update, $data,false,false);
-} else {
- send_response_vote($update, $data);
-}
+curl_json_multi_request($tg_json);
?>
\ No newline at end of file
diff --git a/mods/overview_share.php b/mods/overview_share.php
index 0b50548e..2e4aedf6 100644
--- a/mods/overview_share.php
+++ b/mods/overview_share.php
@@ -58,7 +58,7 @@
$tg_json[] = edit_message($update, $msg_callback, $keys, ['disable_web_page_preview' => 'true'], true);
// Send the message, but disable the web preview!
- $tg_json[] = send_message($chat_id, $overview_message, $keys, ['disable_web_page_preview' => 'true'], true);
+ $tg_json[] = send_message($chat_id, $overview_message, $keys, ['disable_web_page_preview' => 'true'], true, 'overview');
}else {
// List all overviews to user
foreach( array_keys($active_raids) as $chat_id ) {
diff --git a/mods/post_raid.php b/mods/post_raid.php
index eca5e0b2..b8e6f298 100644
--- a/mods/post_raid.php
+++ b/mods/post_raid.php
@@ -13,51 +13,8 @@
// Get chat id.
$chat = $data['arg'];
-// Get raid data.
-$raid = get_raid($id);
-
-// Get text and keys.
-$text = show_raid_poll($raid);
-$keys = keys_vote($raid);
-
-// Send location.
-if ($config->RAID_LOCATION) {
- // Send location.
- $msg_text = !empty($raid['address']) ? ($raid['address'] . ', ' . substr(strtoupper($config->BOT_ID), 0, 1) . '-ID = ' . $raid['id']) : ($raid['pokemon'] . ', ' . $raid['id']); // DO NOT REMOVE "ID ="--> NEEDED FOR $config->CLEANUP PREPARATION!
- $loc = send_venue($chat, $raid['lat'], $raid['lon'], '', $msg_text);
-
- // Write to log.
- debug_log('location:');
- debug_log($loc);
-}
-
-// Telegram JSON array.
-$tg_json = array();
-
-// Raid picture
-if($config->RAID_PICTURE) {
- require_once(LOGIC_PATH . '/raid_picture.php');
- $picture_url = raid_picture_url($raid);
-}
-
-// Send the message.
-$raid_picture_hide_level = explode(",",$config->RAID_PICTURE_HIDE_LEVEL);
-$raid_picture_hide_pokemon = explode(",",$config->RAID_PICTURE_HIDE_POKEMON);
-
-$raid_pokemon_id = $raid['pokemon'];
-$raid_level = $raid['level'];
-$raid_pokemon_form_name = get_pokemon_form_name($raid_pokemon_id,$raid['pokemon_form']);
-$raid_pokemon = $raid_pokemon_id . "-" . $raid_pokemon_form_name;
-
-if($config->RAID_PICTURE && $raid['event_hide_raid_picture'] == 0 && !in_array($raid_level, $raid_picture_hide_level) && !in_array($raid_pokemon, $raid_picture_hide_pokemon) && !in_array($raid_pokemon_id, $raid_picture_hide_pokemon)) {
- $tg_json[] = send_photo($chat, $picture_url, $text['short'], $keys, ['disable_web_page_preview' => 'true'], true);
-} else {
- $tg_json[] = send_message($chat, $text['full'], $keys, ['disable_web_page_preview' => 'true'], true);
-}
-
-// Set callback keys and message
-$callback_msg = getTranslation('successfully_shared');
-$callback_keys = [];
+require_once(LOGIC_PATH . '/send_raid_poll.php');
+$tg_json = send_raid_poll($id, false, $chat);
// Telegram multicurl request.
curl_json_multi_request($tg_json);
diff --git a/mods/raid_by_location.php b/mods/raid_by_location.php
index 85b495e7..ab6641bd 100644
--- a/mods/raid_by_location.php
+++ b/mods/raid_by_location.php
@@ -12,7 +12,7 @@
// Enabled?
if(!$config->RAID_VIA_LOCATION) {
debug_log('Creating raids by sharing a location is not enabled in config! Exiting!');
- sendMessage($update['message']['chat']['id'], '' . getTranslation('bot_access_denied') . '');
+ send_message($update['message']['chat']['id'], '' . getTranslation('bot_access_denied') . '');
exit();
}
@@ -24,7 +24,7 @@
$lat = $data['id'];
$lon = $data['arg'];
} else {
- sendMessage($update['message']['chat']['id'], '' . getTranslation('invalid_input') . '');
+ send_message($update['message']['chat']['id'], '' . getTranslation('invalid_input') . '');
exit();
}
diff --git a/mods/raid_share.php b/mods/raid_share.php
index 2f6be433..58955c8d 100644
--- a/mods/raid_share.php
+++ b/mods/raid_share.php
@@ -1,6 +1,7 @@
RAID_LOCATION) {
- // Send location.
- $msg_text = !empty($raid['address']) ? ($raid['address'] . ', ' . substr(strtoupper($config->BOT_ID), 0, 1) . '-ID = ' . $raid['id']) : ($raid['pokemon'] . ', ' . $raid['id']); // DO NOT REMOVE "ID ="--> NEEDED FOR $config->CLEANUP PREPARATION!
- $loc = send_venue($chat, $raid['lat'], $raid['lon'], '', $msg_text);
-
- // Write to log.
- debug_log('location:');
- debug_log($loc);
-}
-
-// Telegram JSON array.
-$tg_json = array();
-
-// Raid picture
-if($config->RAID_PICTURE) {
- require_once(LOGIC_PATH . '/raid_picture.php');
- $picture_url = raid_picture_url($raid);
-}
-
-// Send the message.
-$raid_picture_hide_level = explode(",",$config->RAID_PICTURE_HIDE_LEVEL);
-$raid_picture_hide_pokemon = explode(",",$config->RAID_PICTURE_HIDE_POKEMON);
-
-$raid_pokemon_id = $raid['pokemon'];
-$raid_level = $raid['level'];
-$raid_pokemon_form_name = get_pokemon_form_name($raid_pokemon_id,$raid['pokemon_form']);
-$raid_pokemon = $raid_pokemon_id . "-" . $raid_pokemon_form_name;
-
-if($config->RAID_PICTURE && $raid['event_hide_raid_picture'] == 0 && !in_array($raid_level, $raid_picture_hide_level) && !in_array($raid_pokemon, $raid_picture_hide_pokemon) && !in_array($raid_pokemon_id, $raid_picture_hide_pokemon)) {
- $tg_json[] = send_photo($chat, $picture_url, $text['short'], $keys, ['disable_web_page_preview' => 'true'], true);
-} else {
- $tg_json[] = send_message($chat, $text['full'], $keys, ['disable_web_page_preview' => 'true'], true);
-}
+$tg_json = send_raid_poll($id, false, $chat);
// Set callback keys and message
$callback_msg = getTranslation('successfully_shared');
@@ -71,4 +32,5 @@
curl_json_multi_request($tg_json);
// Exit.
+$dbh = null;
exit();
diff --git a/mods/refresh_polls.php b/mods/refresh_polls.php
index a5813ddb..c7a616c3 100644
--- a/mods/refresh_polls.php
+++ b/mods/refresh_polls.php
@@ -3,11 +3,12 @@
// Refresh polls
if($config->AUTO_REFRESH_POLLS) {
$query_messages = my_query("
- SELECT *
- FROM cleanup
+ SELECT cleanup.*
+ FROM cleanup
LEFT JOIN raids
ON cleanup.raid_id = raids.id
WHERE chat_id != 0
+ AND cleanup.type IN ('poll_text', 'poll_photo')
AND raids.start_time <= UTC_TIMESTAMP()
AND raids.end_time > DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 MINUTE)
AND message_id != 0
@@ -15,38 +16,17 @@
debug_log("REFRESH POLLS:");
debug_log("Num rows: ".$query_messages->rowCount());
$tg_json = [];
- $time_now = utcnow();
while($res_messages = $query_messages->fetch()) {
debug_log("message id: ".$res_messages['message_id']);
debug_log("chat id: ".$res_messages['chat_id']);
debug_log("raid id: ".$res_messages['raid_id']);
- // Create a fake callback_query for edit_caption()
- $data_poll['callback_query']['message']['message_id']=$res_messages['message_id'];
- $data_poll['callback_query']['message']['chat']['id']=$res_messages['chat_id'];
+ $data_poll['push']['message_id']=$res_messages['message_id'];
+ $data_poll['push']['chat_id']=$res_messages['chat_id'];
+ $data_poll['push']['type']=$res_messages['type'];
- debug_log("callback_query: ".json_encode($data_poll));
-
- // Get the raid data by id.
- $raid = get_raid($res_messages['raid_id']);
-
- $msg = show_raid_poll($raid);
- $keys = keys_vote($raid);
-
- if(!$config->RAID_PICTURE or $raid['event_hide_raid_picture'] == 1 or strlen(utf8_decode($msg['short'])) > 1024) {
- $tg_json[] = edit_message($data_poll, $msg['full'], $keys, ['disable_web_page_preview' => 'true'], true);
- }else {
- // If raid is over, update photo
- if($time_now > $raid['end_time']) {
- // Edit the photo
- require_once(LOGIC_PATH . '/raid_picture.php');
- $raid['pokemon'] = 'ended';
- $picture_url = raid_picture_url($raid);
- $tg_json[] = editMessageMedia($res_messages['message_id'], $msg['short'], $keys, $res_messages['chat_id'],['disable_web_page_preview' => 'true'], true, $picture_url);
- }else {
- $tg_json[] = edit_caption($data_poll, $msg['short'], $keys, ['disable_web_page_preview' => 'true'], true);
- }
- }
+ require_once(LOGIC_PATH . '/update_raid_poll.php');
+ $tg_json = update_raid_poll($res_messages['raid_id'], false, $data_poll, $tg_json);
}
curl_json_multi_request($tg_json);
}
diff --git a/mods/share_raid_by_location.php b/mods/share_raid_by_location.php
index ec8a985d..2f542ee0 100644
--- a/mods/share_raid_by_location.php
+++ b/mods/share_raid_by_location.php
@@ -53,7 +53,7 @@
$lat = (float)$update['message']['location']['latitude'];
$lon = (float)$update['message']['location']['longitude'];
}else {
- sendMessage($update['message']['chat']['id'], '' . getTranslation('invalid_input') . '');
+ send_message($update['message']['chat']['id'], '' . getTranslation('invalid_input') . '');
exit();
}
$gps_diff = (float)0.01;
diff --git a/mods/trainer_share.php b/mods/trainer_share.php
index 9bd8ecba..d2a9a900 100644
--- a/mods/trainer_share.php
+++ b/mods/trainer_share.php
@@ -20,7 +20,7 @@
$tg_json = array();
// Send the message.
-$tg_json[] = send_message($chat, $text, $keys, ['disable_web_page_preview' => 'true'], true);
+$tg_json[] = send_message($chat, $text, $keys, ['disable_web_page_preview' => 'true'], true, 'trainer');
// Set callback keys and message
$callback_msg = getTranslation('successfully_shared');
diff --git a/mods/vote_can_invite.php b/mods/vote_can_invite.php
index a45ae6c0..aee24549 100644
--- a/mods/vote_can_invite.php
+++ b/mods/vote_can_invite.php
@@ -56,11 +56,13 @@
alarm($data['id'],$update['callback_query']['from']['id'],'no_can_invite');
}
// Send vote response.
- if($config->RAID_PICTURE) {
- send_response_vote($update, $data,false,false);
- } else {
- send_response_vote($update, $data);
- }
+ require_once(LOGIC_PATH . '/update_raid_poll.php');
+
+ $tg_json = update_raid_poll($data['id'], false, $update);
+
+ $tg_json[] = answerCallbackQuery($update['callback_query']['id'], getTranslation('vote_updated'), true);
+
+ curl_json_multi_request($tg_json);
} else {
// Send vote time first.
send_vote_time_first($update);
diff --git a/mods/vote_extra.php b/mods/vote_extra.php
index c0e54f44..47238473 100644
--- a/mods/vote_extra.php
+++ b/mods/vote_extra.php
@@ -72,18 +72,23 @@
} else {
// Send max remote users reached.
send_vote_remote_users_limit_reached($update);
+ $dbh = null;
+ exit();
}
}
// Send vote response.
- if($config->RAID_PICTURE) {
- send_response_vote($update, $data,false,false);
- } else {
- send_response_vote($update, $data);
- }
+ require_once(LOGIC_PATH . '/update_raid_poll.php');
+
+ $tg_json = update_raid_poll($data['id'], false, $update);
+
+ $tg_json[] = answerCallbackQuery($update['callback_query']['id'], getTranslation('vote_updated'), true);
+
+ curl_json_multi_request($tg_json);
} else {
// Send vote time first.
send_vote_time_first($update);
}
+$dbh = null;
exit();
diff --git a/mods/vote_invite.php b/mods/vote_invite.php
index 3a6e40c9..1aad9f0b 100644
--- a/mods/vote_invite.php
+++ b/mods/vote_invite.php
@@ -20,10 +20,12 @@
);
// Send vote response.
- if($config->RAID_PICTURE) {
- send_response_vote($update, $data,false,false);
- } else {
- send_response_vote($update, $data);
- }
+require_once(LOGIC_PATH . '/update_raid_poll.php');
+
+$tg_json = update_raid_poll($data['id'], false, $update);
+
+$tg_json[] = answerCallbackQuery($update['callback_query']['id'], getTranslation('vote_updated'), true);
+
+curl_json_multi_request($tg_json);
exit();
diff --git a/mods/vote_level.php b/mods/vote_level.php
index 89011a6a..b8a3d281 100644
--- a/mods/vote_level.php
+++ b/mods/vote_level.php
@@ -49,11 +49,13 @@
}
} else {
// Send vote response.
- if($config->RAID_PICTURE) {
- send_response_vote($update, $data,false,false);
- } else {
- send_response_vote($update, $data);
- }
+ require_once(LOGIC_PATH . '/update_raid_poll.php');
+
+ $tg_json = update_raid_poll($data['id'], false, $update);
+
+ $tg_json[] = answerCallbackQuery($update['callback_query']['id'], getTranslation('vote_updated'), true);
+
+ curl_json_multi_request($tg_json);
}
exit();
diff --git a/mods/vote_pokemon.php b/mods/vote_pokemon.php
index 68f1da4f..b74a700a 100644
--- a/mods/vote_pokemon.php
+++ b/mods/vote_pokemon.php
@@ -33,9 +33,6 @@
if(!empty($atts)) {
// Any pokemon?
if($data['arg'] == 0) {
- // Send alarm
- alarm($data['id'],$update['callback_query']['from']['id'],'pok_individual',$data['arg']);
-
// Update attendance.
my_query(
"
@@ -62,6 +59,9 @@
AND user_id = {$update['callback_query']['from']['id']}
"
);
+
+ // Send alarm
+ alarm($data['id'],$update['callback_query']['from']['id'],'pok_individual',$data['arg']);
} else {
// Init found and count.
$found = false;
@@ -166,12 +166,13 @@
}
}
- // Send vote response.
- if($config->RAID_PICTURE) {
- send_response_vote($update, $data,false,false);
- } else {
- send_response_vote($update, $data);
- }
+ require_once(LOGIC_PATH . '/update_raid_poll.php');
+
+ $tg_json = update_raid_poll($data['id'], false, $update);
+
+ $tg_json[] = answerCallbackQuery($update['callback_query']['id'], getTranslation('vote_updated'), true);
+
+ curl_json_multi_request($tg_json);
} else {
// Send vote time first.
send_vote_time_first($update);
diff --git a/mods/vote_refresh.php b/mods/vote_refresh.php
index 1cd5df56..f4462c06 100644
--- a/mods/vote_refresh.php
+++ b/mods/vote_refresh.php
@@ -1,10 +1,11 @@
RAID_PICTURE){
- send_response_vote($update, $data,false,false);
-} else {
- send_response_vote($update, $data);
-}
+require_once(LOGIC_PATH . '/update_raid_poll.php');
+
+$tg_json = update_raid_poll($data['id'], false, $update, false, false, false, ($data['arg']=0?false:true));
+
+$tg_json[] = answerCallbackQuery($update['callback_query']['id'], getTranslation('vote_updated'), true);
+
+curl_json_multi_request($tg_json);
+
+$dbh = null;
exit();
diff --git a/mods/vote_remote.php b/mods/vote_remote.php
index 08d8f5c3..45121045 100644
--- a/mods/vote_remote.php
+++ b/mods/vote_remote.php
@@ -49,11 +49,13 @@
}
// Send vote response.
- if($config->RAID_PICTURE) {
- send_response_vote($update, $data,false,false);
- } else {
- send_response_vote($update, $data);
- }
+ require_once(LOGIC_PATH . '/update_raid_poll.php');
+
+ $tg_json = update_raid_poll($data['id'], false, $update);
+
+ $tg_json[] = answerCallbackQuery($update['callback_query']['id'], getTranslation('vote_updated'), true);
+
+ curl_json_multi_request($tg_json);
} else {
// Send max remote users reached.
send_vote_remote_users_limit_reached($update);
diff --git a/mods/vote_status.php b/mods/vote_status.php
index 80f68a6c..d0ae02b3 100644
--- a/mods/vote_status.php
+++ b/mods/vote_status.php
@@ -10,7 +10,7 @@
// Check if the user has voted for this raid before.
$rs = my_query(
"
- SELECT attendance.want_invite,
+ SELECT attendance.want_invite, attendance.alarm,
IF(SUBSTR(gyms.gym_name, 1, LENGTH('".$remote_string."')-1) = '".$remote_string."', 1, 0) as is_remote_gym,
IF(raids.user_id = {$update['callback_query']['from']['id']}, 1, 0) as user_is_creator
FROM attendance
@@ -50,9 +50,9 @@
AND user_id = {$update['callback_query']['from']['id']}
"
);
-
+ $new_alarm_value = $answer['alarm'] = 0 ? 1 : 0;
// Inform User about change
- sendAlertOnOffNotice($data, $update);
+ sendAlertOnOffNotice($data['id'], $update['callback_query']['from']['id'], $new_alarm_value);
} else {
// All other status-updates are using the short query
my_query(
@@ -88,11 +88,13 @@
}
// Send vote response.
- if($config->RAID_PICTURE) {
- send_response_vote($update, $data,false,false);
- } else {
- send_response_vote($update, $data);
- }
+ require_once(LOGIC_PATH . '/update_raid_poll.php');
+
+ $tg_json = update_raid_poll($data['id'], false, $update);
+
+ $tg_json[] = answerCallbackQuery($update['callback_query']['id'], getTranslation('vote_updated'), true);
+
+ curl_json_multi_request($tg_json);
}else {
$msg = getTranslation('vote_status_not_allowed');
answerCallbackQuery($update['callback_query']['id'], $msg);
diff --git a/mods/vote_team.php b/mods/vote_team.php
index 64528c67..d35590df 100644
--- a/mods/vote_team.php
+++ b/mods/vote_team.php
@@ -36,11 +36,13 @@
send_trainerinfo($update, true);
} else {
// Send vote response.
- if($config->RAID_PICTURE) {
- send_response_vote($update, $data,false,false);
- } else {
- send_response_vote($update, $data);
- }
+ require_once(LOGIC_PATH . '/update_raid_poll.php');
+
+ $tg_json = update_raid_poll($data['id'], false, $update);
+
+ $tg_json[] = answerCallbackQuery($update['callback_query']['id'], getTranslation('vote_updated'), true);
+
+ curl_json_multi_request($tg_json);
}
exit();
diff --git a/mods/vote_time.php b/mods/vote_time.php
index 45c3698b..af6a70fc 100644
--- a/mods/vote_time.php
+++ b/mods/vote_time.php
@@ -19,21 +19,6 @@
$count_att = $answer_count['count'];
// Write to log.
debug_log($answer_count, 'Anyone Voted: ');
-$perform_share = false; // no sharing by default
-// Check if Raid has been posted to target channel
-if($count_att == 0 && $config->SHARE_AFTER_ATTENDANCE && !empty($config->SHARE_CHATS_AFTER_ATTENDANCE)){
- $rs_chann = my_query(
- "
- SELECT *
- FROM cleanup
- WHERE raid_id = {$data['id']}
- AND chat_id = {$config->SHARE_CHATS_AFTER_ATTENDANCE}
- ");
- // IF Chat was not shared to target channel we want to share it
- if ($rs_chann->rowCount() == 0) {
- $perform_share = true;
- }
-}
// Request Raid and Gym - Infos
$raid = get_raid($data['id']);
@@ -59,6 +44,8 @@
$answer = [];
}
+$tg_json = [];
+
$vote_time = $data['arg'];
// Raid anytime?
if($vote_time == 0) {
@@ -140,46 +127,47 @@
// Enable alerts message. -> only if alert is on
if($config->RAID_AUTOMATIC_ALARM) {
// Inform User about active alert
- sendAlertOnOffNotice($data, $update, $config->RAID_AUTOMATIC_ALARM);
+ sendAlertOnOffNotice($data['id'], $update['callback_query']['from']['id'], 1, $raid);
}
}
- // Check if RAID has no participants AND Raid should be shared to another Channel at first participant
- // AND target channel was set in config AND Raid was not shared to target channel before
- if($count_att == 0 && $config->SHARE_AFTER_ATTENDANCE && !empty($config->SHARE_CHATS_AFTER_ATTENDANCE) && $perform_share){
- // TODO(artanicus): This code is very WET, I'm sure we have functions somewhere to send a raid share -_-
- // Share Raid to another Channel
- $chat = $config->SHARE_CHATS_AFTER_ATTENDANCE;
- // Set text.
- $text = show_raid_poll($raid);
- // Set keys.
- $keys = keys_vote($raid);
- // Send the message.
- if($config->RAID_PICTURE) {
- require_once(LOGIC_PATH . '/raid_picture.php');
- $picture_url = raid_picture_url($data);
- $tg_json[] = send_photo($chat, $picture_url, $text['short'], $keys, ['disable_web_page_preview' => 'true'], true);
- } else {
- $tg_json[] = send_message($chat, $text['full'], $keys, ['disable_web_page_preview' => 'true'], true);
+ // Check if RAID has no participants AND Raid should be shared to another chat at first participant
+ // AND target chat was set in config AND Raid was not shared to target chat before
+ if($count_att == 0 && $config->SHARE_AFTER_ATTENDANCE && !empty($config->SHARE_CHATS_AFTER_ATTENDANCE)){
+ // Check if Raid has been posted to target chat
+ $rs_chann = my_query(
+ "
+ SELECT *
+ FROM cleanup
+ WHERE raid_id = {$data['id']}
+ AND chat_id = {$config->SHARE_CHATS_AFTER_ATTENDANCE}
+ ");
+ // IF raid was not shared to target chat, we want to share it
+ if ($rs_chann->rowCount() == 0) {
+ // Send the message.
+ require_once(LOGIC_PATH . '/send_raid_poll.php');
+ $tg_json = send_raid_poll($data['id'], $raid, $config->SHARE_CHATS_AFTER_ATTENDANCE, $tg_json);
}
- // Telegram multicurl request.
- curl_json_multi_request($tg_json);
}
} else {
// Send max remote users reached.
send_vote_remote_users_limit_reached($update);
+ $dbh = null;
+ exit();
}
} else {
// Send vote time first.
send_vote_time_future($update);
- send_response_vote($update, $data);
}
- // Send vote response.
- if($config->RAID_PICTURE) {
- send_response_vote($update, $data,false,false);
- } else {
- send_response_vote($update, $data);
- }
+// Send vote response.
+require_once(LOGIC_PATH . '/update_raid_poll.php');
+
+$tg_json = update_raid_poll($data['id'], $raid, $update);
+
+$tg_json[] = answerCallbackQuery($update['callback_query']['id'], getTranslation('vote_updated'), true);
+
+curl_json_multi_request($tg_json);
+$dbh = null;
exit();
\ No newline at end of file
diff --git a/mods/vote_want_invite.php b/mods/vote_want_invite.php
index da07effd..ca55869e 100644
--- a/mods/vote_want_invite.php
+++ b/mods/vote_want_invite.php
@@ -55,11 +55,13 @@
alarm($data['id'],$update['callback_query']['from']['id'],'no_want_invite');
}
// Send vote response.
- if($config->RAID_PICTURE) {
- send_response_vote($update, $data,false,false);
- } else {
- send_response_vote($update, $data);
- }
+ require_once(LOGIC_PATH . '/update_raid_poll.php');
+
+ $tg_json = update_raid_poll($data['id'], false, $update);
+
+ $tg_json[] = answerCallbackQuery($update['callback_query']['id'], getTranslation('vote_updated'), true);
+
+ curl_json_multi_request($tg_json);
} else {
// Send vote time first.
send_vote_time_first($update);
diff --git a/raidpicture.php b/raidpicture.php
index 1eb43d1b..be90ba95 100644
--- a/raidpicture.php
+++ b/raidpicture.php
@@ -15,7 +15,7 @@ function grab_img($uri){
}
return $img;
}
-
+if(isset($_GET['sa']) && $_GET['sa'] == 1) $standalone_photo = true; else $standalone_photo = false;
// Debug switch
$debug = false;
if(isset($_GET['debug']) && $_GET['debug'] == 1) {
@@ -470,6 +470,8 @@ function grab_img($uri){
$time_text_lines[] .= $time_text;
}
$num_text_lines = count($time_text_lines);
+// If the photo is sent without caption, we want to keep the bottom right corcer clear of text because Telegram covers it with a timestamp
+if($standalone_photo) $time_top -= 10;
// Go through every line...
for($ya=0;$ya<$num_text_lines;$ya++){
@@ -536,6 +538,9 @@ function grab_img($uri){
$poke_text_top = 272;
}
+// If the photo is sent without caption, we want to keep the bottom right corcer clear of text because Telegram covers it with a timestamp
+if($standalone_photo) $poke_text_top -= 50;
+
// Add pokemon name to image
for($pa=0;$pa<$num_pokemon_lines;$pa++){
// Get text width and height
diff --git a/sql/pokemon-raid-bot.sql b/sql/pokemon-raid-bot.sql
index ce0b06ba..751601a7 100644
--- a/sql/pokemon-raid-bot.sql
+++ b/sql/pokemon-raid-bot.sql
@@ -39,6 +39,7 @@ CREATE TABLE `cleanup` (
`raid_id` int(10) unsigned NOT NULL,
`chat_id` bigint(20) NOT NULL,
`message_id` bigint(20) unsigned NOT NULL,
+ `type` VARCHAR(20) NULL,
`date_of_posting` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/sql/upgrade/2.1.229.2.sql b/sql/upgrade/2.1.229.2.sql
new file mode 100644
index 00000000..4e265efe
--- /dev/null
+++ b/sql/upgrade/2.1.229.2.sql
@@ -0,0 +1 @@
+ALTER TABLE `cleanup` ADD COLUMN IF NOT EXISTS `type` VARCHAR(20) NULL AFTER `message_id`;