chatgraph 0.4.2__py3-none-any.whl → 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of chatgraph might be problematic. Click here for more details.
- chatgraph/__init__.py +4 -3
- chatgraph/bot/chatbot_model.py +11 -8
- chatgraph/gRPC/gRPCCall.py +61 -145
- chatgraph/messages/message_consumer.py +74 -139
- chatgraph/pb/router.proto +127 -0
- chatgraph/pb/router_pb2.py +77 -0
- chatgraph/pb/router_pb2_grpc.py +669 -0
- chatgraph/types/message_types.py +79 -76
- chatgraph/types/request_types.py +176 -251
- {chatgraph-0.4.2.dist-info → chatgraph-0.5.0.dist-info}/METADATA +1 -1
- chatgraph-0.5.0.dist-info/RECORD +21 -0
- chatgraph/pb/userstate.proto +0 -41
- chatgraph/pb/userstate_pb2.py +0 -47
- chatgraph/pb/userstate_pb2_grpc.py +0 -269
- chatgraph/pb/voll.proto +0 -90
- chatgraph/pb/voll_pb2.py +0 -63
- chatgraph/pb/voll_pb2_grpc.py +0 -470
- chatgraph-0.4.2.dist-info/RECORD +0 -24
- {chatgraph-0.4.2.dist-info → chatgraph-0.5.0.dist-info}/LICENSE +0 -0
- {chatgraph-0.4.2.dist-info → chatgraph-0.5.0.dist-info}/WHEEL +0 -0
- {chatgraph-0.4.2.dist-info → chatgraph-0.5.0.dist-info}/entry_points.txt +0 -0
chatgraph/types/message_types.py
CHANGED
|
@@ -3,106 +3,109 @@ from typing import Optional, Union
|
|
|
3
3
|
messageTypes = Union[str, float, int]
|
|
4
4
|
MessageTypes = (str, float, int)
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Atributos:
|
|
11
|
-
message (str): O conteúdo textual da mensagem.
|
|
12
|
-
absolute_text (bool): Se True, o texto não será modificado.
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
def __init__(
|
|
16
|
-
self,
|
|
17
|
-
text:str,
|
|
18
|
-
absolute_text: bool = False,
|
|
19
|
-
) -> None:
|
|
20
|
-
self.absolute_text = absolute_text
|
|
21
|
-
|
|
22
|
-
if not absolute_text:
|
|
23
|
-
text = text.replace('\t', '')
|
|
24
|
-
|
|
25
|
-
self.text = text
|
|
6
|
+
|
|
7
|
+
TITLE_MAX_LENGTH = 20
|
|
8
|
+
DETAIL_MAX_LENGTH = 72
|
|
9
|
+
|
|
26
10
|
|
|
27
11
|
class Button:
|
|
28
12
|
"""
|
|
29
13
|
Representa uma lista rápida de botões.
|
|
30
|
-
|
|
14
|
+
|
|
31
15
|
Atributos:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
caption (str): A legenda da mensagem.
|
|
16
|
+
typeButton (str): O tipo do botão.
|
|
17
|
+
title (str): O texto do botão.
|
|
18
|
+
detail (str): A descrição do botão.
|
|
36
19
|
absolute_text (bool): Se True, o texto não será modificado.
|
|
37
|
-
|
|
20
|
+
|
|
38
21
|
Limitações:
|
|
39
|
-
O
|
|
40
|
-
|
|
22
|
+
O título do botão deve ter no máximo 20 caracteres.
|
|
23
|
+
A descrição do botão deve ter no máximo 72 caracteres.
|
|
41
24
|
"""
|
|
25
|
+
|
|
42
26
|
def __init__(
|
|
43
|
-
self,
|
|
44
|
-
text:str,
|
|
45
|
-
buttons: list[str],
|
|
27
|
+
self,
|
|
46
28
|
title: Optional[str] = None,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
29
|
+
detail: Optional[str] = None,
|
|
30
|
+
typeButton: Optional[str]="postback",
|
|
31
|
+
absolute_text: Optional[bool] = False,
|
|
32
|
+
) -> None:
|
|
33
|
+
|
|
50
34
|
self.absolute_text = absolute_text
|
|
51
|
-
|
|
35
|
+
|
|
52
36
|
if not absolute_text:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
assert
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
37
|
+
detail = detail.replace("\t", "")
|
|
38
|
+
|
|
39
|
+
assert (
|
|
40
|
+
len(title) <= TITLE_MAX_LENGTH
|
|
41
|
+
), f"O texto do botão deve ter no máximo {TITLE_MAX_LENGTH} caracteres."
|
|
42
|
+
assert (
|
|
43
|
+
len(detail) <= DETAIL_MAX_LENGTH
|
|
44
|
+
), f"A descrição do botão deve ter no máximo {DETAIL_MAX_LENGTH} caracteres."
|
|
45
|
+
|
|
46
|
+
self.type = typeButton
|
|
62
47
|
self.title = title
|
|
63
|
-
self.
|
|
48
|
+
self.detail = detail
|
|
49
|
+
|
|
50
|
+
def to_dict(self):
|
|
51
|
+
return {
|
|
52
|
+
"type": self.type,
|
|
53
|
+
"title": self.title,
|
|
54
|
+
"detail": self.detail,
|
|
55
|
+
}
|
|
64
56
|
|
|
65
|
-
|
|
57
|
+
|
|
58
|
+
class Message:
|
|
66
59
|
"""
|
|
67
|
-
Representa uma
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
Representa uma mensagem universal enviada pelo chatbot.
|
|
61
|
+
|
|
62
|
+
Atributos:
|
|
63
|
+
type (str): O tipo da mensagem.
|
|
64
|
+
url (str): A URL da mensagem.
|
|
65
|
+
filename (str): O nome do arquivo da mensagem.
|
|
71
66
|
title (str): O título da mensagem.
|
|
72
|
-
|
|
73
|
-
elements (list[dict]): A lista de elementos.
|
|
67
|
+
detail (str): A descrição da mensagem.
|
|
74
68
|
caption (str): A legenda da mensagem.
|
|
69
|
+
buttons (list[Button]): A lista de botões da mensagem.
|
|
75
70
|
absolute_text (bool): Se True, o texto não será modificado.
|
|
76
|
-
|
|
77
|
-
Limitações:
|
|
78
|
-
O número máximo de elementos é 10.
|
|
79
|
-
O título do elemento deve ter no máximo 24 caracteres.
|
|
80
|
-
A descrição do elemento deve ter no máximo 72 caracteres.
|
|
81
71
|
"""
|
|
72
|
+
|
|
82
73
|
def __init__(
|
|
83
|
-
self,
|
|
84
|
-
|
|
85
|
-
button_title: str,
|
|
86
|
-
elements: dict,
|
|
74
|
+
self,
|
|
75
|
+
detail: Optional[str] = None,
|
|
87
76
|
title: Optional[str] = None,
|
|
88
77
|
caption: Optional[str] = None,
|
|
89
|
-
|
|
90
|
-
|
|
78
|
+
type: Optional[str]="message",
|
|
79
|
+
url: Optional[str] = None,
|
|
80
|
+
filename: Optional[str] = None,
|
|
81
|
+
buttons: Optional[list[Button]] = None,
|
|
82
|
+
display_button: Optional[Button] = None,
|
|
83
|
+
absolute_text: Optional[bool] = False,
|
|
84
|
+
) -> None:
|
|
91
85
|
self.absolute_text = absolute_text
|
|
92
|
-
|
|
86
|
+
|
|
93
87
|
if not absolute_text:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
assert len(key) <= 24, "O título do elemento deve ter no máximo 24 caracteres."
|
|
100
|
-
assert len(value) <= 72, "A descrição do elemento deve ter no máximo 72 caracteres."
|
|
101
|
-
|
|
102
|
-
self.text = text
|
|
88
|
+
detail = detail.replace("\t", "")
|
|
89
|
+
|
|
90
|
+
self.type = type
|
|
91
|
+
self.url = url
|
|
92
|
+
self.filename = filename
|
|
103
93
|
self.title = title
|
|
104
|
-
self.
|
|
105
|
-
self.elements = elements
|
|
94
|
+
self.detail = detail
|
|
106
95
|
self.caption = caption
|
|
96
|
+
self.buttons = buttons or []
|
|
97
|
+
self.display_button = display_button
|
|
107
98
|
|
|
108
|
-
|
|
99
|
+
def to_dict(self):
|
|
100
|
+
return {
|
|
101
|
+
"message": {
|
|
102
|
+
"type": self.type,
|
|
103
|
+
"url": self.url,
|
|
104
|
+
"filename": self.filename,
|
|
105
|
+
"title": self.title,
|
|
106
|
+
"detail": self.detail,
|
|
107
|
+
"caption": self.caption,
|
|
108
|
+
},
|
|
109
|
+
"buttons": [button.to_dict() for button in self.buttons],
|
|
110
|
+
"display_button": self.display_button.to_dict() if self.display_button else None,
|
|
111
|
+
}
|