Refactor notification titles to allow for them to be None, this also includes a change in Telegram to only include the title if it's present, and to use a Markdown parse mode for messages (#3100)

This commit is contained in:
Lewis Juggins authored and Paulus Schoutsen committed 2016-09-01 14:35:46 +01:00
1 parent 5036bb0bc6
commit 0bcfb65a30
18 files changed
+50 -34

No files matched your search

+11 -1
View File
@@ -106,10 +106,20 @@ class TelegramNotificationService(BaseNotificationService):
elif data is not None and ATTR_DOCUMENT in data:
return self.send_document(data.get(ATTR_DOCUMENT))
text = ''
if title:
text = '{} {}'.format(title, message)
else:
text = message
parse_mode = telegram.parsemode.ParseMode.MARKDOWN
# send message
try:
self.bot.sendMessage(chat_id=self._chat_id,
text=title + " " + message)
text=text,
parse_mode=parse_mode)
except telegram.error.TelegramError:
_LOGGER.exception("Error sending message.")
return