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