support for html parsing in telegram messages
This commit is contained in:
parent
f63552fa09
commit
a025fcfba2
@ -18,7 +18,7 @@ var (
|
|||||||
|
|
||||||
TelegramBotToken = envvars.String("TELEGRAM_API_TOKEN", "")
|
TelegramBotToken = envvars.String("TELEGRAM_API_TOKEN", "")
|
||||||
TelegramChatID = envvars.Int64("TELEGRAM_CHAT_ID", 0)
|
TelegramChatID = envvars.Int64("TELEGRAM_CHAT_ID", 0)
|
||||||
TelegramOrganizeMessagePatternStr = logic.EscSeqReplacer.Replace(envvars.String("TELEGRAM_ORGANIZE_MESSAGE_PATTERN", `Download finished{{range .}}\n{{.Anime.Title.UserPreferred}} episode {{.Episode}}{{end}}`))
|
TelegramOrganizeMessagePatternStr = logic.EscSeqReplacer.Replace(envvars.String("TELEGRAM_ORGANIZE_MESSAGE_PATTERN", `<u><b>Recently Downloaded Animes ({{len .}} eps)</b></u>{{range .}}\n{{.Anime.Title.UserPreferred}} Episode {{.Episode}}{{end}}`))
|
||||||
TelegramOrganizeMessagePattern = template.Must(template.New("TELEGRAM_ORGANIZE_MESSAGE_PATTERN").Parse(TelegramOrganizeMessagePatternStr))
|
TelegramOrganizeMessagePattern = template.Must(template.New("TELEGRAM_ORGANIZE_MESSAGE_PATTERN").Parse(TelegramOrganizeMessagePatternStr))
|
||||||
TelegramOrganizeMessageSendCondition = envvars.ObjectSlice("TELEGRAM_ORGANIZE_MESSAGE_SEND_CONDITION", ",", []SendCondition{SendConditionAlways}, SendConditionFromString)
|
TelegramOrganizeMessageSendCondition = envvars.ObjectSlice("TELEGRAM_ORGANIZE_MESSAGE_SEND_CONDITION", ",", []SendCondition{SendConditionAlways}, SendConditionFromString)
|
||||||
TelegramOrganizeMessageSendInterval = envvars.Duration("TELEGRAM_ORGANIZE_MESSAGE_SEND_INTERVAL", 0)
|
TelegramOrganizeMessageSendInterval = envvars.Duration("TELEGRAM_ORGANIZE_MESSAGE_SEND_INTERVAL", 0)
|
||||||
|
@ -72,11 +72,12 @@ func sendAllQueuedAnimeEpisodes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SendTelegramMessage(text string) {
|
func SendTelegramMessage(text string) {
|
||||||
if TelegramBot == nil {
|
if TelegramBot == nil || strings.TrimSpace(text) == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := tgbotapi.NewMessage(TelegramChatID, text)
|
msg := tgbotapi.NewMessage(TelegramChatID, text)
|
||||||
|
msg.ParseMode = "html"
|
||||||
_, err := TelegramBot.Send(msg)
|
_, err := TelegramBot.Send(msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
adverr.Println(adverr.Wrap("could not send telegram message", err))
|
adverr.Println(adverr.Wrap("could not send telegram message", err))
|
||||||
|
Loading…
Reference in New Issue
Block a user