try/except api call

This commit is contained in:
Gordon Shumway 2019-04-10 04:08:03 -04:00 committed by GitHub
parent cd4ecbeb36
commit 2aabb0c157
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

View File

@ -70,12 +70,15 @@ class BotLibre(callbacks.Plugin):
'instance': self.registryValue('instance'),
'message': query
}
r = requests.post(self.url, json=payload)
j = r.json()
response = j['message']
self.conversation[channel] = j['conversation']
if response:
irc.reply(j['message'])
try:
r = requests.post(self.url, json=payload)
j = r.json()
response = j['message']
self.conversation[channel] = j['conversation']
if response:
irc.reply(j['message'])
except:
return
def botlibre(self, irc, msg, args, text):
"""Manual Call to the Cleverbot.io API"""