owo lowg stuwf

This commit is contained in:
Christian Rendina 2020-05-05 12:48:25 +02:00
parent e8e3ed7d79
commit a6abf63973

View File

@ -153,23 +153,28 @@ class InlineBot:
r = requests.post(self.config.getApiUrl(), headers = { "Content-Type" : "application/json", "User-Agent" : self.config.getUserAgent() }, data = json.JSONEncoder().encode(JSONRequest(self.config, command.getName(), senderid, text).__dict__))
if not r:
self.logger.warning('Request api fail')
return None
if len(r.text) < 1:
self.logger.warning('Request text api fail')
return None
resp = None
try:
resp = json.loads(r.text, object_hook = asResponse)
except:
self.logger.warning('JSON deserialization failed')
return None ## Invalid json
if not resp.isAuthorized() or not resp.succeeded():
self.logger.warning('Unathorized/Unsuccessfull')
return None
txt = r.headers[command.getHeaderField()]
if len(txt) < 1:
self.logger.warning('Wrong response in header:',command.getHeaderField())
return None ## Wrong api?
return txt