forked from HonusBot/HonusBot
^
This commit is contained in:
parent
f68e0234a7
commit
497cfe33b0
20
inline.py
20
inline.py
@ -115,6 +115,15 @@ class Config:
|
|||||||
def getUserAgent(self):
|
def getUserAgent(self):
|
||||||
return self.userAgent
|
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:
|
class InlineBot:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.errorText = "Sowwy mawster, an ewror occuwed. ;;w;;"
|
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("Lewd", "Say hi to the police", "imageurl", "imageUrl"))
|
||||||
self.commands.append(Command("Rasoio", "Dai facciamogli lo scherzo del rasoio!1!!", "genericurl", "htmlDescription"))
|
self.commands.append(Command("Rasoio", "Dai facciamogli lo scherzo del rasoio!1!!", "genericurl", "htmlDescription"))
|
||||||
self.cancerCommand = Command("Cancer", "Search cancer", "imageurl", "imageurl")
|
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 = ""):
|
def callRequest(self, command, senderid, text = ""):
|
||||||
if not command:
|
if not command:
|
||||||
@ -163,7 +163,7 @@ class InlineBot:
|
|||||||
|
|
||||||
resp = None
|
resp = None
|
||||||
#try:
|
#try:
|
||||||
resp = json.loads(r.text, object_hook = self.asResponse)
|
resp = json.loads(r.text, object_hook = jsonasResponse)
|
||||||
#except:
|
#except:
|
||||||
# self.logger.warning('JSON deserialization failed')
|
# self.logger.warning('JSON deserialization failed')
|
||||||
# return None ## Invalid json
|
# return None ## Invalid json
|
||||||
|
Loading…
x
Reference in New Issue
Block a user