diff --git a/src/vodokanal.php b/src/vodokanal.php index fad937f..fe5424d 100644 --- a/src/vodokanal.php +++ b/src/vodokanal.php @@ -29,15 +29,17 @@ foreach ($html->find('td[bgcolor="#ffffff"]') as $e) { if (strcasecmp(reset($date), $dateNow) == 0) { // get current date posts // remove date from content $content = str_replace(reset($date), "", $e->plaintext); + $content = htmlspecialchars_decode($content); $content = str_replace("\r\n \r\n", "", $content); $content = str_replace("\n\n", "", $content); + display_message($content); // add post to array $all_elements[] = $content; } } if ($all_elements == null) { - echo "Posts not dound"; + echo "Posts not dound\n"; exit; } @@ -51,7 +53,7 @@ if ($db != null) { send_telegram_message($e); } } else { - echo "No changes."; + echo "No changes.\n"; exit; } } else { @@ -61,15 +63,22 @@ if ($db != null) { } } - // save posts to database - $json = json_encode($all_elements, JSON_UNESCAPED_UNICODE); - file_put_contents("db.json", $json); +// save posts to database +$json = json_encode($all_elements, JSON_UNESCAPED_UNICODE); +file_put_contents("db.json", $json); + +function display_message($message) +{ + echo "---- START MESSAGE ----\n"; + echo $message . "\n"; + echo "---- END MESSAGE ----\n"; +} function send_telegram_message($message) { - $message = str_replace(" ", "%20", $message); // fix for telegram + $t_message = urlencode($message); // Url fix global $config; - $obj = json_decode(file_get_contents("https://api.telegram.org/bot" . $config['Telegram_token'] . "/sendMessage?chat_id=" . $config['Telegram_channel'] . "&disable_notification=" . $config['Send_silent'] . "&text=" . $message)); + $obj = json_decode(file_get_contents("https://api.telegram.org/bot" . $config['Telegram_token'] . "/sendMessage?chat_id=" . $config['Telegram_channel'] . "&disable_notification=" . $config['Send_silent'] . "&text=" . $t_message)); if ($http_response_header[0] != null && $http_response_header[0] == "HTTP/1.1 200 OK") { try {