up
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
require_once 'config/config.php';
|
||||
|
||||
if ($argc < 2) {
|
||||
echo "Usage: php debug_user_state.php <phone_number>\n";
|
||||
exit(1);
|
||||
}
|
||||
$phone = $argv[1];
|
||||
$db = Database::getInstance();
|
||||
|
||||
$user = $db->fetch("SELECT * FROM users WHERE phone_number = :phone", ['phone' => $phone]);
|
||||
if (!$user) {
|
||||
echo "User not found for phone: $phone\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo "User: id={$user['id']} phone={$user['phone_number']} name={$user['name']}\n";
|
||||
echo "Flags: in_service={$user['in_service']} advisor_requested={$user['advisor_requested']} on_hold={$user['on_hold']} bot_paused_until={$user['bot_paused_until']} current_menu_id={$user['current_menu_id']} welcome_sent_at={$user['welcome_sent_at']}\n";
|
||||
|
||||
// Last messages
|
||||
$messages = $db->fetchAll("SELECT id, direction, message_type, content, created_at FROM conversations WHERE user_id = :uid ORDER BY created_at DESC LIMIT 20", ['uid' => $user['id']]);
|
||||
|
||||
echo "Last messages (most recent first):\n";
|
||||
foreach ($messages as $m) {
|
||||
$content = $m['content'];
|
||||
$short = mb_substr(strip_tags($content), 0, 120);
|
||||
echo " - [{$m['created_at']}] {$m['direction']} {$m['message_type']} id={$m['id']} content=" . json_encode($short) . "\n";
|
||||
}
|
||||
|
||||
// ConversationStateService data
|
||||
try {
|
||||
if (class_exists('ConversationStateService')) {
|
||||
$svc = new ConversationStateService();
|
||||
$state = $svc->getState($phone);
|
||||
echo "ConversationStateService state row: ";
|
||||
if ($state) {
|
||||
echo json_encode($state) . "\n";
|
||||
echo "Current menu via service: " . json_encode($svc->getCurrentMenuId($phone)) . "\n";
|
||||
} else {
|
||||
echo "(no state row)\n";
|
||||
}
|
||||
} else {
|
||||
echo "ConversationStateService not available\n";
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo "Error querying ConversationStateService: " . $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
// Recent operator activity
|
||||
$acts = $db->fetchAll("SELECT * FROM operator_activity WHERE user_id = :uid ORDER BY created_at DESC LIMIT 10", ['uid' => $user['id']]);
|
||||
if ($acts) {
|
||||
echo "Recent operator activity:\n";
|
||||
foreach ($acts as $a) {
|
||||
echo " - [{$a['created_at']}] action={$a['action']} operator_id={$a['operator_id']} details=" . ($a['details'] ?? '') . "\n";
|
||||
}
|
||||
} else {
|
||||
echo "No operator activity found\n";
|
||||
}
|
||||
|
||||
echo "Done\n";
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
require_once 'config/config.php';
|
||||
|
||||
if ($argc < 2) {
|
||||
echo "Usage: php set_menu_option_request_documents.php <menu_option_id>\n";
|
||||
exit(1);
|
||||
}
|
||||
$id = intval($argv[1]);
|
||||
|
||||
$db = Database::getInstance();
|
||||
$opt = $db->fetch("SELECT * FROM menu_options WHERE id = :id", ['id' => $id]);
|
||||
if (!$opt) {
|
||||
echo "Menu option not found: $id\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$db->update('menu_options', ['action_type' => 'request_documents'], 'id = :id', ['id' => $id]);
|
||||
|
||||
echo "Updated menu_option id=$id to action_type=request_documents\n";
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
require_once 'config/config.php';
|
||||
|
||||
$phone = $argv[1] ?? '573022548060';
|
||||
$db = Database::getInstance();
|
||||
$user = $db->fetch('SELECT * FROM users WHERE phone_number = :phone', ['phone' => $phone]);
|
||||
if (!$user) { echo "No user found\n"; exit(1); }
|
||||
|
||||
$bot = new BotService();
|
||||
|
||||
echo "1) Simular selección del menú que pide documentos (opción 1)\n";
|
||||
$bot->processMessage($user, '1', 'text');
|
||||
|
||||
echo "2) Simular envío de imagen (documento)\n";
|
||||
$bot->processMessage($user, 'media123', 'image');
|
||||
|
||||
echo "3) Simular confirmación 'ENVIADA'\n";
|
||||
$bot->processMessage($user, 'ENVIADA', 'text');
|
||||
|
||||
echo "Done\n";
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
require_once 'config/config.php';
|
||||
|
||||
$phone = $argv[1] ?? '573022548060';
|
||||
$db = Database::getInstance();
|
||||
$user = $db->fetch('SELECT * FROM users WHERE phone_number = :phone', ['phone' => $phone]);
|
||||
if (!$user) { echo "No user found\n"; exit(1); }
|
||||
|
||||
$bot = new BotService();
|
||||
|
||||
// Simulate incoming message '1'
|
||||
$bot->processMessage($user, '1', 'text');
|
||||
|
||||
echo "Simulated processMessage('1') for {$phone}\n";
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
require_once 'config/config.php';
|
||||
|
||||
$phone = $argv[1] ?? '573194724531';
|
||||
$message = $argv[2] ?? '1';
|
||||
$db = Database::getInstance();
|
||||
$user = $db->fetch('SELECT * FROM users WHERE phone_number = :phone', ['phone' => $phone]);
|
||||
if (!$user) { echo "No user found\n"; exit(1); }
|
||||
|
||||
$bot = new BotService();
|
||||
|
||||
// Simulate incoming message
|
||||
$bot->processMessage($user, $message, 'text');
|
||||
|
||||
echo "Simulated processMessage('{$message}') for {$phone}\n";
|
||||
Reference in New Issue
Block a user