chatgraph 0.3.13__py3-none-any.whl → 0.3.15__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.

@@ -2,6 +2,7 @@ from chatgraph.gRPC.gRPCCall import WhatsappServiceClient, UserStateServiceClien
2
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
+ from datetime import datetime
5
6
  import json, os
6
7
 
7
8
  @dataclass
@@ -73,6 +74,28 @@ class UserState:
73
74
 
74
75
  user_state_client.delete_user_state(self.customer_id)
75
76
 
77
+ @classmethod
78
+ def get_user_state(cls, customer_id: str, grpc_uri: Optional[str] = None) -> 'UserState':
79
+ if grpc_uri is None:
80
+ grpc_uri = os.getenv('GRPC_URI')
81
+ user_state_client = UserStateServiceClient(grpc_uri)
82
+
83
+ response = user_state_client.select_user_state(user_id=customer_id)
84
+
85
+ if not response:
86
+ raise ValueError("Erro ao buscar estado do usuário.")
87
+
88
+ date = datetime.strptime(response.date, "%Y-%m-%d %H:%M:%S")
89
+ return cls(
90
+ customer_id=response.user_id,
91
+ menu=response.menu_id,
92
+ route=response.route,
93
+ obs=json.loads(response.obs),
94
+ direction_in=response.direction,
95
+ voll_id=response.voll_id,
96
+ platform=response.platform,
97
+ lst_update=date,
98
+ )
76
99
  class UserCall:
77
100
  """
78
101
  Representa uma mensagem recebida ou enviada pelo chatbot.
@@ -201,6 +224,10 @@ class UserCall:
201
224
  if len(element_list) > 20:
202
225
  raise ValueError("O número máximo de elementos é 20.")
203
226
 
227
+ if not text:
228
+ raise ValueError("O corpo da mensagem não pode ser vazio.")
229
+
230
+
204
231
  response = self.__wpp_server_client.send_list(
205
232
  {
206
233
  "hook_id": self.company_phone,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: chatgraph
3
- Version: 0.3.13
3
+ Version: 0.3.15
4
4
  Summary: A user-friendly chatbot library
5
5
  Home-page: https://github.com/irissonnlima/chatgraph
6
6
  License: MIT
@@ -15,10 +15,10 @@ chatgraph/pb/voll_pb2.py,sha256=WLwE7F1pe_elcnwRnSFqVDcFihLZ3JBq4ScTHNCqWGA,5328
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
17
  chatgraph/types/message_types.py,sha256=l488K4sVhTdOY5bbk47Y-qjfvfyn4h7bpmOFf2xGods,3334
18
- chatgraph/types/request_types.py,sha256=_TMQlGx6FD--XlLtSf3_sciJiWKAuJrFGM32h5nCBos,10743
18
+ chatgraph/types/request_types.py,sha256=Rju__bOLI3AG-l5aYTNv_SwqH_-pu1tNiiHA9PujN_M,11761
19
19
  chatgraph/types/route.py,sha256=2fuHEPKUL_Vuv4g8pB6M7eJLouxXasqjesdju6_eumE,2757
20
- chatgraph-0.3.13.dist-info/entry_points.txt,sha256=bO9_Q-PqE5vCNNo6ke_-3j2gHfKQMDGnKDTkNuCdBuA,48
21
- chatgraph-0.3.13.dist-info/LICENSE,sha256=rVJozpRzDlplOpvI8A1GvmfVS0ReYdZvMWc1j2jV0v8,1090
22
- chatgraph-0.3.13.dist-info/METADATA,sha256=BJ8Kmg4aM8vF9D7puWofNAsQLJp8aRTpIh9aXIhBrSI,12782
23
- chatgraph-0.3.13.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
24
- chatgraph-0.3.13.dist-info/RECORD,,
20
+ chatgraph-0.3.15.dist-info/entry_points.txt,sha256=bO9_Q-PqE5vCNNo6ke_-3j2gHfKQMDGnKDTkNuCdBuA,48
21
+ chatgraph-0.3.15.dist-info/LICENSE,sha256=rVJozpRzDlplOpvI8A1GvmfVS0ReYdZvMWc1j2jV0v8,1090
22
+ chatgraph-0.3.15.dist-info/METADATA,sha256=mNAlDag7ul4zfuMfKVvApureydphWgTxvEeNaC1dwqU,12782
23
+ chatgraph-0.3.15.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
24
+ chatgraph-0.3.15.dist-info/RECORD,,