From 8d60bd9f16cdcdb8b2a31a299ce818a8b9683caa Mon Sep 17 00:00:00 2001 From: Sean Hinchee Date: Thu, 1 Feb 2018 01:45:40 +0000 Subject: [PATCH] tweaks working on subscribe --- TODO | 1 + main.go | 2 +- x/mux/commits.go | 14 +++++++++----- x/mux/config.go | 1 + 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index e089494c37ecda932beb0b0e862cca07ed2ac1ef..51d9aa645385758843dba26f5d4745479964933c 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,5 @@ Features +** Rework feed handling (don't cache feed in cfg? might be static not able to expand) * g!sum acid(1) * Support for acid(1) in g!man * Search man blocks other than 9front's diff --git a/main.go b/main.go index 66a1e438d9327ca11fc5393f1c09a43c45dc53fd..16019a5177ec1f46b303cd4cca6e8ce86d5af4fb 100644 --- a/main.go +++ b/main.go @@ -78,7 +78,7 @@ func main() { // Init Mux daemons // Problem child Listener is - go mux.Listener() +// go mux.Listener() // go mux.CommMux() // go CommMux() diff --git a/x/mux/commits.go b/x/mux/commits.go index 1d328c66d486ec874c479e366c759bc8fb2ece04..eadc28db9a839149adecc6de711bbd5e0865cded 100644 --- a/x/mux/commits.go +++ b/x/mux/commits.go @@ -14,9 +14,9 @@ import ( // Listen on the rss feed func Listener() { for { - for p, feed := range Config.Feeds { - fmt.Print("Updating feed: ", feed.Title, "\n") - err := feed.Update() + for p, _ := range Config.Feeds { + fmt.Print("Updating feed: ", Config.Feeds[p].Title, "\n") + err := Config.Feeds[p].Update() if err != nil { fmt.Println("Error in updating RSS feed, see: x/mux/commits.go") @@ -24,9 +24,9 @@ func Listener() { } else { Notify(p) } - time.Sleep(10 * time.Minute) + time.Sleep(1 * time.Minute) } - time.Sleep(10 * time.Minute) + time.Sleep(1 * time.Minute) } } @@ -43,6 +43,7 @@ func Notify(id int) { resp += "\n" // Loop through subbed chans and post notification message + fmt.Println("Looping through subs to notify...") for _, v := range Config.Subs { if v.SubID == id { Session.ChannelMessageSend(v.ChanID, resp) @@ -50,6 +51,9 @@ func Notify(id int) { time.Sleep(10 * time.Millisecond) } } + fmt.Println("No new notifys for ", Config.Feeds[id].UpdateURL) + fmt.Println(Config.Feeds[id].Items[0]) + fmt.Println(Config.Feeds[id].Items[len(Config.Feeds[id].Items)-1]) } diff --git a/x/mux/config.go b/x/mux/config.go index fbd34a0475dd3c71f60e22901b05693e853c0961..2665161e8d6f47b825bb447e974664dcc99dcc1f 100644 --- a/x/mux/config.go +++ b/x/mux/config.go @@ -27,6 +27,7 @@ type Configuration struct { func (c *Configuration) Init(s *discordgo.Session) { c.Read() Session = s + go Listener() } // Writes current config