summaryrefslogtreecommitdiffhomepage
path: root/libs/apprise/plugins/NotifyBase.py
diff options
context:
space:
mode:
Diffstat (limited to 'libs/apprise/plugins/NotifyBase.py')
-rw-r--r--libs/apprise/plugins/NotifyBase.py30
1 files changed, 20 insertions, 10 deletions
diff --git a/libs/apprise/plugins/NotifyBase.py b/libs/apprise/plugins/NotifyBase.py
index 82c025506..54e897906 100644
--- a/libs/apprise/plugins/NotifyBase.py
+++ b/libs/apprise/plugins/NotifyBase.py
@@ -265,7 +265,7 @@ class NotifyBase(BASE_OBJECT):
)
def notify(self, body, title=None, notify_type=NotifyType.INFO,
- overflow=None, attach=None, **kwargs):
+ overflow=None, attach=None, body_format=None, **kwargs):
"""
Performs notification
@@ -291,18 +291,22 @@ class NotifyBase(BASE_OBJECT):
title = '' if not title else title
# Apply our overflow (if defined)
- for chunk in self._apply_overflow(body=body, title=title,
- overflow=overflow):
+ for chunk in self._apply_overflow(
+ body=body, title=title, overflow=overflow,
+ body_format=body_format):
+
# Send notification
if not self.send(body=chunk['body'], title=chunk['title'],
- notify_type=notify_type, attach=attach):
+ notify_type=notify_type, attach=attach,
+ body_format=body_format):
# Toggle our return status flag
return False
return True
- def _apply_overflow(self, body, title=None, overflow=None):
+ def _apply_overflow(self, body, title=None, overflow=None,
+ body_format=None):
"""
Takes the message body and title as input. This function then
applies any defined overflow restrictions associated with the
@@ -334,18 +338,24 @@ class NotifyBase(BASE_OBJECT):
overflow = self.overflow_mode
if self.title_maxlen <= 0 and len(title) > 0:
- if self.notify_format == NotifyFormat.MARKDOWN:
- # Content is appended to body as markdown
- body = '**{}**\r\n{}'.format(title, body)
- elif self.notify_format == NotifyFormat.HTML:
+ if self.notify_format == NotifyFormat.HTML:
# Content is appended to body as html
body = '<{open_tag}>{title}</{close_tag}>' \
'<br />\r\n{body}'.format(
open_tag=self.default_html_tag_id,
- title=self.escape_html(title),
+ title=title,
close_tag=self.default_html_tag_id,
body=body)
+
+ elif self.notify_format == NotifyFormat.MARKDOWN and \
+ body_format == NotifyFormat.TEXT:
+ # Content is appended to body as markdown
+ title = title.lstrip('\r\n \t\v\f#-')
+ if title:
+ # Content is appended to body as text
+ body = '# {}\r\n{}'.format(title, body)
+
else:
# Content is appended to body as text
body = '{}\r\n{}'.format(title, body)