From 35c7baa85490f486b33d3ab22046077eef8d8a40 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Tue, 22 Aug 2023 03:35:15 +0200 Subject: [PATCH] Add author --- rss.go | 5 +++++ tg.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/rss.go b/rss.go index 348355d..243f115 100644 --- a/rss.go +++ b/rss.go @@ -14,6 +14,7 @@ type Item struct { Link string `xml:"link"` Description string `xml:"description"` PubDate RssDate `xml:"pubDate"` + Author Author `xml:"author"` } type Channel struct { @@ -32,6 +33,10 @@ type RssDate struct { time.Time } +type Author struct { + Name string `xml:"name"` +} + func (c *RssDate) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { var v string dateFormat := "Mon, 02 Jan 2006 15:04:05 GMT" diff --git a/tg.go b/tg.go index e2f86a5..f1ee6e9 100644 --- a/tg.go +++ b/tg.go @@ -33,7 +33,7 @@ func init() { } func SendItemToTelegram(item *Item) error { - text := fmt.Sprintf("%s (%s)\n", item.Title, humanize.Time(item.PubDate.Time)) + text := fmt.Sprintf("%s\n_%s by_ [%s](https://stacker.news/%s)\n", item.Title, humanize.Time(item.PubDate.Time), item.Author.Name, item.Author.Name) linkItem := item.Link != item.Guid if linkItem { text += fmt.Sprintf("[Link](%s) ", item.Link)