// SATMELI — Chat simulado del bot de Telegram (canal estrella). function TgTime({ children, light }) { return {children}; } function BotBubble({ children, time, tail }) { return (
{children} {time &&
{time}
}
); } function UserBubble({ children, time }) { return (
{children} {time &&
{time} ✓✓
}
); } function BotAlertBubble({ n, search, onGoMeli, time }) { const cat = search ? search.cat : 'tech'; const delta = deltaInfo(n.price, n.target); return (
{/* encabezado del bot card */}
Nuevo match {search ? search.term : ''}
{/* "foto" del producto */}
FOTO PUBLICACIÓN
{n.title}
{fmtARS(n.price)} {delta && delta.under && ↓ {delta.pct}% bajo tu tope}
{condLabel(n.condition)} · {n.location}
{/* botones inline de Telegram */}
{time}
); } function CmdChip({ children }) { return {children}; } function TelegramChat({ dark, mode, onBack, notifs, searches }) { const byId = Object.fromEntries(searches.map((s) => [s.id, s])); const goMeli = (n) => window.open(n.permalink || 'https://www.mercadolibre.com.ar', '_blank'); // Estado real del bot const [botStatus, setBotStatus] = React.useState(null); React.useEffect(() => { apiFetch('/telegram/status').then(setBotStatus).catch(() => setBotStatus(null)); }, []); const botUsername = (botStatus && botStatus.username) || 'SatmeliBot'; const botConnected = botStatus && botStatus.connected; const chatLinked = botStatus && botStatus.chatLinked; // Mostrar las 2 alertas no leídas más recientes en el chat simulado const recentAlerts = notifs.filter((n) => !n.read).slice(0, 2); const alert1 = recentAlerts[0] || null; const alert2 = recentAlerts[1] || null; const activeCount = searches.filter((s) => s.active).length; return (
{/* patrón de fondo sutil */}
{/* header */}
@{botUsername}
{botConnected ? (chatLinked ? 'bot · alertas activas' : 'bot · enviá /start para vincular') : 'bot · no configurado'}
{botConnected && ( Abrir )}
{/* mensajes */}
HOY
/start 👋 ¡Hola! Soy el bot de SATMELI. Te aviso acá apenas aparezca en Mercado Libre algo que estás buscando. Tu cuenta ya está vinculada con la web.
✓ {activeCount} centinela{activeCount !== 1 ? 's' : ''} activo{activeCount !== 1 ? 's' : ''} monitoreando ahora mismo.
hace instantes
{alert1 && } {alert1 && ( Apareció 1 publicación nueva para {byId[alert1.searchId] ? byId[alert1.searchId].term : 'tu búsqueda'} 🎯 )} {alert2 && } {!alert1 && !alert2 && ( Aún no hay coincidencias nuevas. ¡Te aviso cuando aparezca algo! 🔍 )} /activas 📡 Tus centinelas
{searches.filter((s) => s.active).map((s) => ( • {s.term} — {s.matches} hallazgos
))} {!searches.some((s) => s.active) && No tenés centinelas activos.} Escribí /pausar <id> para silenciar una.
{/* comandos + input */}
/activas/pausar/silenciar 1h/nueva
Mensaje
); } Object.assign(window, { TelegramChat });