mirror of
https://github.com/evilhero/mylar
synced 2024-12-22 07:42:24 +00:00
cleanup of code
This commit is contained in:
parent
d96265d008
commit
7f44f4a278
1 changed files with 13 additions and 17 deletions
|
@ -340,25 +340,21 @@ class TELEGRAM:
|
|||
else:
|
||||
self.token = test_token
|
||||
|
||||
def notify(self, message, imageurl=None):
|
||||
if imageurl:
|
||||
# Construct message
|
||||
payload = {'chat_id': self.userid, 'caption': message, 'photo': imageurl}
|
||||
|
||||
# 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:
|
||||
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}
|
||||
sendMethod = "sendPhoto"
|
||||
|
||||
# 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))
|
||||
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 a new issue