File size: 3,395 Bytes
9f8b4ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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