<?php
// telegram-bot.php

require_once __DIR__ . '/bootstrap.php';

$content = file_get_contents('php://input');
$update = json_decode($content, true);

if (!$update) {
    error_log("Received invalid JSON input: " . $content);
    exit('Invalid Input');
}

$bot = new Bot();
$bot->handleUpdate($update);

// ثبت درخواست
error_log(date('Y-m-d H:i:s') . " - Update processed: " . json_encode(['chat_id' => $update['message']['chat']['id'] ?? 'N/A', 'type' => $update['message']['text'] ?? 'other']) . "\n", 3, LOG_FILE);