Skip to content

Commit

Permalink
Added raid poll template feature + 'can_inv' key
Browse files Browse the repository at this point in the history
- Raid poll template config allows users to nearly fully customize the order of their raid poll buttons
- Added 'can_inv' key to raid polls. With this the user can let others know that they themself aren't playing the raid, but they can invite others who want to play (useful for some low level raids)
  • Loading branch information
Ninjasoturi committed Aug 12, 2021
1 parent 88447ee commit 44ec321
Show file tree
Hide file tree
Showing 22 changed files with 284 additions and 177 deletions.
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,14 +459,12 @@ 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_ORDER` to the customize the order of the buttons rows for the raid polls. The default is 'extra,teamlvl,time,pokemon,status' but can be changed to any other order, e.g. 'time,pokemon,extra,status,teamlvl'.
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.

Set `RAID_POLL_HIDE_BUTTONS_RAID_LEVEL` to the raid levels (1-5 and X) 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.
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.

Set `RAID_POLL_HIDE_BUTTONS_POKEMON` to the pokedex IDs (e.g. '1' for Bulbasaur) or pokedex ID and form combined by a minus sign (e.g. '386-normal' for Deoxys Normal form or '386-attack' for Deoxys Attack form) for which the voting buttons under the raid poll should be hidden.

Set `RAID_POLL_HIDE_BUTTONS_TEAM_LVL` to true to hide the team and level+/- buttons below each raid poll. That users are still able to set their team and level when the buttons are hidden, take a look at the '/trainer' command.

Set `RAID_POLL_HIDE_DONE_CANCELED` to true to hide the users which are done with the raid or canceled and do not longer attend the raid.

Set `RAID_EX_GYM_MARKER` to set the marker for ex-raid gyms. You can use a predefined icon using the value 'icon' or any own marker, e.g. 'EX'.
Expand Down Expand Up @@ -1189,10 +1187,9 @@ To keep local data, such as `pokemon` table and Pokemon icons directory, up to d
| RAID_PIN_MESSAGE| Custom message added to the bottom of the raid overview messages |
| RAID_POLL_HIDE_BUTTONS_POKEMON| List of Pokemon dex IDs for which voting buttons are disabled |
| RAID_POLL_HIDE_BUTTONS_RAID_LEVEL| List of raid levels for which voting buttons are disabled |
| RAID_POLL_HIDE_BUTTONS_TEAM_LVL| Bool, true to hide the team and level+/- buttons below each raid poll |
| RAID_POLL_HIDE_DONE_CANCELED| Bool, hide the Done and Cancel buttons from raid polls |
| RAID_POLL_HIDE_USERS_TIME| In minutes, after what time the previous raid slots are hidden from a raid poll |
| RAID_POLL_UI_ORDER| Order of elements in text based raid polls. Valid elements are: `extra, teamll, time, pokemon, status` |
| RAID_POLL_UI_TEMPLATE| Array, Order of elements in 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`. |
| RAID_POLL_POKEMON_NAME_FIRST_LINE| Shows the Name of the Pokemon instead of `Raid:` - Good for Message Preview to see which Pokemon the Raid will be. |
| RAID_POLL_CALCULATE_MAPS_ROUTE| TRUE: Will show the Route to the Gym while clicking onto gym-address - FALSE: Will open Google Maps and only show the gym as a point in the map. |
| RAID_POLL_SHOW_NICK_OVER_NAME | Show users Telegram @username instead of name |
Expand All @@ -1204,7 +1201,6 @@ To keep local data, such as `pokemon` table and Pokemon icons directory, up to d
| RAID_POLL_ENABLE_HYPERLINKS_IN_NAMES | Enable hyperlinks to user profiles in participant names in raid polls. It's recommended to disable this if you're running the bot in a supergroup and with `RAID_PICTURE` mode on. |
| RAID_POLL_SHOW_NICK_OVER_NAME | Bool, If `CUSTOM_TRAINERNAME` is `false`, display user's Telegram nickname (@name) instead of name (first name + last name)|
| RAID_ENDED_HIDE_KEYS | Bool, Hide the `Raid done` button in raid polls after the raid has ended |
| RAID_REMOTEPASS_USERS | Bool, allow participation to raid polls with a remote pass |
| RAID_REMOTEPASS_USERS_LIMIT | Integer, How many remote participants to allow into a single raid |
| RAID_WANT_INVITE | Bool, allow participants to indicate that they wish to be invited to the raid |
| RAID_SLOTS| Amount of minutes between raid poll voting slots |
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.224.1
2.1.224.7
4 changes: 2 additions & 2 deletions config/config.json.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"VERSION":"2.1.224.1",
"VERSION":"2.1.224.7",
"DB_HOST":"localhost",
"DB_NAME":"your_database_name",
"DB_USER":"your_database_user",
Expand All @@ -11,9 +11,9 @@
"MAINTAINER_ID":"your_tg_integer",
"BOT_NAME":"@RaidPokemonBot",
"BOT_ADMINS":"",
"LANGUAGE_PRIVATE":"",
"LANGUAGE_PUBLIC":"EN",
"TIMEZONE":"Europe/Berlin",
"CUSTOM_TRAINERNAME": true,
"SHARE_CHATS":""
"RAID_POLL_UI_TEMPLATE":[["alone","extra","extra_alien","remote","inv_plz","can_inv","ex_inv"],["teamlvl"],["time"],["pokemon"],["refresh","alarm","here","late","done","cancel"]],
}
4 changes: 1 addition & 3 deletions config/defaults-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"RAID_VOTE_TEXT": false,
"RAID_LATE_MSG": true,
"RAID_LATE_TIME":"3",
"RAID_REMOTEPASS_USERS": true,
"RAID_REMOTEPASS_USERS_LIMIT":"5",
"RAID_WANT_INVITE": true,
"RAID_CODE_POKEMON":"1,7,4,25,12,143,19,16,52",
Expand All @@ -71,11 +70,10 @@
"RAID_PICTURE_POKEMON_ICONS":"pokemon,PokeMiners,ZeChrales",
"RAID_PICTURE_POKEMON_FALLBACK":"images/shadow_pika.png",
"RAID_PICTURE_POKEMON_TYPES": true,
"RAID_POLL_UI_ORDER":"extra,teamlvl,time,pokemon,status",
"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_HIDE_USERS_TIME":"10",
"RAID_POLL_HIDE_BUTTONS_RAID_LEVEL":"1,2,3",
"RAID_POLL_HIDE_BUTTONS_POKEMON":"",
"RAID_POLL_HIDE_BUTTONS_TEAM_LVL": true,
"RAID_POLL_HIDE_DONE_CANCELED": false,
"RAID_POLL_POKEMON_NAME_FIRST_LINE":false,
"RAID_POLL_CALCULATE_MAPS_ROUTE":true,
Expand Down
1 change: 1 addition & 0 deletions constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
defined('EMOJI_WANT_INVITE')or define('EMOJI_WANT_INVITE', iconv('UCS-4LE', 'UTF-8', pack('V', 0x1F4E5)));
defined('EMOJI_IN_PERSON') or define('EMOJI_IN_PERSON', iconv('UCS-4LE', 'UTF-8', pack('V', 0x1F9E1)));
defined('EMOJI_ALIEN') or define('EMOJI_ALIEN', iconv('UCS-4LE', 'UTF-8', pack('V', 0x1F47D)));
defined('EMOJI_CAN_INVITE')or define('EMOJI_CAN_INVITE', iconv('UCS-4LE', 'UTF-8', pack('V', 0x1F47B)));

// Weather Icons.
defined('EMOJI_W_SUNNY') or define('EMOJI_W_SUNNY', iconv('UCS-4LE', 'UTF-8', pack('V', 0x2600)));
Expand Down
1 change: 1 addition & 0 deletions core/bot/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function migrate_config($config, $file){
$had_to_fix = false;
foreach($config as $key => $val) {
// Make "True" and "False" real true and false
if(is_array($val)) continue;
if(strtolower($val) == "true") {
$had_to_fix = true;
$config[$key] = true;
Expand Down
24 changes: 24 additions & 0 deletions lang/language.json
Original file line number Diff line number Diff line change
Expand Up @@ -3119,6 +3119,30 @@
"PL": "TRANSLATE",
"FI": "Ei enää toivo kutsua."
},
"alert_can_invite": {
"NL": "TRANSLATE",
"DE": "TRANSLATE",
"EN": "Is not attending but can send invites.",
"IT": "TRANSLATE",
"PT-BR": "TRANSLATE",
"RU": "TRANSLATE",
"NO": "TRANSLATE",
"FR": "TRANSLATE",
"PL": "TRANSLATE",
"FI": "Ei osallistu raidiin, mutta voi lähettää kutsuja."
},
"alert_no_can_invite": {
"NL": "TRANSLATE",
"DE": "TRANSLATE",
"EN": "Is no longer able to invite others.",
"IT": "TRANSLATE",
"PT-BR": "TRANSLATE",
"RU": "TRANSLATE",
"NO": "TRANSLATE",
"FR": "TRANSLATE",
"PL": "TRANSLATE",
"FI": "Ei enää pysty kutsumaan muita."
},
"event": {
"NL": "TRANSLATE",
"DE": "Event",
Expand Down
20 changes: 20 additions & 0 deletions logic/alarm.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,26 @@ function alarm($raid_id_array, $user_id, $action, $info = '')
$msg_text .= EMOJI_CLOCK . SP . '<b>' . check_time($attendtime) . '</b>';
$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") {
debug_log('Alarm: ' . $action);
$msg_text = '<b>' . getTranslation('alert_can_invite', true, $recipient_language) . '</b>' . CR;
$msg_text .= EMOJI_CAN_INVITE . SP . $gymname . SP . '(' . $raidtimes . ')' . CR;
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
$msg_text .= EMOJI_CLOCK . SP . '<b>' . check_time($attendtime) . '</b>';
$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") {
debug_log('Alarm: ' . $action);
$msg_text = '<b>' . getTranslation('alert_no_can_invite', true, $recipient_language) . '</b>' . CR;
$msg_text .= EMOJI_CAN_INVITE . SP . $gymname . SP . '(' . $raidtimes . ')' . CR;
$msg_text .= EMOJI_SINGLE . SP . $username . CR;
$msg_text .= EMOJI_CLOCK . SP . '<b>' . check_time($attendtime) . '</b>';
$msg_text .= create_traincode_msg($trainercode);
$tg_json[] = sendMessage($answer['user_id'], $msg_text, true);
}
}
if(count($tg_json) > 0) curl_json_multi_request($tg_json);
Expand Down
12 changes: 7 additions & 5 deletions logic/get_overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ function get_overview( $active_raids, $chat_title, $chat_username )
$rs_att = my_query(
"
SELECT count(attend_time) AS count,
sum(want_invite = 0 && remote = 0) + sum(case when want_invite = 0 && remote = 0 then attendance.extra_in_person else 0 end) AS count_in_person,
sum(want_invite = 0 && remote = 1) + sum(case when want_invite = 0 && remote = 1 then attendance.extra_in_person else 0 end) AS count_remote,
sum(case when want_invite = 0 then attendance.extra_alien else 0 end) AS extra_alien,
sum(case when want_invite = 1 then 1 + attendance.extra_in_person else 0 end) AS count_want_invite
sum(want_invite = 0 && remote = 0 && can_invite = 0) + sum(case when want_invite = 0 && remote = 0 then attendance.extra_in_person else 0 end) AS count_in_person,
sum(want_invite = 0 && remote = 1 && can_invite = 0) + sum(case when want_invite = 0 && remote = 1 then attendance.extra_in_person else 0 end) AS count_remote,
sum(case when want_invite = 0 && can_invite = 0 then attendance.extra_alien else 0 end) AS extra_alien,
sum(case when want_invite = 1 && can_invite = 0 then 1 + attendance.extra_in_person else 0 end) AS count_want_invite,
sum(can_invite = 1) AS count_can_invite
FROM (
SELECT DISTINCT attend_time, user_id, extra_in_person, extra_alien, remote, want_invite
SELECT DISTINCT attend_time, user_id, extra_in_person, extra_alien, remote, want_invite, can_invite
FROM attendance
WHERE raid_id = {$raid_id}
AND attend_time IS NOT NULL
Expand All @@ -88,6 +89,7 @@ function get_overview( $active_raids, $chat_title, $chat_username )
// Add to message.
if ($att['count'] > 0) {
$msg .= EMOJI_GROUP . '<b> ' . ($att['count_in_person'] + $att['count_remote'] + $att['extra_alien'] + $att['count_want_invite']) . '</b> — ';
$msg .= ((($att['count_can_invite']) > 0) ? EMOJI_CAN_INVITE . ($att['count_can_invite']) . ' ' : '');
$msg .= ((($att['count_in_person']) > 0) ? EMOJI_IN_PERSON . ($att['count_in_person']) . ' ' : '');
$msg .= ((($att['count_remote']) > 0) ? EMOJI_REMOTE . ($att['count_remote']) . ' ' : '');
$msg .= ((($att['extra_alien']) > 0) ? EMOJI_ALIEN . ($att['extra_alien']) . ' ' : '');
Expand Down
2 changes: 1 addition & 1 deletion logic/get_raid.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function get_raid($raid_id)
raids.id, raids.user_id, raids.spawn, 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,
users.name, users.trainername, users.nick,
events.name as event_name, events.description as event_description, events.vote_key_mode as event_vote_key_mode, events.time_slots as event_time_slots, events.raid_duration as event_raid_duration, events.hide_raid_picture as event_hide_raid_picture, events.allow_remote as event_allow_remote, events.allow_invite as event_allow_invite,
events.name as event_name, events.description as event_description, events.vote_key_mode as event_vote_key_mode, events.time_slots as event_time_slots, events.raid_duration as event_raid_duration, events.hide_raid_picture as event_hide_raid_picture, events.poll_template as event_poll_template,
TIME_FORMAT(TIMEDIFF(end_time, UTC_TIMESTAMP()) + INTERVAL 1 MINUTE, \'%k:%i\') AS t_left
FROM raids
LEFT JOIN gyms
Expand Down
Loading

0 comments on commit 44ec321

Please sign in to comment.