Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to parse telegram text as HTML or markdown #231

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions ntfy/backends/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
config_file = path.join(config_dir, 'telegram.ini')


def notify(title, message, retcode=None):
"""Sends message over Telegram using telegram-send, title is ignored."""
def notify(title, message, parse_mode="text", retcode=None):
"""
Sends message over Telegram using telegram-send, title is ignored.

Optional parameters:
* ``parse_mode`` - How telegram parses the text. Possible options are "text", "markdown" or "html". More details here: https://core.telegram.org/bots/api#formatting-options
"""
if not path.exists(config_file):
if not path.exists(config_dir):
makedirs(config_dir)
print("Follow the instructions to configure the Telegram backend.\n")
configure(config_file)
send(messages=[message], conf=config_file)
send(messages=[message], parse_mode=parse_mode, conf=config_file)