mirror of https://github.com/evilhero/mylar
cleanup of code
This commit is contained in:
parent
d96265d008
commit
7f44f4a278
|
@ -340,25 +340,21 @@ class TELEGRAM:
|
|||
else:
|
||||
self.token = test_token
|
||||
|
||||
def notify(self, message, imageurl=None):
|
||||
if imageurl:
|
||||
def notify(self, message, imageUrl=None):
|
||||
# Construct message
|
||||
payload = {'chat_id': self.userid, 'text': message}
|
||||
sendMethod = "sendMessage"
|
||||
|
||||
if imageUrl:
|
||||
# Construct message
|
||||
payload = {'chat_id': self.userid, 'caption': message, 'photo': imageurl}
|
||||
payload = {'chat_id': self.userid, 'caption': message, 'photo': imageUrl}
|
||||
sendMethod = "sendPhoto"
|
||||
|
||||
# Send message to user using Telegram's Bot API
|
||||
try:
|
||||
response = requests.post(self.TELEGRAM_API % (self.token, "sendPhoto"), json=payload, verify=True)
|
||||
except Exception, e:
|
||||
logger.info(u'Telegram notify failed: ' + str(e))
|
||||
else:
|
||||
# Construct message
|
||||
payload = {'chat_id': self.userid, 'text': message}
|
||||
|
||||
# Send message to user using Telegram's Bot API
|
||||
try:
|
||||
response = requests.post(self.TELEGRAM_API % (self.token, "sendMessage"), json=payload, verify=True)
|
||||
except Exception, e:
|
||||
logger.info(u'Telegram notify failed: ' + str(e))
|
||||
# Send message to user using Telegram's Bot API
|
||||
try:
|
||||
response = requests.post(self.TELEGRAM_API % (self.token, sendMethod), json=payload, verify=True)
|
||||
except Exception as e:
|
||||
logger.info('Telegram notify failed: ' + str(e))
|
||||
|
||||
# Error logging
|
||||
sent_successfuly = True
|
||||
|
|
Loading…
Reference in New Issue