<?php

include "config.php";

function sendTelegramMessage($message){

    global $BOT_TOKEN, $CHAT_ID;

    $url =
    "https://api.telegram.org/bot{$BOT_TOKEN}/sendMessage";

    $data = [
        "chat_id" => $CHAT_ID,
        "text" => $message
    ];

    $options = [
        "http" => [
            "header" =>
            "Content-type: application/x-www-form-urlencoded\r\n",

            "method" => "POST",

            "content" =>
            http_build_query($data)
        ]
    ];

    $context =
    stream_context_create($options);

    @file_get_contents(
        $url,
        false,
        $context
    );
}