feat: Implement Telegram Bot and AI Settings

This commit is contained in:
renato97
2026-01-28 23:15:44 -03:00
parent 4ba5841839
commit f369bb70fe
115 changed files with 26873 additions and 26 deletions

View File

@@ -0,0 +1,45 @@
import { NextResponse } from 'next/server'
export async function POST(request: Request) {
try {
const { botToken, chatId } = await request.json()
if (!botToken || !chatId) {
return NextResponse.json(
{ success: false, error: 'Faltan credenciales (Token o Chat ID)' },
{ status: 400 }
)
}
const message = "🤖 *Prueba de Conexión*\n\n¡Hola! Si lees esto, tu bot de Finanzas está correctamente configurado. 🚀"
const url = `https://api.telegram.org/bot${botToken}/sendMessage`
const response = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
chat_id: chatId,
text: message,
parse_mode: 'Markdown'
})
})
const data = await response.json()
if (!data.ok) {
return NextResponse.json(
{ success: false, error: data.description || 'Error desconocido de Telegram' },
{ status: 500 }
)
}
return NextResponse.json({ success: true, data })
} catch (error: any) {
console.error('Telegram Test Error:', error)
return NextResponse.json(
{ success: false, error: error.message || 'Error interno del servidor' },
{ status: 500 }
)
}
}