|
|
|
|
@ -16,6 +16,44 @@ import { ResponseQueue } from '../response-queue';
|
|
|
|
|
import { isGroupId } from '../../utils/whatsapp';
|
|
|
|
|
import { Metrics } from '../metrics';
|
|
|
|
|
|
|
|
|
|
function getQuickHelp(): string {
|
|
|
|
|
return [
|
|
|
|
|
'Guía rápida:',
|
|
|
|
|
'- Ver tus tareas: `/t mias`',
|
|
|
|
|
'- Ver todas: `/t todas`',
|
|
|
|
|
'- Crear: `/t n Descripción 2028-11-26 @Ana`',
|
|
|
|
|
'- Completar: `/t x 123`',
|
|
|
|
|
'- Tomar: `/t tomar 12`',
|
|
|
|
|
'- Configurar recordatorios: `/t configurar diario|l-v|semanal|off [HH:MM]`',
|
|
|
|
|
'- Web: `/t web`'
|
|
|
|
|
].join('\n');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getFullHelp(): string {
|
|
|
|
|
return [
|
|
|
|
|
'Ayuda avanzada:',
|
|
|
|
|
'Comandos y alias:',
|
|
|
|
|
' · Crear: `n`, `nueva`, `crear`, `+`',
|
|
|
|
|
' · Ver: `ver`, `listar`, `mostrar`, `ls` (scopes: `mis` | `todas`)',
|
|
|
|
|
' · Completar: `x`, `hecho`, `completar`, `done`',
|
|
|
|
|
' · Tomar: `tomar`, `claim`',
|
|
|
|
|
' · Soltar: `soltar`, `unassign`',
|
|
|
|
|
'Preferencias:',
|
|
|
|
|
' · `/t configurar diario|l-v|semanal|off [HH:MM]`',
|
|
|
|
|
'Fechas:',
|
|
|
|
|
' · `YYYY-MM-DD` o `YY-MM-DD` → `20YY-MM-DD` (ej.: 27-09-04)',
|
|
|
|
|
' · Palabras: `hoy`, `mañana`',
|
|
|
|
|
'Acceso web:',
|
|
|
|
|
' · `/t web`'
|
|
|
|
|
].join('\n');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function buildUnknownHelp(): string {
|
|
|
|
|
const header = '❓ COMANDO NO RECONOCIDO';
|
|
|
|
|
const cta = 'Prueba `/t ayuda`';
|
|
|
|
|
return [header, cta, '', getQuickHelp()].join('\n');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type RoutedMessage = {
|
|
|
|
|
recipient: string;
|
|
|
|
|
message: string;
|
|
|
|
|
@ -38,6 +76,18 @@ export async function route(context: RouteContext, deps?: { db: Database }): Pro
|
|
|
|
|
const rawAction = (tokens[1] || '').toLowerCase();
|
|
|
|
|
const action = ACTION_ALIASES[rawAction] || rawAction;
|
|
|
|
|
|
|
|
|
|
// Ayuda (no requiere DB)
|
|
|
|
|
if (action === 'ayuda') {
|
|
|
|
|
const isAdvanced = (tokens[2] || '').toLowerCase() === 'avanzada';
|
|
|
|
|
const message = isAdvanced
|
|
|
|
|
? getFullHelp()
|
|
|
|
|
: [getQuickHelp(), '', 'Ayuda avanzada: `/t ayuda avanzada`'].join('\n');
|
|
|
|
|
return [{
|
|
|
|
|
recipient: context.sender,
|
|
|
|
|
message
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Requiere db inyectada para poder operar (CommandService la inyecta)
|
|
|
|
|
const database = deps?.db;
|
|
|
|
|
if (!database) return null;
|
|
|
|
|
@ -96,6 +146,9 @@ export async function route(context: RouteContext, deps?: { db: Database }): Pro
|
|
|
|
|
return await handleWeb(context as any, { db: database });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// No manejado aquí → fallback al CommandService actual
|
|
|
|
|
return null;
|
|
|
|
|
// Desconocido → ayuda rápida
|
|
|
|
|
return [{
|
|
|
|
|
recipient: context.sender,
|
|
|
|
|
message: buildUnknownHelp()
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|