<?php

    include_once 'Config.php';
    class Telegram extends Config {
        public function __construct(){
            parent::__construct();
        }

        public function Message($message){
            $botToken = $this::$token;
            $chatId = $this::$chat_id;
            
            $telegramApiUrl = "https://api.telegram.org/bot$botToken/sendMessage";

            // Set the message data with HTML formatting
            $data = array(
                'chat_id' => $chatId,
                'text' => $message,
                'parse_mode' => 'HTML',
            );

            // Create a new cURL resource
            $ch = curl_init();

            // Set cURL options
            curl_setopt($ch, CURLOPT_URL, $telegramApiUrl);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

            // Execute cURL request
            $response = curl_exec($ch);

            // Close cURL resource
            curl_close($ch);

            return $response;
        }
    }
?>