-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.php
24 lines (20 loc) · 828 Bytes
/
bot.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
// config.php
define('BOT_TOKEN', '2038195983:AAERggKgyiM3zaND0rHo-2TLihk5WkNWUms'); // ضع رمز التوكن الخاص بك هنا
define('API_URL', 'https://api.telegram.org/bot' . BOT_TOKEN . '/');
// Function to send message
function sendMessage($chat_id, $text) {
$url = API_URL . 'sendMessage?chat_id=' . $chat_id . '&text=' . urlencode($text);
file_get_contents($url);
}
// Get the updates from Telegram
$update = file_get_contents('php://input');
$update = json_decode($update, TRUE);
if (isset($update['message'])) {
$chat_id = $update['message']['chat']['id'];
$message_text = $update['message']['text'];
// Here you can add more logic to respond differently based on the message text
$response_text = "You said: " . $message_text;
sendMessage($chat_id, $response_text);
}
?>