up
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../config/config.php';
|
||||
require_once __DIR__ . '/../services/BotService.php';
|
||||
$db = Database::getInstance();
|
||||
$bot = new BotService();
|
||||
|
||||
$phone = '573011111222';
|
||||
$db->execute('DELETE FROM users WHERE phone_number = :p', ['p' => $phone]);
|
||||
$id = $db->insert('users', ['phone_number' => $phone, 'status' => 'active', 'created_at' => date('Y-m-d H:i:s')]);
|
||||
|
||||
// Ensure welcome_message config exists
|
||||
$message = getConfigFromDB('welcome_message', null);
|
||||
if (!$message) {
|
||||
$m = 'Bienvenido a nuestro servicio (mensaje por defecto)';
|
||||
// Insert config if missing
|
||||
try {
|
||||
$db->insert('system_config', ['config_key' => 'welcome_message', 'config_value' => $m, 'created_at' => date('Y-m-d H:i:s')]);
|
||||
echo "Inserted welcome_message config\n";
|
||||
} catch (Exception $e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
$bot->sendWelcomeMessage($phone);
|
||||
$user = $db->fetch('SELECT * FROM users WHERE id = :id', ['id' => $id]);
|
||||
if (!empty($user['welcome_sent_at'])) {
|
||||
echo "welcome_sent_at recorded: {$user['welcome_sent_at']}\n";
|
||||
} else {
|
||||
echo "welcome_sent_at NOT set\n";
|
||||
}
|
||||
|
||||
// cleanup
|
||||
$db->execute('DELETE FROM users WHERE id = :id', ['id' => $id]);
|
||||
|
||||
echo "Done\n";
|
||||
Reference in New Issue
Block a user