summaryrefslogtreecommitdiff
path: root/rss.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-12-21 00:38:25 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-12-21 00:38:25 +0100
commit75bec51affee1f01d107e68b38180c9d5d5edae0 (patch)
tree05f7d5403be11b4c81ad397335465c71b62cb9c5 /rss.go
parent432d01e3872d050663379006a7e66dc2932a89d7 (diff)
Split feeds
Diffstat (limited to 'rss.go')
-rw-r--r--rss.go66
1 files changed, 4 insertions, 62 deletions
diff --git a/rss.go b/rss.go
index 741b81d..6f5239b 100644
--- a/rss.go
+++ b/rss.go
@@ -14,64 +14,6 @@ type Feed struct {
Every time.Duration
}
-var Feeds = []Feed{
- {
- Name: "LOR News",
- URL: `https://www.linux.org.ru/section-rss.jsp?section=1`,
- Every: time.Hour,
- },
- {
- Name: "LOR Forum",
- URL: `https://www.linux.org.ru/section-rss.jsp?section=2&filter=tech`,
- Every: time.Minute,
- },
- {
- Name: "LOR Gallery",
- URL: `https://www.linux.org.ru/section-rss.jsp?section=3`,
- Every: 2 * time.Hour,
- },
- {
- Name: "LOR Polls",
- URL: `https://www.linux.org.ru/section-rss.jsp?section=5`,
- Every: 2 * time.Hour,
- },
- {
- Name: "OpenNET",
- URL: `http://www.opennet.ru/opennews/opennews_all_noadv.rss`,
- Every: 4 * time.Hour,
- },
- {
- Name: "Undeadly",
- URL: `http://undeadly.org/cgi?action=rss`,
- Every: 2 * time.Hour,
- },
- {
- Name: "Kernel",
- URL: `https://www.kernel.org/feeds/kdist.xml`,
- Every: 6 * time.Hour,
- },
- {
- Name: "Ted Unangst",
- URL: `http://www.tedunangst.com/flak/rss`,
- Every: 6 * time.Hour,
- },
- {
- Name: "Calomel",
- URL: `https://calomel.org/calomel_rss.xml`,
- Every: 6 * time.Hour,
- },
- {
- Name: "Golang News",
- URL: `https://golangnews.com/index.xml`,
- Every: 6 * time.Hour,
- },
- {
- Name: "Golang Weekly",
- URL: `http://golangweekly.com/rss/1fg21ahk`,
- Every: 6 * time.Hour,
- },
-}
-
type News struct {
Feed
rss.Item
@@ -88,7 +30,7 @@ func (n News) String() string {
return s
}
-func (f Feed) Watch(news chan News) {
+func (f Feed) watch(news chan News) {
ticker := time.NewTicker(f.Every)
defer ticker.Stop()
for t := range ticker.C {
@@ -106,10 +48,10 @@ func (f Feed) Watch(news chan News) {
}
}
-func watchNews(msg chan string) {
+func Watch(msg chan string, feeds []Feed) {
news := make(chan News)
- for _, feed := range Feeds {
- go feed.Watch(news)
+ for _, feed := range feeds {
+ go feed.watch(news)
}
for n := range news {
msg <- fmt.Sprint(n)