1
0
mirror of https://github.com/serega404/VodokanalBot.git synced 2025-04-21 06:20:46 +03:00

Urlendcode fix

This commit is contained in:
Sergey Karmanov 2021-08-28 13:39:38 +03:00
parent 888b663520
commit 180875a42d
Signed by: serega404
GPG Key ID: 97CADD982D88DF68

View File

@ -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 {