This commit is contained in:
lizandrogd
2026-01-21 02:22:29 -05:00
parent 3fffb0d023
commit b1961f0116
35 changed files with 1006 additions and 122 deletions
+8 -2
View File
@@ -35,7 +35,13 @@ class BotService {
if ($this->processSpecialCommands($phoneNumber, $messageText)) {
return;
}
// Si el asesor ya respondió después del último mensaje del usuario, frenar al bot
$lastIncoming = $this->db->fetch("SELECT created_at FROM conversations WHERE user_id = :uid AND direction = 'incoming' ORDER BY created_at DESC LIMIT 1", ['uid' => $user['id']]);
$lastOutgoing = $this->db->fetch("SELECT created_at FROM conversations WHERE user_id = :uid AND direction = 'outgoing' ORDER BY created_at DESC LIMIT 1", ['uid' => $user['id']]);
if ($lastOutgoing && $lastIncoming && strtotime($lastOutgoing['created_at']) >= strtotime($lastIncoming['created_at'])) {
// El asesor ya respondió, no enviar respuestas automáticas
return;
}
// Verificar si el usuario está en un menú
if ($user['current_menu_id']) {
$this->processMenuSelection($user, $messageText);
@@ -85,7 +91,7 @@ class BotService {
$this->exitMenu($phoneNumber);
return true;
case 'help':
case 'asesor':
case 'ayuda':
$this->showHelp($phoneNumber);
return true;