|
|
|
@ -171,7 +171,7 @@ export class CommandService {
|
|
|
|
' · Tomar: tomar, claim',
|
|
|
|
' · Tomar: tomar, claim',
|
|
|
|
' · Soltar: soltar, unassign',
|
|
|
|
' · Soltar: soltar, unassign',
|
|
|
|
'- Preferencias:',
|
|
|
|
'- Preferencias:',
|
|
|
|
' · `/t configurar daily|weekly|off` (hora por defecto 08:30; semanal: lunes 08:30)',
|
|
|
|
' · `/t configurar daily|l-v|weekly|off [HH:MM]` (por defecto 08:30; semanal: lunes; l-v: lunes a viernes)',
|
|
|
|
'- Notas:',
|
|
|
|
'- Notas:',
|
|
|
|
' · En grupos, el bot responde por DM (no publica en el grupo).',
|
|
|
|
' · En grupos, el bot responde por DM (no publica en el grupo).',
|
|
|
|
' · Si creas en grupo y no mencionas a nadie → “sin responsable”; en DM → se asigna a quien la cree.',
|
|
|
|
' · Si creas en grupo y no mencionas a nadie → “sin responsable”; en DM → se asigna a quien la cree.',
|
|
|
|
@ -190,7 +190,7 @@ export class CommandService {
|
|
|
|
'- Ver mis tareas: `/t ver mis` (por DM)',
|
|
|
|
'- Ver mis tareas: `/t ver mis` (por DM)',
|
|
|
|
'- Ver todos: `/t ver todos`',
|
|
|
|
'- Ver todos: `/t ver todos`',
|
|
|
|
'- Completar: `/t x 123`',
|
|
|
|
'- Completar: `/t x 123`',
|
|
|
|
'- Configurar recordatorios: `/t configurar daily|weekly|off`'
|
|
|
|
'- Configurar recordatorios: `/t configurar daily|l-v|weekly|off [HH:MM]`'
|
|
|
|
].join('\n');
|
|
|
|
].join('\n');
|
|
|
|
return [{
|
|
|
|
return [{
|
|
|
|
recipient: context.sender,
|
|
|
|
recipient: context.sender,
|
|
|
|
@ -670,10 +670,14 @@ export class CommandService {
|
|
|
|
|
|
|
|
|
|
|
|
if (action === 'configurar') {
|
|
|
|
if (action === 'configurar') {
|
|
|
|
const optRaw = (tokens[2] || '').toLowerCase();
|
|
|
|
const optRaw = (tokens[2] || '').toLowerCase();
|
|
|
|
const map: Record<string, 'daily' | 'weekly' | 'off'> = {
|
|
|
|
const map: Record<string, 'daily' | 'weekly' | 'off' | 'weekdays'> = {
|
|
|
|
'daily': 'daily',
|
|
|
|
'daily': 'daily',
|
|
|
|
'diario': 'daily',
|
|
|
|
'diario': 'daily',
|
|
|
|
'diaria': 'daily',
|
|
|
|
'diaria': 'daily',
|
|
|
|
|
|
|
|
'l-v': 'weekdays',
|
|
|
|
|
|
|
|
'lv': 'weekdays',
|
|
|
|
|
|
|
|
'laborables': 'weekdays',
|
|
|
|
|
|
|
|
'weekdays': 'weekdays',
|
|
|
|
'semanal': 'weekly',
|
|
|
|
'semanal': 'weekly',
|
|
|
|
'weekly': 'weekly',
|
|
|
|
'weekly': 'weekly',
|
|
|
|
'off': 'off',
|
|
|
|
'off': 'off',
|
|
|
|
@ -681,10 +685,26 @@ export class CommandService {
|
|
|
|
'ninguno': 'off'
|
|
|
|
'ninguno': 'off'
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const freq = map[optRaw];
|
|
|
|
const freq = map[optRaw];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Hora opcional HH:MM
|
|
|
|
|
|
|
|
const timeRaw = tokens[3] || '';
|
|
|
|
|
|
|
|
let timeNorm: string | null = null;
|
|
|
|
|
|
|
|
if (timeRaw) {
|
|
|
|
|
|
|
|
const m = /^(\d{1,2}):([0-5]\d)$/.exec(timeRaw);
|
|
|
|
|
|
|
|
if (!m) {
|
|
|
|
|
|
|
|
return [{
|
|
|
|
|
|
|
|
recipient: context.sender,
|
|
|
|
|
|
|
|
message: 'Uso: `/t configurar daily|l-v|weekly|off [HH:MM]`'
|
|
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const hh = Math.max(0, Math.min(23, parseInt(m[1], 10)));
|
|
|
|
|
|
|
|
timeNorm = `${String(hh).padStart(2, '0')}:${m[2]}`;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!freq) {
|
|
|
|
if (!freq) {
|
|
|
|
return [{
|
|
|
|
return [{
|
|
|
|
recipient: context.sender,
|
|
|
|
recipient: context.sender,
|
|
|
|
message: 'Uso: `/t configurar daily|weekly|off`'
|
|
|
|
message: 'Uso: `/t configurar daily|l-v|weekly|off [HH:MM]`'
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const ensured = ensureUserExists(context.sender, this.dbInstance);
|
|
|
|
const ensured = ensureUserExists(context.sender, this.dbInstance);
|
|
|
|
@ -693,12 +713,24 @@ export class CommandService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.dbInstance.prepare(`
|
|
|
|
this.dbInstance.prepare(`
|
|
|
|
INSERT INTO user_preferences (user_id, reminder_freq, reminder_time, last_reminded_on, updated_at)
|
|
|
|
INSERT INTO user_preferences (user_id, reminder_freq, reminder_time, last_reminded_on, updated_at)
|
|
|
|
VALUES (?, ?, COALESCE((SELECT reminder_time FROM user_preferences WHERE user_id = ?), '08:30'), NULL, strftime('%Y-%m-%d %H:%M:%f', 'now'))
|
|
|
|
VALUES (?, ?, COALESCE(?, COALESCE((SELECT reminder_time FROM user_preferences WHERE user_id = ?), '08:30')), NULL, strftime('%Y-%m-%d %H:%M:%f', 'now'))
|
|
|
|
ON CONFLICT(user_id) DO UPDATE SET
|
|
|
|
ON CONFLICT(user_id) DO UPDATE SET
|
|
|
|
reminder_freq = excluded.reminder_freq,
|
|
|
|
reminder_freq = excluded.reminder_freq,
|
|
|
|
|
|
|
|
reminder_time = CASE WHEN ? IS NOT NULL THEN excluded.reminder_time ELSE reminder_time END,
|
|
|
|
updated_at = excluded.updated_at
|
|
|
|
updated_at = excluded.updated_at
|
|
|
|
`).run(ensured, freq, ensured);
|
|
|
|
`).run(ensured, freq, timeNorm, ensured, timeNorm);
|
|
|
|
const label = freq === 'daily' ? 'diario' : freq === 'weekly' ? 'semanal (lunes 08:30)' : 'apagado';
|
|
|
|
|
|
|
|
|
|
|
|
let label: string;
|
|
|
|
|
|
|
|
if (freq === 'daily') {
|
|
|
|
|
|
|
|
label = timeNorm ? `diario (${timeNorm})` : 'diario';
|
|
|
|
|
|
|
|
} else if (freq === 'weekdays') {
|
|
|
|
|
|
|
|
label = timeNorm ? `laborables (lunes a viernes ${timeNorm})` : 'laborables (lunes a viernes)';
|
|
|
|
|
|
|
|
} else if (freq === 'weekly') {
|
|
|
|
|
|
|
|
label = timeNorm ? `semanal (lunes ${timeNorm})` : 'semanal (lunes 08:30)';
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
label = 'apagado';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return [{
|
|
|
|
return [{
|
|
|
|
recipient: context.sender,
|
|
|
|
recipient: context.sender,
|
|
|
|
message: `✅ Recordatorios: ${label}`
|
|
|
|
message: `✅ Recordatorios: ${label}`
|
|
|
|
|