This commit is contained in:
lizandrogd
2026-01-21 02:45:59 -05:00
parent edfa5f68d9
commit 845762f916
10 changed files with 207 additions and 8 deletions
+5
View File
@@ -51,6 +51,11 @@ class BotService {
return;
}
// Si el usuario ha desactivado el bot manualmente (toggle), no responder
if (isset($user['bot_enabled']) && !$user['bot_enabled']) {
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']]);