diff --git a/api/chat.php b/api/chat.php index ec1826c..4bb34d0 100644 --- a/api/chat.php +++ b/api/chat.php @@ -55,7 +55,10 @@ if ($method === 'GET') { $msg['level_color'] = '#94a3b8'; $msg['level_emoji'] = ''; - if ($msg['username'] === $topRequester) { + if ($msg['username'] === 'Lili Bot 🤖') { + $msg['level_color'] = '#00e676'; + $msg['level_emoji'] = '🤖'; + } elseif ($msg['username'] === $topRequester) { $msg['level_color'] = '#facc15'; $msg['level_emoji'] = '👑'; $msg['is_top_listener'] = true; diff --git a/weekly_report.php b/weekly_report.php index 83f843b..a849d51 100644 --- a/weekly_report.php +++ b/weekly_report.php @@ -229,6 +229,7 @@ if ($action === 'send') { if (!$stmt->fetch()) { $rewards = [50, 30, 20]; + $rewarded_users = []; foreach ($top_chatters as $i => $c) { if ($i >= 3) break; $username = $c['username']; @@ -243,7 +244,24 @@ if ($action === 'send') { } else { $db->prepare("INSERT INTO fans (name, points) VALUES (?, ?)")->execute([$username, $points_to_add]); } + $rewarded_users[$username] = $points_to_add; } + + // Bot message to chat + if (!empty($rewarded_users)) { + $bot_msg = "🏆 ¡Atención comunidad! El Top 3 de interactores de esta semana ha sido premiado:\n\n"; + $medals = ["🥇", "🥈", "🥉"]; + $idx = 0; + foreach ($rewarded_users as $user => $pts) { + $bot_msg .= "{$medals[$idx]} $user: +$pts Fan Points\n"; + $idx++; + } + $bot_msg .= "\n¡Sigue participando en el chat para ganar el próximo lunes! 📻✨"; + + $db->prepare("INSERT INTO messages (username, ip_address, message, type) VALUES (?, ?, ?, ?)") + ->execute(['Lili Bot 🤖', '127.0.0.1', $bot_msg, 'text']); + } + $db->prepare("INSERT INTO automation_logs (task_name, last_run) VALUES ('weekly_report_rewards', NOW()) ON DUPLICATE KEY UPDATE last_run = NOW()")->execute(); }