Update plugin.py

This commit is contained in:
Gordon Shumway 2020-02-21 16:16:04 -05:00 committed by GitHub
parent d8dccfa83c
commit 5acca16e80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,7 +70,7 @@ class Azure(callbacks.Plugin):
response = requests.post(url, headers=headers, json=body) response = requests.post(url, headers=headers, json=body)
response.raise_for_status() response.raise_for_status()
result = response.json() result = response.json()
if result[0]['detectedLanguage']: if result[0].get('detectedLanguage'):
reply = "{0} [{1}~>{2}]".format(result[0]['translations'][0]['text'], result[0]['detectedLanguage']['language'], target) reply = "{0} [{1}~>{2}]".format(result[0]['translations'][0]['text'], result[0]['detectedLanguage']['language'], target)
else: else:
reply = "{0} [{1}~>{2}]".format(source, target) reply = "{0} [{1}~>{2}]".format(source, target)