diff --git a/config/defaults-config.json b/config/defaults-config.json index deb15239..20fee7db 100644 --- a/config/defaults-config.json +++ b/config/defaults-config.json @@ -39,6 +39,10 @@ "RAID_VIA_LOCATION_FUNCTION": "create", "RAID_EGG_DURATION":"60", "RAID_EGG_DURATION_ELITE":"1440", + "RAID_BOSS_LIST": false, + "RAID_BOSS_LIST_TITLE": "Raidbosses:", + "RAID_BOSS_LIST_RAID_LEVELS": [5,7,8,10], + "RAID_BOSS_LIST_ROW_LIMIT": "4", "RAID_DURATION":"45", "RAID_DURATION_ELITE":"30", "RAID_DURATION_CLOCK_STYLE": true, diff --git a/docs/config.rst b/docs/config.rst index e692c459..e2637f18 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -1034,6 +1034,14 @@ Config reference - Fully qualified HTTPS URL to ``raidpicture.php``\ , for example ``https://example.com/raidbot/raidpicture.php`` * - RAID_PIN_MESSAGE - Custom message added to the bottom of the raid overview messages + * - RAID_BOSS_LIST" + - Bool, adds a list of saved raid bosses to overview message + * - RAID_BOSS_LIST_TITLE + - String, title of the list + * - RAID_BOSS_LIST_RAID_LEVELS + - Array, list of raid levels included in the list + * - RAID_BOSS_LIST_ROW_LIMIT + - Int, limit the list to set number of rows * - RAID_POLL_HIDE_BUTTONS_POKEMON - List of Pokemon dex IDs for which voting buttons are disabled * - RAID_POLL_HIDE_BUTTONS_RAID_LEVEL diff --git a/logic/createRaidBossList.php b/logic/createRaidBossList.php new file mode 100644 index 00000000..428e61a8 --- /dev/null +++ b/logic/createRaidBossList.php @@ -0,0 +1,73 @@ +RAID_BOSS_LIST_RAID_LEVELS). ')'; + $q = my_query('SELECT pokedex_id,pokemon_form_id,date_start,date_end,concat(date_format(date_start,"%d%m%y%k"),date_format(date_end,"%d%m%y%k")) as arrkey,CASE WHEN date(date_start) = date(date_end) THEN 1 ELSE 0 END as sameDay FROM raid_bosses where raid_level in ' . $levelList . ' order by sameDay, date_start, date_end'); + $list = ''; + $prevStartDate = ''; + $data[0] = $data[1] = []; + // Save the results in easy to process format + foreach($q->fetchAll() as $row) { + $data[$row['sameDay']][$row['arrkey']][] = $row; + } + if(count($row) == 0) return ''; + $i = 1; + $list = $config->RAID_BOSS_LIST_TITLE; + // Print list of bosses that run for multiple days + foreach($data[0] as $tempRow) { + $list .= PHP_EOL . '- '; + foreach($tempRow as $num => $row) { + $pokemonName = get_local_pokemon_name($row['pokedex_id'], $row['pokemon_form_id']); + if($num != 0) $list .= ', '; + $list .= $pokemonName; + } + $dateStart = new dateTime($row['date_start']); + $dateEnd = new dateTime($row['date_end']); + $list .= ' ' . $dateStart->format($dateFormat) . ' - '. $dateEnd->format($dateFormat); + $i++; + if($i > $config->RAID_BOSS_LIST_ROW_LIMIT) break; + } + + // Print list of one day bosses + foreach($data[1] as $arrkey => $tempRow) { + $startDate = substr($arrkey, 0, 6); + if($list != '' && $prevStartDate != $startDate) $list.= PHP_EOL . PHP_EOL; + foreach($tempRow as $num => $row) { + $dateStart = new dateTime($row['date_start']); + $dateEnd = new dateTime($row['date_end']); + if($num == 0){ + if($prevStartDate != $startDate) { + $list .= $dateStart->format($dateFormat); + } + $list .= PHP_EOL . '- '; + } + $pokemonName = get_local_pokemon_name($row['pokedex_id'], $row['pokemon_form_id']); + if($num != 0) $list .= ', '; + $list .= $pokemonName; + $prevStartDate = $startDate; + } + $list .= ' ' . $dateStart->format($timeFormat) . ' - ' . $dateEnd->format($timeFormat); + } + return $list; +} +?> \ No newline at end of file diff --git a/logic/get_overview.php b/logic/get_overview.php index cb9850c4..a8261700 100644 --- a/logic/get_overview.php +++ b/logic/get_overview.php @@ -1,5 +1,6 @@ RAID_BOSS_LIST) { + $msg .= createRaidBossList() . CR . CR; + } //Add custom message from the config. if (!empty($config->RAID_PIN_MESSAGE)) { $msg .= $config->RAID_PIN_MESSAGE; @@ -105,6 +109,9 @@ function get_overview( $active_raids, $chat_title, $chat_username ) $msg .= (($att['count_want_invite'] > 0) ? EMOJI_WANT_INVITE . $att['count_want_invite'] : ''); $msg .= CR . CR; } + if($config->RAID_BOSS_LIST) { + $msg .= createRaidBossList() . CR . CR; + } //Add custom message from the config. if (!empty($config->RAID_PIN_MESSAGE)) { $msg .= $config->RAID_PIN_MESSAGE;