|  |  |  | @ -22,12 +22,20 @@ export function handleTaskCommand(body: string, sender: string, groupId: string, | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |       // Extract WhatsApp mention (format: @<phone_number>)
 | 
		
	
		
			
				|  |  |  |  |       const assignedUserMatch = description.match(/@\d+/); | 
		
	
		
			
				|  |  |  |  |       const assignedUser = assignedUserMatch ? assignedUserMatch[0] : null; | 
		
	
		
			
				|  |  |  |  |       let assignedUser = null; | 
		
	
		
			
				|  |  |  |  |        | 
		
	
		
			
				|  |  |  |  |       // Validate phone number format
 | 
		
	
		
			
				|  |  |  |  |       if (assignedUser && !/^@\d{8,}$/.test(assignedUser)) { | 
		
	
		
			
				|  |  |  |  |         sendMessage(sender, 'Formato de mención inválido. Usa @ seguido del número de teléfono'); | 
		
	
		
			
				|  |  |  |  |         return; | 
		
	
		
			
				|  |  |  |  |       if (assignedUserMatch) { | 
		
	
		
			
				|  |  |  |  |         try { | 
		
	
		
			
				|  |  |  |  |           assignedUser = normalizeUserIdentifier(assignedUserMatch[0]); | 
		
	
		
			
				|  |  |  |  |           // Check if assigned user is in the community
 | 
		
	
		
			
				|  |  |  |  |           if (!linkedGroups.has(`${assignedUser.replace('@', '')}@s.whatsapp.net`)) { | 
		
	
		
			
				|  |  |  |  |             sendMessage(sender, `El usuario ${assignedUser} no está en la comunidad`); | 
		
	
		
			
				|  |  |  |  |             return; | 
		
	
		
			
				|  |  |  |  |           } | 
		
	
		
			
				|  |  |  |  |         } catch (error) { | 
		
	
		
			
				|  |  |  |  |           sendMessage(sender, `Formato de mención inválido: ${error.message}`); | 
		
	
		
			
				|  |  |  |  |           return; | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |       const dueDateMatch = description.match(/\d{4}-\d{2}-\d{2}/); | 
		
	
	
		
			
				
					|  |  |  | @ -51,7 +59,7 @@ export function handleTaskCommand(body: string, sender: string, groupId: string, | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |       } else if (action === 'nueva') { | 
		
	
		
			
				|  |  |  |  |         try { | 
		
	
		
			
				|  |  |  |  |           const finalAssignedUser = assignedUser || `@${sender.split('@')[0]}`; | 
		
	
		
			
				|  |  |  |  |           const finalAssignedUser = assignedUser || normalizeUserIdentifier(sender); | 
		
	
		
			
				|  |  |  |  |           const task = createTask(sender, { | 
		
	
		
			
				|  |  |  |  |             description: cleanDescription, | 
		
	
		
			
				|  |  |  |  |             assignedTo: finalAssignedUser, | 
		
	
	
		
			
				
					|  |  |  | 
 |