alerta / alerta-contrib

Contributed integrations, plugins and custom webhooks
http://alerta.io
MIT License
119 stars 170 forks source link

[Telegram plugin] Can't find mentioned Jinja2 template #367

Closed Beetix closed 2 years ago

Beetix commented 2 years ago

Issue Summary In the Telegram plugin's README.md an example template is mentioned in Explorer. Once on the site there doesn't seem to be any Jinja2 template.

xpufx commented 2 years ago

I couldn't find it either. However the MS Teams plugin has a little example of the template format. Should work if you create a file and point the telegram plugin to it.

https://github.com/alerta/alerta-contrib/blob/5d79ea4bbda44bde0a578856fa465a89e64dee1d/plugins/msteams/README.md

MS_TEAMS_SUMMARY_FMT = '<b>[{{ alert.status|capitalize }}]</b> [{{ alert.severity|upper }}] Event {{ alert.event }} on <b>{{ alert.resource }}</b><br>{{ alert.text }}'

Also, the telegram plugin is already using a template but it's embedded into the script. See "DEFAULT_TMPL" variable in there.

Beetix commented 2 years ago

I couldn't find it either. However the MS Teams plugin has a little example of the template format. Should work if you create a file and point the telegram plugin to it.

https://github.com/alerta/alerta-contrib/blob/5d79ea4bbda44bde0a578856fa465a89e64dee1d/plugins/msteams/README.md

MS_TEAMS_SUMMARY_FMT = '<b>[{{ alert.status|capitalize }}]</b> [{{ alert.severity|upper }}] Event {{ alert.event }} on <b>{{ alert.resource }}</b><br>{{ alert.text }}'

Also, the telegram plugin is already using a template but it's embedded into the script. See "DEFAULT_TMPL" variable in there.

Yes, I ended up using the DEFAULT_TMPL variable 😃 Could be worth embedding it or change the link in the README.md.

darkobas2 commented 2 years ago

what are the possible filters we can use ?

edit: https://jinja.palletsprojects.com/en/latest/templates/#builtin-filters