From 7151497344c6dd8e9264b0e1124b0e59828837ac Mon Sep 17 00:00:00 2001 From: Sean Hinchee Date: Fri, 26 Jan 2018 21:42:24 +0000 Subject: [PATCH] tweaks and boiler for commit tracking of 9front --- README.md | 3 +-- main.go | 5 +++++ x/mux/commits.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ x/mux/fortunes.go | 1 - 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 x/mux/commits.go diff --git a/README.md b/README.md index 270af12281791457cf39e52291f45d7ba1eb9dca..f395167f6d9951066a87193c03fa3494509a875b 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,9 @@ library. ### Installing -Use go get to download the repository into your Go work environment. - ``` go get github.com/bwmarrin/discordgo +go get github.com/SlyMarbo/rss ``` ### Usage diff --git a/main.go b/main.go index 4d190fa965dedc6e3ab9fa696a51f6dd92bc5ab9..00ac326cfa3d087ebade2b9c87271614247ae51b 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "os/signal" "syscall" "github.com/bwmarrin/discordgo" + "bitbucket.org/henesy/glenda/x/mux" ) const Version = "v0.1.0-alpha" @@ -74,6 +75,10 @@ func main() { os.Exit(1) } + go mux.Listener() + + Session.UpdateStatus(0, "with #cat-v") + // Wait for a CTRL-C log.Printf(`Now running. Press CTRL-C to exit.`) sc := make(chan os.Signal, 1) diff --git a/x/mux/commits.go b/x/mux/commits.go new file mode 100644 index 0000000000000000000000000000000000000000..85ef9b68424c64a41153eed518e61444836d8188 --- /dev/null +++ b/x/mux/commits.go @@ -0,0 +1,45 @@ +package mux + +import ( + "github.com/bwmarrin/discordgo" + "github.com/SlyMarbo/rss" + "fmt" + "time" +) + +/* internal functions */ + +// Listen on the rss feed +func Listener() { + feed, err := rss.Fetch("http://code.9front.org/hg/plan9front/rss-log") + if err != nil { + fmt.Println("Error in reading RSS feed, see: x/mux/commits.go") + fmt.Printf("%s\n\n", err) + } + + time.Sleep(1000 * time.Second) + + err = feed.Update() + if err != nil { + fmt.Println("Error in updating RSS feed, see: x/mux/commits.go") + fmt.Printf("%s\n\n", err) + } +} + +// Load JSON Configuration File (move me?) + + +/* Commands for Mux */ + +// Print last commit or +func (m *Mux) Commits(ds *discordgo.Session, dm *discordgo.Message, ctx *Context) { + resp := "```\n" + + + + resp += "```\n" + + ds.ChannelMessageSend(dm.ChannelID, resp) + + return +} diff --git a/x/mux/fortunes.go b/x/mux/fortunes.go index ecb27b17fce564d58d1a64c8cfce4a7093d25f9c..039a7b1e6d55a8e7847b2b9c5690130e97c4d419 100644 --- a/x/mux/fortunes.go +++ b/x/mux/fortunes.go @@ -45,4 +45,3 @@ func (m *Mux) Fortunes(ds *discordgo.Session, dm *discordgo.Message, ctx *Contex return } -