diff --git a/internal/alert/telegram.go b/internal/alert/telegram.go index 63229fdb..f2717e21 100644 --- a/internal/alert/telegram.go +++ b/internal/alert/telegram.go @@ -2,25 +2,29 @@ package alert import ( "bytes" + "embed" "html/template" "strconv" - telegramBot "github.com/go-telegram-bot-api/telegram-bot-api" + tg "github.com/go-telegram-bot-api/telegram-bot-api" "teler.app/pkg/errors" ) +//go:embed template/*.tmpl +var tmpl embed.FS + func toTelegram(token string, chatID string, log map[string]string) { id, err := strconv.ParseInt(chatID, 10, 64) if err != nil { errors.Show(err.Error()) } - api, err := telegramBot.NewBotAPI(token) + api, err := tg.NewBotAPI(token) if err != nil { errors.Exit(err.Error()) } - message := telegramBot.NewMessage(id, telegramMessage(log)) + message := tg.NewMessage(id, telegramMessage(log)) message.ParseMode = "MarkdownV2" // TODO: Displays an error if it does not exceed the rate-limit @@ -31,7 +35,7 @@ func toTelegram(token string, chatID string, log map[string]string) { func telegramMessage(log map[string]string) string { var buffer bytes.Buffer - tpl, err := template.ParseFiles("internal/alert/template/telegram.tmpl") + tpl, err := template.ParseFS(tmpl, "template/telegram.tmpl") if err != nil { errors.Exit(err.Error()) }