summaryrefslogtreecommitdiff
path: root/rss.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-08-15 13:46:26 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-08-15 13:46:26 +0200
commit2cedfd17b76067124fe1b3455ad0f135a95e5390 (patch)
treef2c9752ae76dab1375814aff3cf5fc45cf08bed0 /rss.go
parent420bcc416b57372365bc9cb8df154c038f273c91 (diff)
Don't show author if there is none
Diffstat (limited to 'rss.go')
-rw-r--r--rss.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/rss.go b/rss.go
index 31be5ba..03bfba0 100644
--- a/rss.go
+++ b/rss.go
@@ -60,11 +60,20 @@ type News struct {
var news = make(chan News)
+func (n News) String() string {
+ s := fmt.Sprintf("%v: %v", n.Name, n.Title)
+ if n.Author != "" {
+ s += fmt.Sprintf(" (%v) ", n.Author)
+ } else {
+ s += " - "
+ }
+ s += fmt.Sprintf("%v", n.Link)
+ return s
+}
+
func ShowNews(conn *irc.Conn, _ *irc.Line) {
for n := range news {
- s := fmt.Sprintf("%v: %v (%v) %v",
- n.Name, n.Title, n.Author, n.Link)
- conn.Notice(*room, s)
+ conn.Notice(*room, n.String())
}
}