chatgraph 0.3.4__py3-none-any.whl → 0.3.6__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/bot/chatbot_model.py +2 -2
- chatgraph/types/message_types.py +1 -1
- chatgraph/types/request_types.py +54 -10
- {chatgraph-0.3.4.dist-info → chatgraph-0.3.6.dist-info}/METADATA +1 -1
- {chatgraph-0.3.4.dist-info → chatgraph-0.3.6.dist-info}/RECORD +8 -8
- {chatgraph-0.3.4.dist-info → chatgraph-0.3.6.dist-info}/LICENSE +0 -0
- {chatgraph-0.3.4.dist-info → chatgraph-0.3.6.dist-info}/WHEEL +0 -0
- {chatgraph-0.3.4.dist-info → chatgraph-0.3.6.dist-info}/entry_points.txt +0 -0
chatgraph/bot/chatbot_model.py
CHANGED
|
@@ -144,9 +144,9 @@ class ChatbotApp:
|
|
|
144
144
|
|
|
145
145
|
if isinstance(userCall_response, (list, tuple)):
|
|
146
146
|
for response in userCall_response:
|
|
147
|
-
self.__process_func_response(response, userCall)
|
|
147
|
+
self.__process_func_response(response, userCall, route=route)
|
|
148
148
|
|
|
149
|
-
def __process_func_response(self, userCall_response, userCall: UserCall):
|
|
149
|
+
def __process_func_response(self, userCall_response, userCall: UserCall, route: str):
|
|
150
150
|
|
|
151
151
|
if isinstance(userCall_response, (str, float, int)):
|
|
152
152
|
userCall.send(Message(text=userCall_response))
|
chatgraph/types/message_types.py
CHANGED
chatgraph/types/request_types.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
from
|
|
2
|
-
from .message_types import Message, Button, ListElements, messageTypes, MessageTypes
|
|
1
|
+
from chatgraph.gRPC.gRPCCall import WhatsappServiceClient, UserStateServiceClient
|
|
2
|
+
from chatgraph.types.message_types import Message, Button, ListElements, messageTypes, MessageTypes
|
|
3
3
|
from dataclasses import dataclass
|
|
4
4
|
from typing import Optional
|
|
5
|
-
import json
|
|
5
|
+
import json, os
|
|
6
6
|
|
|
7
7
|
@dataclass
|
|
8
8
|
class UserState:
|
|
@@ -15,12 +15,56 @@ class UserState:
|
|
|
15
15
|
lst_update (str): A última atualização do menu.
|
|
16
16
|
obs (dict): Observações adicionais sobre o estado do usuário.
|
|
17
17
|
"""
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
customer_id: str,
|
|
21
|
+
menu: str,
|
|
22
|
+
route: str,
|
|
23
|
+
lst_update: Optional[str]=None,
|
|
24
|
+
obs: Optional[dict] = None,
|
|
25
|
+
direction_in: Optional[bool] = True,
|
|
26
|
+
) -> None:
|
|
27
|
+
|
|
28
|
+
self.customer_id = customer_id
|
|
29
|
+
self.menu = menu
|
|
30
|
+
self.route = route
|
|
31
|
+
self.lst_update = lst_update
|
|
32
|
+
self.obs = obs
|
|
33
|
+
self.direction_in = direction_in
|
|
34
|
+
|
|
35
|
+
def __str__(self):
|
|
36
|
+
return f"UserState:\n\tcustomer_id={self.customer_id},\n\tmenu={self.menu},\n\troute={self.route},\n\tlst_update={self.lst_update},\n\tobs={self.obs},\n\tdirection_in={self.direction_in}"
|
|
23
37
|
|
|
38
|
+
def insert(self, grpc_uri: Optional[str] = None) -> None:
|
|
39
|
+
if grpc_uri is None:
|
|
40
|
+
grpc_uri = os.getenv('GRPC_URI')
|
|
41
|
+
user_state_client = UserStateServiceClient(grpc_uri)
|
|
42
|
+
|
|
43
|
+
user_state_client.insert_user_state({
|
|
44
|
+
'user_id': self.customer_id,
|
|
45
|
+
'menu_id': self.menu,
|
|
46
|
+
'route': self.route,
|
|
47
|
+
'obs': json.dumps(self.obs),
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
def update(self, grpc_uri: Optional[str] = None) -> None:
|
|
51
|
+
if grpc_uri is None:
|
|
52
|
+
grpc_uri = os.getenv('GRPC_URI')
|
|
53
|
+
user_state_client = UserStateServiceClient(grpc_uri)
|
|
54
|
+
|
|
55
|
+
user_state_client.update_user_state({
|
|
56
|
+
'user_id': self.customer_id,
|
|
57
|
+
'menu_id': self.menu,
|
|
58
|
+
'route': self.route,
|
|
59
|
+
'obs': json.dumps(self.obs),
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
def delete(self, grpc_uri: Optional[str] = None) -> None:
|
|
63
|
+
if grpc_uri is None:
|
|
64
|
+
grpc_uri = os.getenv('GRPC_URI')
|
|
65
|
+
user_state_client = UserStateServiceClient(grpc_uri)
|
|
66
|
+
|
|
67
|
+
user_state_client.delete_user_state(self.customer_id)
|
|
24
68
|
|
|
25
69
|
class UserCall:
|
|
26
70
|
"""
|
|
@@ -86,7 +130,7 @@ class UserCall:
|
|
|
86
130
|
message.text,
|
|
87
131
|
message.title,
|
|
88
132
|
message.button_title,
|
|
89
|
-
message.
|
|
133
|
+
message.elements,
|
|
90
134
|
message.caption
|
|
91
135
|
)
|
|
92
136
|
else:
|
|
@@ -156,7 +200,7 @@ class UserCall:
|
|
|
156
200
|
"button_title": button_title,
|
|
157
201
|
"message_caption": caption,
|
|
158
202
|
"message_title": title,
|
|
159
|
-
"options": [{"title": k, "description": v} for k,v in element_list],
|
|
203
|
+
"options": [{"title": k, "description": v} for k,v in element_list.items()],
|
|
160
204
|
}
|
|
161
205
|
)
|
|
162
206
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
chatgraph/__init__.py,sha256=lUMcFMSxKQeHVFq7CyZV2r_UOHAtGGpeXtac0RUd7po,718
|
|
2
2
|
chatgraph/auth/credentials.py,sha256=xsMEpLQnc66novPjL6upocMcnUnvFJ7yxINzUenkxmc,2388
|
|
3
|
-
chatgraph/bot/chatbot_model.py,sha256=
|
|
3
|
+
chatgraph/bot/chatbot_model.py,sha256=s6InEQzed0TyyNctikI89ujJS1RgS-E_LVih-npc_8E,7226
|
|
4
4
|
chatgraph/bot/chatbot_router.py,sha256=tl-4WP9wqUjCIwvtO9kJVUFjN2-mxNDUTRAFL9PXBgI,3028
|
|
5
5
|
chatgraph/cli/__init__.py,sha256=tfgYhGoKy1nD4STN4xDh6J4VV55RICk7v1GZmzAg-bM,7413
|
|
6
6
|
chatgraph/error/chatbot_error.py,sha256=4sEcW8vz0eQk2QDmDygucVM4caHliZW5iH7XJvmLBuk,1897
|
|
@@ -14,11 +14,11 @@ chatgraph/pb/voll.proto,sha256=fSjx24MT_fJQbo7EwO9BsuIWAa7IzXgJnioCSrdt3FM,2007
|
|
|
14
14
|
chatgraph/pb/voll_pb2.py,sha256=IkopsIc8x-lS9j6WpL9Wk5MHl41FDa8cU0kmZRpKKKY,5291
|
|
15
15
|
chatgraph/pb/voll_pb2_grpc.py,sha256=U-_nXTAIEzo2GMYjHiphbSyTx3zyipsnKebFuZuoU1k,17685
|
|
16
16
|
chatgraph/types/end_types.py,sha256=--Ty2gM_y7J-yRAvZV26e4HMUpoguAMAhfOIS9-kQTk,1316
|
|
17
|
-
chatgraph/types/message_types.py,sha256
|
|
18
|
-
chatgraph/types/request_types.py,sha256=
|
|
17
|
+
chatgraph/types/message_types.py,sha256=VoCD8-Mr7ScTkzvdUTMXQDP4V6getReO8Ecump6cGQk,3358
|
|
18
|
+
chatgraph/types/request_types.py,sha256=Fq8LHFJH4A7MnH0MQmn4r57_EQaXpCYL05CW1ycK9bA,10307
|
|
19
19
|
chatgraph/types/route.py,sha256=2fuHEPKUL_Vuv4g8pB6M7eJLouxXasqjesdju6_eumE,2757
|
|
20
|
-
chatgraph-0.3.
|
|
21
|
-
chatgraph-0.3.
|
|
22
|
-
chatgraph-0.3.
|
|
23
|
-
chatgraph-0.3.
|
|
24
|
-
chatgraph-0.3.
|
|
20
|
+
chatgraph-0.3.6.dist-info/entry_points.txt,sha256=bO9_Q-PqE5vCNNo6ke_-3j2gHfKQMDGnKDTkNuCdBuA,48
|
|
21
|
+
chatgraph-0.3.6.dist-info/LICENSE,sha256=rVJozpRzDlplOpvI8A1GvmfVS0ReYdZvMWc1j2jV0v8,1090
|
|
22
|
+
chatgraph-0.3.6.dist-info/METADATA,sha256=Oz-P2A2XTg63qi5RTXv8T-BTCy_0YnrFagTSrlhUHd0,12781
|
|
23
|
+
chatgraph-0.3.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
24
|
+
chatgraph-0.3.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|