package main import ( "fmt" "dim13.org/rss" irc "github.com/fluffle/goirc/client" ) type RSS struct{ Command } func (v RSS) Handle(conn *irc.Conn, line *irc.Line) { news, err := rss.Fetch(v.Arg) if err != nil { conn.Privmsg(line.Target(), err.Error()) return } if line.Public() && len(news.Channel.Items) > 3 { news.Channel.Items = news.Channel.Items[:3] } for n, i := range news.Channel.Items { s := fmt.Sprintf("%2d. %v - %v", n+1, i.Title, i.Link) conn.Privmsg(line.Target(), s) } } func init() { Register("news", &RSS{ Command{ Help: "LOR news (msg private to see all)", Arg: `https://www.linux.org.ru/section-rss.jsp?section=1`, }, }) Register("forum", &RSS{ Command{ Help: "LOR forum (msg private to see all)", Arg: `https://www.linux.org.ru/section-rss.jsp?section=2`, }, }) Register("gallery", &RSS{ Command{ Help: "LOR gallery (msg private to see all)", Arg: `https://www.linux.org.ru/section-rss.jsp?section=3`, }, }) Register("bsd", &RSS{ Command{ Help: "Undeadly news (msg private to see all)", Arg: `http://undeadly.org/cgi?action=rss`, }, }) }