requireAdmin(); $bot = new TelegramBot(); $message = ''; $messageType = ''; $webhookInfo = null; $botInfo = null; // Obtener información del bot $botMe = $bot->getMe(); if ($botMe && isset($botMe['ok']) && $botMe['ok']) { $botInfo = $botMe['result']; } // Verificar estado del webhook if ($_SERVER['REQUEST_METHOD'] === 'POST') { $action = $_POST['action'] ?? ''; if ($action === 'verificar') { $url = "https://api.telegram.org/bot{$config['telegram_bot_token']}/getWebhookInfo"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $result = json_decode($response, true); if ($result && isset($result['ok'])) { $webhookInfo = $result; $message = 'Información del webhook obtenida'; $messageType = 'success'; } else { $message = 'Error al obtener información del webhook'; $messageType = 'danger'; } } elseif ($action === 'borrar') { $url = "https://api.telegram.org/bot{$config['telegram_bot_token']}/deleteWebhook"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([])); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $result = json_decode($response, true); if ($result && isset($result['ok']) && $result['ok']) { $message = 'Webhook eliminado correctamente'; $messageType = 'success'; $webhookInfo = null; } else { $message = 'Error al eliminar webhook: ' . ($result['description'] ?? 'Desconocido'); $messageType = 'danger'; } } elseif ($action === 'configurar') { $webhookUrl = trim($_POST['webhook_url'] ?? ''); if (empty($webhookUrl)) { $message = 'Debes ingresar la URL del webhook'; $messageType = 'danger'; } elseif (!filter_var($webhookUrl, FILTER_VALIDATE_URL)) { $message = 'La URL ingresada no es válida'; $messageType = 'danger'; } else { $url = "https://api.telegram.org/bot{$config['telegram_bot_token']}/setWebhook"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ 'url' => $webhookUrl, 'allowed_updates' => ['message', 'callback_query'] ])); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $result = json_decode($response, true); if ($result && isset($result['ok']) && $result['ok']) { $message = "Webhook configurado correctamente en:\n" . htmlspecialchars($webhookUrl); $messageType = 'success'; } else { $message = 'Error al configurar webhook: ' . ($result['description'] ?? 'Desconocido'); $messageType = 'danger'; } } } } // Obtener estado actual del webhook $url = "https://api.telegram.org/bot{$config['telegram_bot_token']}/getWebhookInfo"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $webhookInfo = json_decode($response, true); $currentPage = 'webhook'; $pageTitle = 'Administración del Bot de Telegram'; ?> <?= $pageTitle ?> - Contenedor Ibiza

🤖 Administración del Bot de Telegram

Información del Bot

Nombre:

Username: @

ID:

Estado: Conectado

Token configurado correctamente
Error: No se pudo conectar con el bot. Verifica que el TELEGRAM_BOT_TOKEN esté configurado correctamente en .env
Estado del Webhook
✅ Webhook activo

URL:

  • Última actualización:
  • IP permitida:
  • Errores acumulados:
  • Actualizaciones pendientes:
⚠️ Webhook no configurado

No hay webhook configurado para este bot.

Error: No se pudo obtener información del webhook
⚙️ Configurar Webhook
URL sugerida basada en SITE_URL:
📝 Instrucciones:
  1. Asegúrate de que la URL sea accesible públicamente (no localhost)
  2. El dominio debe tener certificado SSL (HTTPS)
  3. Ejemplo de URL: https://contenedor-test.local:82/bot/webhook.php
📋 Comandos Disponibles
Comando Descripción
/start o /menu Muestra el menú interactivo con botones
/turnos Muestra la tabla completa de asignaciones
/semana o hoy Muestra quién tiene turno esta semana
/ayudantes Lista de todos los ayudantes
[Nombre] Busca los turnos de un ayudante específico
🔗 URLs de Referencia
Webhook:
/bot/webhook.php
Test del bot:
/bot/test.php