From 3d3633592a50665784f223cae102370ddd90dc0e Mon Sep 17 00:00:00 2001 From: raphael Date: Fri, 17 Dec 2021 16:22:04 +0100 Subject: [PATCH] updates list for new rest result - list is now a json object which contains "messages" which is a JSON Array list --- main.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 8ea41ee..b2cd6db 100644 --- a/main.py +++ b/main.py @@ -7,6 +7,7 @@ import requests import base64 import re + SENDER_LENGTH = 4 PASSWORD_LENGTH = 8 @@ -109,6 +110,10 @@ class Bump: password = self.get_password() return password_decrypt(data, password).decode() + def push_fake(self, data): + print(self.encrypt(data)) + + def push(self, data): url = self.URL + "push" params = { @@ -121,8 +126,8 @@ class Bump: print(r.json()) - def peak(self): - return self.get_post("peak") + def peek(self): + return self.get_post("peek") def pop(self): return self.get_post("pop") @@ -148,10 +153,11 @@ class Bump: messages = requests.post(url, params).json() - if messages == {} or messages == None or messages == []: + if(messages == {} or messages == None or + "messages" in messages and messages["messages"] == []): return [{}] - elif type(messages) == list: - for message in messages: + elif "messages" in messages: + for message in messages.get("messages"): message['data'] = self.decrypt(message.get('data')) return messages @@ -186,3 +192,4 @@ class Bump: if __name__ == '__main__': b = Bump() + b.decrypt("M1dEAxKZ5HUHCJoRkgGOvAABhqCAAAAAAGG2eKTSlKXWLDQx5B_wssZsNwsanzQID2UyUm4KKuKYKgfwH5MG2N-qzt6K4mg3pfZmWPaiDB9PiqlX236k6zo9Yvvq")