@@ -214,12 +214,42 @@ def get_web_api_log(token, product_id = 0, key = "", machine_code="", friendly_n
214214
215215 if jobj == None or not ("result" in jobj ) or jobj ["result" ] == 1 :
216216 if jobj != None :
217- return (False , jobj ["message" ])
217+ return (None , jobj ["message" ])
218218 else :
219- return (False , "Could not contact the server." )
219+ return (None , "Could not contact the server." )
220220
221221 return (jobj ["logs" ], "" )
222222
223+ class Message :
224+
225+ @staticmethod
226+ def get_messages (token , channel = "" , time = 0 ):
227+
228+ """
229+ This method will return a list of messages that were broadcasted.
230+ You can create new messages here. Messages can be filtered based on the time and the channel.
231+
232+ More docs: https://app.cryptolens.io/docs/api/v3/GetMessages
233+ """
234+
235+ try :
236+ response = HelperMethods .send_request ("/message/getmessages/" , {"token" :token , "Channel" : channel , "Time" : time })
237+ except HTTPError as e :
238+ response = e .read ()
239+ except URLError as e :
240+ return (None , "Could not contact the server. Error message: " + str (e ))
241+ except Exception :
242+ return (None , "Could not contact the server." )
243+
244+ jobj = json .loads (response )
245+
246+ if jobj == None or not ("result" in jobj ) or jobj ["result" ] == 1 :
247+ if jobj != None :
248+ return (None , jobj ["message" ])
249+ else :
250+ return (None , "Could not contact the server." )
251+
252+ return (jobj ["messages" ], "" )
223253
224254class Helpers :
225255
@@ -264,5 +294,4 @@ def IsOnRightMachine(license_key, is_floating_license = False, allow_overdraft=F
264294 if current_mid == act_machine .Mid :
265295 return True
266296
267- return False
268-
297+ return False
0 commit comments