Skip to content
This repository has been archived by the owner on Aug 14, 2022. It is now read-only.

choose message template format HTML/MarkDown #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kaminek
Copy link

@kaminek kaminek commented Sep 29, 2019

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 env TEMPLATE_FORMAT

The docker image is available rg.fr-par.scw.cloud/devel/alertmanager-bot:0.4.1 for testing

@kaminek kaminek changed the title choose message template format choose message template format HTML/MarkDown Sep 29, 2019
Copy link
Owner

@metalmatze metalmatze left a 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)).
Copy link
Owner

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.

Copy link
Author

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
Copy link
Owner

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.

@isac-seven
Copy link

Nice feature, I would love to use it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants