@@ -313,51 +313,92 @@ function isPointInsidePolygon($point, $vertices) {
313
313
314
314
$ chats_geofence = $ chats_raidlevel = $ webhook_chats = $ chats_by_pokemon = [];
315
315
if ($ send_updates == true ) {
316
+ // Update raid polls and send alerts of updates
316
317
require_once (LOGIC_PATH .'/update_raid_poll.php ' );
317
318
$ tg_json = update_raid_poll ($ raid_id , $ raid , false , $ tg_json , true );
318
319
if ($ wasBossUpdated ) $ tg_json = alarm ($ raid , false , 'new_boss ' , '' , $ tg_json );
319
- if (!empty ($ config ->WEBHOOK_CHATS_BY_POKEMON [0 ]) && !$ no_auto_posting ) {
320
- foreach ($ config ->WEBHOOK_CHATS_BY_POKEMON as $ rule ) {
321
- if (isset ($ rule ['pokemon_id ' ]) && $ rule ['pokemon_id ' ] == $ pokemon && (!isset ($ rule ['form_id ' ]) or (isset ($ rule ['form_id ' ]) && $ rule ['form_id ' ] == $ form ))) {
322
- foreach ($ rule ['chats ' ] as $ rule_chat ) {
323
- // If the raid isn't already posted to the chats specified in WEBHOOK_CHATS_BY_POKEMON, we add it to the array
324
- if (!isset ($ cleanup_data [$ raid_id ]) or !in_array ($ rule_chat , $ cleanup_data [$ raid_id ])) {
325
- $ chats_by_pokemon [] = $ rule_chat ;
320
+ // Post hatched Pokemon to their respective chats if configured
321
+ // Start share_chats backwards compatibility
322
+ if (!$ config ->CHATS_SHARE ) {
323
+ if (!empty ($ config ->WEBHOOK_CHATS_BY_POKEMON [0 ]) && !$ no_auto_posting ) {
324
+ foreach ($ config ->WEBHOOK_CHATS_BY_POKEMON as $ rule ) {
325
+ if (isset ($ rule ['pokemon_id ' ]) && $ rule ['pokemon_id ' ] == $ pokemon && (!isset ($ rule ['form_id ' ]) or (isset ($ rule ['form_id ' ]) && $ rule ['form_id ' ] == $ form ))) {
326
+ foreach ($ rule ['chats ' ] as $ rule_chat ) {
327
+ // If the raid isn't already posted to the chats specified in WEBHOOK_CHATS_BY_POKEMON, we add it to the array
328
+ if (!isset ($ cleanup_data [$ raid_id ]) or !in_array ($ rule_chat , $ cleanup_data [$ raid_id ])) {
329
+ $ chats_by_pokemon [] = $ rule_chat ;
330
+ }
331
+ }
332
+ }
333
+ }
334
+ }
335
+ // End chats_share backwards compatibility
336
+ }else {
337
+ if (!empty ($ config ->CHATS_SHARE ['webhook ' ]['by_pokemon ' ]) && !$ no_auto_posting ) {
338
+ foreach ($ config ->CHATS_SHARE ['webhook ' ]['by_pokemon ' ] as $ rule ) {
339
+ if (isset ($ rule ['pokemon_id ' ]) && $ rule ['pokemon_id ' ] == $ pokemon && (!isset ($ rule ['form_id ' ]) or (isset ($ rule ['form_id ' ]) && $ rule ['FORM_ID ' ] == $ form ))) {
340
+ foreach ($ rule ['chats ' ] as $ rule_chat ) {
341
+ if (!isset ($ cleanup_data [$ raid_id ]) or !in_array ($ rule_chat ['id ' ], $ cleanup_data [$ raid_id ])) {
342
+ $ chats_by_pokemon [] = $ rule_chat ;
343
+ }
326
344
}
327
345
}
328
346
}
329
347
}
330
348
}
349
+
331
350
if (empty ($ chats_by_pokemon )) continue ;
332
351
}else {
333
- // Get chats to share to by raid level and geofence id
334
- if ($ geofences != false ) {
335
- foreach ($ inside_geofences as $ geofence_id ) {
336
- $ const_geofence = 'WEBHOOK_CHATS_LEVEL_ ' . $ level . '_ ' . $ geofence_id ;
337
- $ const_geofence_chats = $ config ->{$ const_geofence } ?? [];
338
-
339
- if (!empty ($ const_geofence_chats )) {
340
- $ chats_geofence = explode (', ' , $ const_geofence_chats );
352
+ // Start share_chats backwards compatibility
353
+ if (!$ config ->CHATS_SHARE ) {
354
+ // Get chats to share to by raid level and geofence id
355
+ if ($ geofences != false ) {
356
+ foreach ($ inside_geofences as $ geofence_id ) {
357
+ $ const_geofence = 'WEBHOOK_CHATS_LEVEL_ ' . $ level . '_ ' . $ geofence_id ;
358
+ $ const_geofence_chats = $ config ->{$ const_geofence } ?? [];
359
+
360
+ if (!empty ($ const_geofence_chats )) {
361
+ $ chats_geofence = explode (', ' , $ const_geofence_chats );
362
+ }
341
363
}
342
364
}
343
- }
344
365
345
- // Get chats to share to by raid level
346
- $ const = 'WEBHOOK_CHATS_LEVEL_ ' . $ level ;
347
- $ const_chats = $ config ->{$ const } ?? [];
366
+ // Get chats to share to by raid level
367
+ $ const = 'WEBHOOK_CHATS_LEVEL_ ' . $ level ;
368
+ $ const_chats = $ config ->{$ const } ?? [];
348
369
349
- if (!empty ($ const_chats )) {
350
- $ chats_raidlevel = explode (', ' , $ const_chats );
351
- }
370
+ if (!empty ($ const_chats )) {
371
+ $ chats_raidlevel = explode (', ' , $ const_chats );
372
+ }
352
373
353
- // Get chats
354
- if (!empty ($ config ->WEBHOOK_CHATS_ALL_LEVELS )) {
355
- $ webhook_chats = explode (', ' , $ config ->WEBHOOK_CHATS_ALL_LEVELS );
374
+ // Get chats
375
+ if (!empty ($ config ->WEBHOOK_CHATS_ALL_LEVELS )) {
376
+ $ webhook_chats = explode (', ' , $ config ->WEBHOOK_CHATS_ALL_LEVELS );
377
+ }
378
+ // End chats_share backwards compatibility
379
+ }else {
380
+ if ($ geofences != false ) {
381
+ foreach ($ inside_geofences as $ geofence_id ) {
382
+ $ geofence_chats_all = $ config ->CHATS_SHARE ['webhook ' ]['geofences ' ][$ geofence_id ]['all ' ] ?? [];
383
+ $ geofence_chats_by_level = $ config ->CHATS_SHARE ['webhook ' ]['geofences ' ][$ geofence_id ][$ level ] ?? [];
384
+
385
+ if (!empty ($ geofence_chats_all )) {
386
+ $ chats_geofence = array_merge ($ chats_geofence , $ geofence_chats_all );
387
+ }
388
+ if (!empty ($ geofence_chats_by_level )) {
389
+ $ chats_geofence = array_merge ($ chats_geofence , $ geofence_chats_by_level );
390
+ }
391
+ }
392
+ }
393
+ // Get chats to share to by raid level
394
+ $ chats_raidlevel = $ config ->CHATS_SHARE ['webhook ' ][$ level ] ?? [];
395
+
396
+ // Get chats
397
+ $ webhook_chats = $ config ->CHATS_SHARE ['webhook ' ]['all ' ] ?? [];
356
398
}
357
399
}
358
400
359
401
$ chats = array_merge ($ chats_geofence , $ chats_raidlevel , $ webhook_chats , $ chats_by_pokemon );
360
-
361
402
require_once (LOGIC_PATH .'/send_raid_poll.php ' );
362
403
if ($ metrics ) {
363
404
$ webhook_raids_posted_total ->inc ();
@@ -366,6 +407,5 @@ function isPointInsidePolygon($point, $vertices) {
366
407
$ tg_json = send_raid_poll ($ raid_id , $ chats , $ raid , $ tg_json );
367
408
}
368
409
}
369
-
370
410
// Telegram multicurl request.
371
411
curl_json_multi_request ($ tg_json );
0 commit comments