-
Notifications
You must be signed in to change notification settings - Fork 148
choose message template format HTML/MarkDown #80
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool contribution. Thanks!
A few small comments. But that should be fixable quickly.
@@ -117,6 +119,11 @@ func main() { | |||
Default("/templates/default.tmpl"). | |||
ExistingFilesVar(&config.templatesPaths) | |||
|
|||
a.Flag("parse.mode", "The template formatting mode HTML/Markdown"). | |||
Envar("TEMPLATE_FORMAT"). | |||
Default(string(telebot.ModeHTML)). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than introducing a direct dependency on telebot in the main.go
, could we create both ParseHTML
and ParseMarkdown
in pkg/telegram
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used telebot.ParseMode
because telebot.SendMessage()
depends on it, we can do what you said above, but still, I need to cast the param in telebot.SendMessage()
to telebot.ParseMode
to be able to compile cf:
pkg/telegram/bot.go:320:85: cannot use b.parseMode (type ParseMode) as type telebot.ParseMode in field value
make: *** [build] Error 2
What do you think? casting casting still holds the dependancy anyway.
@@ -66,6 +66,7 @@ type Bot struct { | |||
logger log.Logger | |||
revision string | |||
startTime time.Time | |||
parseMode telebot.ParseMode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we set this still to telebot.ModeHTML
as this is the current default.
Nice feature, I would love to use it. |
This MR let the user choose the template message format between HTML and Markdown. The format can be submitted as a parameter
parse.mode
or envTEMPLATE_FORMAT
The docker image is available
rg.fr-par.scw.cloud/devel/alertmanager-bot:0.4.1
for testing