fallback to default text notification in case of errors

This commit is contained in:
Bart274 2020-01-31 15:41:12 +01:00 committed by evilhero
parent 7f44f4a278
commit 563439acdf
No known key found for this signature in database
GPG Key ID: 3E12C51E39D91142
1 changed files with 6 additions and 3 deletions

View File

@ -357,13 +357,16 @@ class TELEGRAM:
logger.info('Telegram notify failed: ' + str(e))
# Error logging
sent_successfuly = True
sent_successfully = True
if not response.status_code == 200:
logger.info(u'Could not send notification to TelegramBot (token=%s). Response: [%s]' % (self.token, response.text))
sent_successfuly = False
sent_successfully = False
if not sent_successfully and sendMethod != "sendMessage":
return self.notify(message)
logger.info(u"Telegram notifications sent.")
return sent_successfuly
return sent_successfully
def test_notify(self):
return self.notify('Test Message: Release the Ninjas!')