From 0d1e655a9e6fb507a105d24a67005f30724d9332 Mon Sep 17 00:00:00 2001 From: JulesText Date: Wed, 12 Jan 2022 18:43:28 +1100 Subject: [PATCH] mid-build save files --- functions.tactics.php | 9 +++++++-- functions.util.php | 7 +++++++ tactics_process.php | 12 ++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/functions.tactics.php b/functions.tactics.php index 3d49375..83fb3a3 100644 --- a/functions.tactics.php +++ b/functions.tactics.php @@ -318,6 +318,8 @@ function conditional_tactics($config, $tactic_ids = FALSE) { # process each tactic foreach ($tactics as $t) { + $response['msg'] .= PHP_EOL . 'processed tactic_id ' . $t['tactic_id'] . PHP_EOL; + $update = FALSE; /* @@ -444,6 +446,9 @@ function conditional_tactics($config, $tactic_ids = FALSE) { ) { if ($t['action'] == 'none') { $t['status'] = 'executed'; + } else if ($t['action'] == 'alert') { + $response['alert'] = TRUE; + $t['status'] = 'executed'; } else { $t['status'] = 'actionable'; if (!is_null($t['from_amount'])) $amount = ($t['from_amount'] + 0) . ' '; @@ -487,9 +492,9 @@ function conditional_tactics($config, $tactic_ids = FALSE) { } if (empty($tactics)) { - $response['msg'] .= 'no tactics found' . PHP_EOL; + $response['msg'] .= PHP_EOL . 'no tactics found' . PHP_EOL; } else { - $response['msg'] .= count($tactics) . ' tactics found, '; + $response['msg'] .= PHP_EOL . count($tactics) . ' tactics found, '; if (empty($response['result'])) $response['msg'] .= '0 updated' . PHP_EOL; else diff --git a/functions.util.php b/functions.util.php index 23f8143..b4bb57b 100644 --- a/functions.util.php +++ b/functions.util.php @@ -12,8 +12,15 @@ function process($response, $config) { /* send notification message to alert bot */ if ($response['alert']) { + // html output is not developed yet // if api returns html, this will throw an error + // so use strip_tags to remove html code $response['msg'] = strip_tags($response['msg']); + // and also replace < and > symbols within plain text + $response['msg'] = str_replace('<=', 'LE', $response['msg']); + $response['msg'] = str_replace('<', 'LT', $response['msg']); + $response['msg'] = str_replace('>=', 'GE', $response['msg']); + $response['msg'] = str_replace('>', 'GT', $response['msg']); $config['url'] = $config['chat_url'] . '/sendMessage?chat_id=' . $config['chat_id'] . diff --git a/tactics_process.php b/tactics_process.php index b8e9bcc..8630f53 100644 --- a/tactics_process.php +++ b/tactics_process.php @@ -2,24 +2,26 @@ include('includes.php'); +$sep = '-------------------------------' . PHP_EOL; + $tactic_ids = FALSE; if(isset($_GET['tactic_ids'])) $tactic_ids = $_GET['tactic_ids']; $changed_ids = array(); $response = actionable_tactics($config, $tactic_ids); -$response['msg'] = 'actionable_tactics' . PHP_EOL . $response['msg']; +$response['msg'] = $sep . 'actionable_tactics' . PHP_EOL . $response['msg']; process($response, $config); foreach ($response['result'] as $key => $val) array_push($changed_ids, $key); $response = ordered_tactics($config, $tactic_ids); -$response['msg'] = 'ordered_tactics' . PHP_EOL . $response['msg']; +$response['msg'] = $sep . 'ordered_tactics' . PHP_EOL . $response['msg']; process($response, $config); foreach ($response['result'] as $key => $val) array_push($changed_ids, $key); $response = conditional_tactics($config, $tactic_ids); -$response['msg'] = 'conditional_tactics' . PHP_EOL . $response['msg']; +$response['msg'] = $sep . 'conditional_tactics' . PHP_EOL . $response['msg']; process($response, $config); foreach ($response['result'] as $key => $val) array_push($changed_ids, $key); @@ -28,7 +30,7 @@ $changed_ids = dedupe_array($changed_ids); $changed_ids = implode(',', $changed_ids); $response = trigger_tactics($config, $changed_ids); - $response['msg'] = 'trigger_tactics ' . PHP_EOL . $response['msg']; + $response['msg'] = $sep . 'trigger_tactics ' . PHP_EOL . $response['msg']; process($response, $config); if ($response['count']) { $tactic_ids = implode(',', $response['result']); @@ -38,4 +40,6 @@ } } +echo $sep; + include('system_metrics.php');