Commits

Anonymous committed 81918e7

First checkin

  • Participants

Comments (0)

Files changed (1)

+package main
+
+import (
+	"fmt"
+	irc "github.com/fluffle/goirc/client"
+	"menteslibres.net/gosexy/redis"
+)
+
+var host string = "irc.freenode.net"
+var channel string = "#go-nuts"
+var r *redis.Client
+
+func main() {
+    r = redis.New()
+	err := r.Connect("127.0.0.1", 6379)
+    if err != nil {
+        return
+    }
+
+	// create new IRC connection
+	c := irc.SimpleClient("jakiro", "jaks")
+	c.EnableStateTracking()
+	c.HandleFunc("connected",
+		func(conn *irc.Conn, line *irc.Line) { 
+            conn.Join(channel)
+            fmt.Println("connected")
+    })
+
+	// Set up a handler to notify of disconnect events.
+	quit := make(chan bool)
+	c.HandleFunc("disconnected",
+		func(conn *irc.Conn, line *irc.Line) { quit <- true })
+
+    c.HandleFunc("privmsg",
+		func(conn *irc.Conn, line *irc.Line) { 
+            data := fmt.Sprintf("<%v>%v",line.Nick,line.Text())
+            r.RPush("chan:zacon",data)
+        })
+
+        reallyquit := false
+	for !reallyquit {
+		// connect to server
+		if err := c.ConnectTo(host); err != nil {
+			fmt.Printf("Connection error: %s\n", err)
+			return
+		}
+
+		// wait on quit channel
+		<-quit
+	}
+}