mirror of
https://github.com/serega404/VodokanalBot.git
synced 2025-04-21 14:30:46 +03:00
Urlendcode fix
This commit is contained in:
parent
888b663520
commit
180875a42d
@ -29,15 +29,17 @@ foreach ($html->find('td[bgcolor="#ffffff"]') as $e) {
|
|||||||
if (strcasecmp(reset($date), $dateNow) == 0) { // get current date posts
|
if (strcasecmp(reset($date), $dateNow) == 0) { // get current date posts
|
||||||
// remove date from content
|
// remove date from content
|
||||||
$content = str_replace(reset($date), "", $e->plaintext);
|
$content = str_replace(reset($date), "", $e->plaintext);
|
||||||
|
$content = htmlspecialchars_decode($content);
|
||||||
$content = str_replace("\r\n \r\n", "", $content);
|
$content = str_replace("\r\n \r\n", "", $content);
|
||||||
$content = str_replace("\n\n", "", $content);
|
$content = str_replace("\n\n", "", $content);
|
||||||
|
display_message($content);
|
||||||
// add post to array
|
// add post to array
|
||||||
$all_elements[] = $content;
|
$all_elements[] = $content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($all_elements == null) {
|
if ($all_elements == null) {
|
||||||
echo "Posts not dound";
|
echo "Posts not dound\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +53,7 @@ if ($db != null) {
|
|||||||
send_telegram_message($e);
|
send_telegram_message($e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo "No changes.";
|
echo "No changes.\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -61,15 +63,22 @@ if ($db != null) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// save posts to database
|
// save posts to database
|
||||||
$json = json_encode($all_elements, JSON_UNESCAPED_UNICODE);
|
$json = json_encode($all_elements, JSON_UNESCAPED_UNICODE);
|
||||||
file_put_contents("db.json", $json);
|
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)
|
function send_telegram_message($message)
|
||||||
{
|
{
|
||||||
$message = str_replace(" ", "%20", $message); // fix for telegram
|
$t_message = urlencode($message); // Url fix
|
||||||
global $config;
|
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") {
|
if ($http_response_header[0] != null && $http_response_header[0] == "HTTP/1.1 200 OK") {
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user