Skip to content

Commit 32ce9dc

Browse files
committed
Backwards compatibility fixes
1 parent 5dcfef4 commit 32ce9dc

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

commands/raid_from_webhook.php

+12-6
Original file line numberDiff line numberDiff line change
@@ -312,22 +312,22 @@ function isPointInsidePolygon($point, $vertices) {
312312
'shadow' => (in_array($level, RAID_LEVEL_SHADOW) ? 1 : 0),
313313
]);
314314

315-
$chats_geofence = $chats_raidlevel = $webhook_chats = $chats_by_pokemon = [];
315+
$chats_geofence = $chats_raidlevel = $webhook_chats = $chats_by_pokemon = $chats = [];
316316
if($send_updates == true) {
317317
// Update raid polls and send alerts of updates
318318
require_once(LOGIC_PATH .'/update_raid_poll.php');
319319
$tg_json = update_raid_poll($raid_id, $raid, false, $tg_json, true);
320320
if($wasBossUpdated) $tg_json = alarm($raid, false, 'new_boss', '', $tg_json);
321321
// Post hatched Pokemon to their respective chats if configured
322322
// Start share_chats backwards compatibility
323-
if(!$config->CHATS_SHARE) {
323+
if(!isset($config->CHATS_SHARE)) {
324324
if(!empty($config->WEBHOOK_CHATS_BY_POKEMON[0]) && !$no_auto_posting) {
325325
foreach($config->WEBHOOK_CHATS_BY_POKEMON as $rule) {
326326
if(isset($rule['pokemon_id']) && $rule['pokemon_id'] == $pokemon && (!isset($rule['form_id']) or (isset($rule['form_id']) && $rule['form_id'] == $form))) {
327327
foreach($rule['chats'] as $rule_chat) {
328328
// If the raid isn't already posted to the chats specified in WEBHOOK_CHATS_BY_POKEMON, we add it to the array
329329
if(!isset($cleanup_data[$raid_id]) or !in_array($rule_chat, $cleanup_data[$raid_id])) {
330-
$chats_by_pokemon[] = $rule_chat;
330+
$chats_by_pokemon[] = create_chat_object([$rule_chat]);
331331
}
332332
}
333333
}
@@ -351,7 +351,7 @@ function isPointInsidePolygon($point, $vertices) {
351351
if(empty($chats_by_pokemon)) continue;
352352
}else {
353353
// Start share_chats backwards compatibility
354-
if(!$config->CHATS_SHARE) {
354+
if(!isset($config->CHATS_SHARE)) {
355355
// Get chats to share to by raid level and geofence id
356356
if($geofences != false) {
357357
foreach($inside_geofences as $geofence_id) {
@@ -376,7 +376,11 @@ function isPointInsidePolygon($point, $vertices) {
376376
if(!empty($config->WEBHOOK_CHATS_ALL_LEVELS)) {
377377
$webhook_chats = explode(',', $config->WEBHOOK_CHATS_ALL_LEVELS);
378378
}
379-
// End chats_share backwards compatibility
379+
$chats_combined = array_merge($chats_geofence, $chats_raidlevel, $webhook_chats);
380+
foreach($chats_combined as $chat) {
381+
$chats[] = create_chat_object([$chat]);
382+
}
383+
// End chats_share backwards compatibility
380384
}else {
381385
if($geofences != false) {
382386
foreach($inside_geofences as $geofence_id) {
@@ -396,16 +400,18 @@ function isPointInsidePolygon($point, $vertices) {
396400

397401
// Get chats
398402
$webhook_chats = $config->CHATS_SHARE['webhook']['all'] ?? [];
403+
$chats = array_merge($chats_geofence, $chats_raidlevel, $webhook_chats);
399404
}
400405
}
401406

402-
$chats = array_merge($chats_geofence, $chats_raidlevel, $webhook_chats, $chats_by_pokemon);
403407
require_once(LOGIC_PATH .'/send_raid_poll.php');
404408
if($metrics) {
405409
$webhook_raids_posted_total->inc();
406410
}
407411
if(count($chats) > 0) {
408412
$tg_json = send_raid_poll($raid_id, $chats, $raid, $tg_json);
413+
}elseif(count($chats_by_pokemon) > 0) {
414+
$tg_json = send_raid_poll($raid_id, $chats_by_pokemon, $raid, $tg_json);
409415
}
410416
}
411417
// Telegram multicurl request.

logic/key_util.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function share_keys($id, $action, $update, $raidLevel = '', $chats = [], $hideGe
5151
}
5252

5353
// Start share_chats backwards compatibility
54-
if(!$config->CHATS_SHARE) {
54+
if(!isset($config->CHATS_SHARE)) {
5555
// Add buttons for predefined sharing chats.
5656
// Default SHARE_CHATS or special chat list via $chats?
5757
if(empty($chats)) {

mods/vote_time.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,12 @@
159159
// Check if RAID has no participants AND Raid should be shared to another chat at first participant
160160
// AND target chat was set in config AND Raid was not shared to target chat before
161161
// Start share_chats backwards compatibility
162-
if(!$config->CHATS_SHARE) {
162+
if(!isset($config->CHATS_SHARE)) {
163163
if($count_att == 0 && $config->SHARE_AFTER_ATTENDANCE && !empty($config->SHARE_CHATS_AFTER_ATTENDANCE)){
164164
// Send the message.
165165
require_once(LOGIC_PATH . '/send_raid_poll.php');
166-
$tg_json = send_raid_poll($raidId, $config->SHARE_CHATS_AFTER_ATTENDANCE, $raid, $tg_json);
166+
$chats = [create_chat_object([$config->SHARE_CHATS_AFTER_ATTENDANCE])];
167+
$tg_json = send_raid_poll($raidId, $chats, $raid, $tg_json);
167168
}
168169
// End share_chats backwards compatibility
169170
}else {

0 commit comments

Comments
 (0)