fixes handling json list output
This commit is contained in:
parent
424812432c
commit
36d5bd42ff
27
main.py
27
main.py
@ -125,20 +125,41 @@ class Bump:
|
||||
return self.get_post("pop")
|
||||
|
||||
def list(self):
|
||||
return self.get_post("list")
|
||||
params = {
|
||||
'minutes': 2
|
||||
}
|
||||
return self.get_post("list", params)
|
||||
|
||||
def clear(self):
|
||||
return self.get_post("clear")
|
||||
|
||||
def get_post(self, mechanism):
|
||||
def get_post(self, mechanism, add_params = None):
|
||||
url = self.URL + mechanism
|
||||
|
||||
params = {
|
||||
'sender': self.get_sender()
|
||||
}
|
||||
|
||||
if add_params != None:
|
||||
params.update(add_params)
|
||||
|
||||
r = requests.post(url, params)
|
||||
if r.json() == {}:
|
||||
|
||||
if r.json() == {} or r.json() == None:
|
||||
return {}
|
||||
elif type(r.json()) == list:
|
||||
messages = []
|
||||
for message in r.json():
|
||||
messages.append(self.decrypt(message.get('data')))
|
||||
|
||||
return messages
|
||||
else:
|
||||
return self.decrypt(r.json().get('data'))
|
||||
|
||||
def alert(self):
|
||||
while True:
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
b = Bump()
|
||||
|
Loading…
Reference in New Issue
Block a user