class ResponseHandler: # Palabras de activación ACTIVATION_WORDS = [ "hola", "bueno", "díga", "mande", "buenas" ] # Palabras de aceptación ACCEPTANCE_WORDS = [ "me interesa", "quiero", "acepto", "suena bien", "claro", "de acuerdo", "okey", "adelante", "perfecto", "hagámoslo" ] # Palabras de negación NEGATIVE_WORDS = [ "no", "no me interesa", "no quiero", "no gracias", "negativo", "en otro momento", "después", "ahora no", "lo pensaré" ] # Palabras de desactivación DEACTIVATION_WORDS = [ "alto", "detente", "adiós", "terminar", "finalizar" ] STOP_COMMANDS = [ "para", "detente", "silencio", "cállate", "espera", "stop", "alto", "basta", "suficiente", "ya", "shh", "sh" ] ACTIVATION_PHRASES = [ "hola asistente", "oye asistente", "hey asistente", "asistente", "bot", "chatbot", "hola bot", "oye bot", "hey bot" ] @classmethod def is_stop_command(cls, text): """Verifica si el texto es un comando de interrupción""" text = text.lower().strip() return any(cmd in text for cmd in cls.STOP_COMMANDS) @classmethod def is_activation_phrase(cls, text): """Verifica si el texto es una frase de activación""" text = text.lower().strip() return any(phrase in text for phrase in cls.ACTIVATION_PHRASES) @classmethod def get_response_type(cls, text): """Determina el tipo de respuesta basado en el texto""" text = text.lower().strip() if cls.is_stop_command(text): return "stop" elif cls.is_activation_phrase(text): return "activation" else: return "normal" @classmethod def is_acceptance_phrase(cls, text): """Verificar si el texto indica aceptación""" return any(word in text.lower() for word in cls.ACCEPTANCE_WORDS) @classmethod def is_negative_phrase(cls, text): """Verificar si el texto indica negativa""" return any(word in text.lower() for word in cls.NEGATIVE_WORDS) @classmethod def is_deactivation_phrase(cls, text): """Verificar si el texto indica desactivación""" return any(word in text.lower() for word in cls.DEACTIVATION_WORDS) @classmethod def handle_response(cls, text, flow_bot, mode, data_manager): """Manejar la respuesta del usuario""" # Primero verificar si es una orden de desactivación if cls.is_deactivation_phrase(text): return "DEACTIVATE" # Señal especial para desactivar if cls.is_negative_phrase(text): response = flow_bot.get_negative_response(mode) data_manager.start_data_collection() return response if cls.is_acceptance_phrase(text): data_manager.start_data_collection() return flow_bot.get_success_message(mode) return None # Indica que no es una respuesta especial