add title

This commit is contained in:
2022-05-07 21:01:14 -04:00
parent 3f4be7b0ae
commit 7d8f7b58a8
4 changed files with 10 additions and 6 deletions

View File

@ -16,7 +16,7 @@ import (
)
type TelegramSender interface {
SendLink(link, channel, rhash string) error
SendLink(link, channel, rhash, title string) error
}
type telegramSender struct {
@ -26,14 +26,17 @@ type telegramSender struct {
rateLimiterPerSec *rate.Limiter
}
func (ts *telegramSender) SendLink(link string, channel string, rhash string) error {
func (ts *telegramSender) SendLink(link, channel, rhash, title string) error {
if title == "" {
title = "Link"
}
msg := struct {
ChatID string `json:"chat_id"`
Text string `json:"text"`
ParseMode string `json:"parse_mode"`
}{
ChatID: channel,
Text: fmt.Sprintf(`<a href="%s">➢</a> <a href="%s">Link</a>`, genIVLink(link, rhash), link),
Text: fmt.Sprintf(`<a href="%s">➢</a> <a href="%s">%s</a>`, genIVLink(link, rhash), link, title),
ParseMode: "HTML",
}
data, err := json.Marshal(msg)