forked from HonusBot/HonusBot
Ok callRequest > 0 now
This commit is contained in:
parent
aef4e6fda4
commit
e8e3ed7d79
23
inline.py
23
inline.py
@ -148,29 +148,29 @@ class InlineBot:
|
||||
|
||||
def callRequest(self, command, senderid, text = ""):
|
||||
if not command:
|
||||
return self.errorText
|
||||
return None
|
||||
|
||||
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:
|
||||
return self.errorText
|
||||
if not r:
|
||||
return None
|
||||
|
||||
if len(r.text) < 1:
|
||||
return self.errorText
|
||||
return None
|
||||
|
||||
resp = None
|
||||
try:
|
||||
resp = json.loads(r.text, object_hook = asResponse)
|
||||
except:
|
||||
return self.errorText ## Invalid json
|
||||
return None ## Invalid json
|
||||
|
||||
if not resp.isAuthorized() or not resp.succeeded():
|
||||
return self.errorText
|
||||
return None
|
||||
|
||||
txt = r.headers[command.getHeaderField()]
|
||||
|
||||
if len(txt) < 1:
|
||||
return self.errorText ## Wrong api?
|
||||
return None ## Wrong api?
|
||||
|
||||
return txt
|
||||
|
||||
@ -215,6 +215,15 @@ class InlineBot:
|
||||
|
||||
qValue = self.callRequest(command, senderid, querySearch)
|
||||
contentText = ""
|
||||
|
||||
if qValue == None:
|
||||
return InlineQueryResultArticle(
|
||||
id=uuid.uuid4().hex,
|
||||
type="article",
|
||||
title="Error",
|
||||
input_message_content=InputTextMessageContent("Error", "HTML"),
|
||||
description=self.errorText
|
||||
)
|
||||
|
||||
if command.getMode() == "imageurl":
|
||||
contentText = InputTextMessageContent("<a href=\"" + qValue + "\">HonusBot</a>", "HTML")
|
||||
|
Loading…
Reference in New Issue
Block a user