From 497cfe33b02134d2f12cd61034292477e89ccda5 Mon Sep 17 00:00:00 2001 From: Arves100 Date: Tue, 5 May 2020 17:14:38 +0200 Subject: [PATCH] ^ --- inline.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/inline.py b/inline.py index 8f3532a..0220352 100644 --- a/inline.py +++ b/inline.py @@ -115,6 +115,15 @@ class Config: def getUserAgent(self): return self.userAgent +def jsonasResponse(dct): + print("LOG:::",str(dct)) + if "imageUrl" in dct: + return JSONResponse(dct["authorized"], dct["success"], dct["imageUrl"], "") + elif "htmlDescription" in dct: + return JSONResponse(dct["authorized"], dct["success"], "", dct["htmlDescription"]) + else: + raise Exception("Invalid JSON") + class InlineBot: def __init__(self): self.errorText = "Sowwy mawster, an ewror occuwed. ;;w;;" @@ -137,15 +146,6 @@ class InlineBot: self.commands.append(Command("Lewd", "Say hi to the police", "imageurl", "imageUrl")) self.commands.append(Command("Rasoio", "Dai facciamogli lo scherzo del rasoio!1!!", "genericurl", "htmlDescription")) self.cancerCommand = Command("Cancer", "Search cancer", "imageurl", "imageurl") - - def asResponse(self, dct): - print("LOG:::",str(dct)) - if "imageUrl" in dct: - return JSONResponse(dct["authorized"], dct["success"], dct["imageUrl"], "") - elif "htmlDescription" in dct: - return JSONResponse(dct["authorized"], dct["success"], "", dct["htmlDescription"]) - else: - raise Exception("Invalid JSON") def callRequest(self, command, senderid, text = ""): if not command: @@ -163,7 +163,7 @@ class InlineBot: resp = None #try: - resp = json.loads(r.text, object_hook = self.asResponse) + resp = json.loads(r.text, object_hook = jsonasResponse) #except: # self.logger.warning('JSON deserialization failed') # return None ## Invalid json