mirror of
https://code.dnix.de/da/flokatirc
synced 2026-07-27 08:59:44 +02:00
Added module configuration params: -params=<key>:<val>(!<key>:<val>])*
This commit is contained in:
+11
-6
@@ -23,9 +23,14 @@ import (
|
||||
var hideOutput = true
|
||||
|
||||
func init() {
|
||||
msgHandlers["rss"] = rssHandleMessage
|
||||
log.Printf("Initializing news module")
|
||||
path := "newsfeeds.conf"
|
||||
MsgHandlers["rss"] = rssHandleMessage
|
||||
log.Printf("Initializing rss module")
|
||||
go rssRun()
|
||||
}
|
||||
|
||||
func rssRun() {
|
||||
time.Sleep(5 * time.Second)
|
||||
path := ModParams["rss-feeds"]
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@@ -53,7 +58,7 @@ func rssPollFeed(uri string, timeout int, cr xmlx.CharsetFunc) {
|
||||
log.Printf("Polling feed: %s", uri)
|
||||
if err := feed.Fetch(uri, cr); err != nil {
|
||||
log.Printf("[e] %s: %s", "*", uri, err)
|
||||
sayCh <- fmt.Sprintf("%s\n[RSS] Error %s: %s", "*", uri, err)
|
||||
SayCh <- fmt.Sprintf("%s\n[RSS] Error %s: %s", "*", uri, err)
|
||||
return
|
||||
}
|
||||
<-time.After(time.Duration(feed.SecondsTillUpdate() * 1e9))
|
||||
@@ -61,7 +66,7 @@ func rssPollFeed(uri string, timeout int, cr xmlx.CharsetFunc) {
|
||||
}
|
||||
|
||||
func rssChanHandler(feed *gorss.Feed, newchannels []*gorss.Channel) {
|
||||
sayCh <- fmt.Sprintf("%s\n[RSS] %d new channel(s) in %s", "*", len(newchannels), feed.Url)
|
||||
SayCh <- fmt.Sprintf("%s\n[RSS] %d new channel(s) in %s", "*", len(newchannels), feed.Url)
|
||||
}
|
||||
|
||||
func rssItemHandler(feed *gorss.Feed, ch *gorss.Channel, newitems []*gorss.Item) {
|
||||
@@ -69,7 +74,7 @@ func rssItemHandler(feed *gorss.Feed, ch *gorss.Channel, newitems []*gorss.Item)
|
||||
return
|
||||
}
|
||||
for _, ni := range newitems {
|
||||
sayCh <- fmt.Sprintf("%s\n[RSS] %v - %v", "*", ni.Title, ni.Links[0].Href)
|
||||
SayCh <- fmt.Sprintf("%s\n[RSS] %v - %v", "*", ni.Title, ni.Links[0].Href)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user