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

choose message template format HTML/MarkDown#80

Open
kaminek wants to merge 1 commit into
metalmatze:masterfrom
kaminek:master
Open

choose message template format HTML/MarkDown#80
kaminek wants to merge 1 commit into
metalmatze:masterfrom
kaminek:master

Conversation

@kaminek
Copy link
Copy Markdown

@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
Copy Markdown
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.


a.Flag("parse.mode", "The template formatting mode HTML/Markdown").
Envar("TEMPLATE_FORMAT").
Default(string(telebot.ModeHTML)).
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread pkg/telegram/bot.go
logger log.Logger
revision string
startTime time.Time
parseMode telebot.ParseMode
Copy link
Copy Markdown
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
Copy Markdown

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