Merge pull request #1 from AcidicNic/askthecaterpillar_edgecase

added edge case incase ask the caterpillar is down
This commit is contained in:
JarbasAI 2020-01-17 01:42:43 +00:00 committed by GitHub
commit 52222d565c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -470,6 +470,8 @@ class AskTheCaterpillar:
@staticmethod
def ask_the_caterpillar(query):
data = requests.post('https://www.askthecaterpillar.com/query', {"query": query})
data = json.loads(data.text)
return data["data"]["messages"][0]["content"]
if data.status_code == 200:
data = json.loads(data.text)
return data["data"]["messages"][0]["content"]
else:
return f"Error {r.status_code}: {r.reason}"