forked from HonusBot/HonusBot
owo lowg stuwf
This commit is contained in:
parent
e8e3ed7d79
commit
a6abf63973
@ -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__))
|
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:
|
if not r:
|
||||||
|
self.logger.warning('Request api fail')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if len(r.text) < 1:
|
if len(r.text) < 1:
|
||||||
|
self.logger.warning('Request text api fail')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
resp = None
|
resp = None
|
||||||
try:
|
try:
|
||||||
resp = json.loads(r.text, object_hook = asResponse)
|
resp = json.loads(r.text, object_hook = asResponse)
|
||||||
except:
|
except:
|
||||||
|
self.logger.warning('JSON deserialization failed')
|
||||||
return None ## Invalid json
|
return None ## Invalid json
|
||||||
|
|
||||||
if not resp.isAuthorized() or not resp.succeeded():
|
if not resp.isAuthorized() or not resp.succeeded():
|
||||||
|
self.logger.warning('Unathorized/Unsuccessfull')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
txt = r.headers[command.getHeaderField()]
|
txt = r.headers[command.getHeaderField()]
|
||||||
|
|
||||||
if len(txt) < 1:
|
if len(txt) < 1:
|
||||||
|
self.logger.warning('Wrong response in header:',command.getHeaderField())
|
||||||
return None ## Wrong api?
|
return None ## Wrong api?
|
||||||
|
|
||||||
return txt
|
return txt
|
||||||
|
Loading…
Reference in New Issue
Block a user