Files
lastwar/admin/comandos.php

162 lines
6.2 KiB
PHP
Executable File

<?php
require_once __DIR__ . '/../includes/db.php';
require_once __DIR__ . '/../includes/session_check.php';
requireAdmin();
$pageTitle = 'Gestión de Comandos';
$templates = [];
try {
$pdo = getDbConnection();
$stmt = $pdo->query("SELECT id, name, telegram_command FROM recurrent_messages ORDER BY name");
$templates = $stmt->fetchAll();
} catch (Exception $e) {
$error = $e->getMessage();
}
require_once __DIR__ . '/../templates/header.php';
?>
<div class="d-flex justify-content-between align-items-center mb-4">
<h2><i class="bi bi-terminal"></i> Gestión de Comandos</h2>
</div>
<div class="alert alert-info">
<i class="bi bi-info-circle"></i> Los comandos se usan en Discord y Telegram anteponiendo <code>#</code> al nombre del comando.
</div>
<div class="row">
<div class="col-md-12">
<div class="card border-0 shadow-sm">
<div class="card-body">
<?php if (empty($templates)): ?>
<p class="text-muted text-center py-4">No hay plantillas con comandos</p>
<?php else: ?>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>#</th>
<th>Nombre</th>
<th>Comando</th>
<th>Uso</th>
</tr>
</thead>
<tbody>
<?php foreach ($templates as $template): ?>
<tr>
<td><?= $template['id'] ?></td>
<td><?= htmlspecialchars($template['name']) ?></td>
<td>
<?php if ($template['telegram_command']): ?>
<code>#<?= htmlspecialchars($template['telegram_command']) ?></code>
<?php else: ?>
<span class="text-muted">Sin comando</span>
<?php endif; ?>
</td>
<td>
<span class="badge bg-primary">Discord</span>
<span class="badge bg-info">Telegram</span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<div class="row mt-4">
<div class="col-md-12">
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-0">
<h5 class="mb-0"><i class="bi bi-discord"></i> Comandos de Discord</h5>
</div>
<div class="card-body">
<table class="table table-sm">
<thead>
<tr>
<th>Comando</th>
<th>Descripción</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>#comando</code></td>
<td>Envía la plantilla asociada</td>
</tr>
<tr>
<td><code>/comandos</code></td>
<td>Lista de comandos disponibles</td>
</tr>
<tr>
<td><code>/setlang [código]</code></td>
<td>Establece el idioma del usuario</td>
</tr>
<tr>
<td><code>/bienvenida</code></td>
<td>Envía mensaje de bienvenida</td>
</tr>
<tr>
<td><code>/agente</code></td>
<td>Cambia a modo IA</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="row mt-4">
<div class="col-md-12">
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-0">
<h5 class="mb-0"><i class="bi bi-telegram"></i> Comandos de Telegram</h5>
</div>
<div class="card-body">
<table class="table table-sm">
<thead>
<tr>
<th>Comando</th>
<th>Descripción</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>#comando</code></td>
<td>Envía la plantilla asociada</td>
</tr>
<tr>
<td><code>/start</code></td>
<td>Inicia el bot</td>
</tr>
<tr>
<td><code>/comandos</code></td>
<td>Lista de comandos disponibles</td>
</tr>
<tr>
<td><code>/setlang [código]</code></td>
<td>Establece el idioma del usuario</td>
</tr>
<tr>
<td><code>/bienvenida</code></td>
<td>Envía mensaje de bienvenida</td>
</tr>
<tr>
<td><code>/agente</code></td>
<td>Cambia a modo IA</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php require_once __DIR__ . '/../templates/footer.php'; ?>