add conditions picture and/or message

This commit is contained in:
Jérémy CHABERNAUD 2019-12-30 23:57:49 +01:00
parent c8848eb05a
commit 9d632a917e
No known key found for this signature in database
GPG Key ID: 6C9DD0B115AC4712
2 changed files with 9 additions and 4 deletions

View File

@ -39,12 +39,15 @@ class Telegram(plugins.Plugin):
message = Voice(lang=config['main']['lang']).on_last_session_tweet(last_session)
bot = telegram.Bot(self.options['bot_token'])
bot.sendPhoto(chat_id=self.options['chat_id'], photo=open(picture, 'rb'))
bot.sendMessage(chat_id=self.options['chat_id'], text=message, disable_web_page_preview=True)
if self.options['send_picture'] is True:
bot.sendPhoto(chat_id=self.options['chat_id'], photo=open(picture, 'rb'))
logging.info("telegram: picture sent")
if self.options['send_message'] is True:
bot.sendMessage(chat_id=self.options['chat_id'], text=message, disable_web_page_preview=True)
logging.info("telegram: message sent: %s" % message)
last_session.save_session_id()
logging.info("telegram: %s" % message)
display.set('status', 'Message sent!')
display.set('status', 'Telegram notification sent!')
display.update(force=True)
except Exception:
logging.exception("Error while sending on Telegram")

View File

@ -3,3 +3,5 @@ telegram:
bot_token: ~
bot_name: pwnagotchi
chat_id: ~
send_picture: true
send_message: true