|
|
|
@ -41,7 +41,12 @@ export function handleTaskCommand(body: string, sender: string, groupId: string,
|
|
|
|
|
if (task.dueDate) message += `\nFecha límite: ${task.dueDate}`;
|
|
|
|
|
message += `\nCreada: ${task.createdAt}`;
|
|
|
|
|
|
|
|
|
|
// Send confirmation privately to creator
|
|
|
|
|
sendMessage(sender, message);
|
|
|
|
|
// Also notify assignee if different from creator
|
|
|
|
|
if (assignedUser && assignedUser !== `@${sender.split('@')[0]}`) {
|
|
|
|
|
sendMessage(assignedUser, `📝 Se te ha asignado una nueva tarea:\n${message}`);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error creating task:', error);
|
|
|
|
|
sendMessage(sender, `❌ Error al crear la tarea: ${error.message}`);
|
|
|
|
@ -54,7 +59,10 @@ export function handleTaskCommand(body: string, sender: string, groupId: string,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assignTask(taskId, assignedUser);
|
|
|
|
|
// Send confirmation privately to the person who assigned
|
|
|
|
|
sendMessage(sender, `✅ Tarea ${taskId} asignada a ${assignedUser}`);
|
|
|
|
|
// Notify the new assignee privately
|
|
|
|
|
sendMessage(assignedUser, `📝 Se te ha asignado la tarea ${taskId}`);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error assigning task:', error);
|
|
|
|
|
sendMessage(sender, `❌ Error al asignar tarea: ${error.message}`);
|
|
|
|
@ -78,7 +86,12 @@ export function handleTaskCommand(body: string, sender: string, groupId: string,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
completeTask(taskId);
|
|
|
|
|
// Send confirmation privately to the user who completed
|
|
|
|
|
sendMessage(sender, `✅ Tarea ${taskId} completada: ${task.description}`);
|
|
|
|
|
// Notify the task creator if different from completer
|
|
|
|
|
if (task.createdBy && task.createdBy !== sender) {
|
|
|
|
|
sendMessage(task.createdBy, `✅ Tarea ${taskId} completada por @${sender.split('@')[0]}: ${task.description}`);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error completing task:', error);
|
|
|
|
|
sendMessage(sender, `❌ Error al completar tarea: ${error.message}`);
|
|
|
|
@ -94,6 +107,7 @@ export function handleTaskCommand(body: string, sender: string, groupId: string,
|
|
|
|
|
const taskList = tasks.map((task) => {
|
|
|
|
|
return `- Tarea ${task.id}: ${task.description}${task.dueDate ? ` (para el ${task.dueDate})` : ''}`;
|
|
|
|
|
}).join('\n');
|
|
|
|
|
// Always send task list privately
|
|
|
|
|
sendMessage(sender, `Tus tareas pendientes:\n${taskList}`);
|
|
|
|
|
}
|
|
|
|
|
} else if (action === 'recordatorios') {
|
|
|
|
@ -101,6 +115,7 @@ export function handleTaskCommand(body: string, sender: string, groupId: string,
|
|
|
|
|
if (enable === 'on' || enable === 'off') {
|
|
|
|
|
const phoneNumber = sender.split('@')[0];
|
|
|
|
|
setRemindersEnabled(phoneNumber, enable === 'on');
|
|
|
|
|
// Send reminder settings confirmation privately
|
|
|
|
|
sendMessage(sender, `Recordatorios ${enable === 'on' ? 'activados' : 'desactivados'}`);
|
|
|
|
|
} else {
|
|
|
|
|
sendMessage(sender, 'Usa /tarea recordatorios on|off para gestionar tus recordatorios');
|
|
|
|
|