diff --git a/pkg/telegram/telegram.go b/pkg/telegram/telegram.go index ff91211..1ebf090 100644 --- a/pkg/telegram/telegram.go +++ b/pkg/telegram/telegram.go @@ -44,7 +44,10 @@ func (t *TelegramClient) SendMessageForItem(item interface{}, url string, messag } func (t *TelegramClient) sendMessageForRSSItem(item *gofeed.Item, url string, messagePrefix string, telegramChannel string) (tgbotapi.Message, error) { - msgBody := strings.TrimSpace(item.Title) + "\n" + url + msgBody := strings.TrimSpace(item.Title) + if url != "" { + msgBody = "" + msgBody + "" + } if messagePrefix != "" { msgBody = "" + messagePrefix + "" + ": " + msgBody } @@ -62,12 +65,15 @@ func (t *TelegramClient) sendMessageForRSSItem(item *gofeed.Item, url string, me } func (t *TelegramClient) sendMessageForHNItem(item hackernews.HNItem, url string) (tgbotapi.Message, error) { - msgBody := "HackerNews: " + item.Title - if url != "" { - msgBody += "\n" + url - } + msgBody := "HackerNews: " if t.YcombinatorLink { - msgBody += "\n" + "https://news.ycombinator.com/item?id=" + strconv.Itoa(item.ID) + msgBody = "HackerNews: " + } + + if url != "" { + msgBody += "" + item.Title + "" + } else { + msgBody += item.Title } msg := tgbotapi.NewMessageToChannel(t.TelegramChannel, msgBody) msg.DisableWebPagePreview = t.TelegramPreviewLink