about summary refs log tree commit diff stats
path: root/main.go
diff options
context:
space:
mode:
authorBenny Morrison <benmorrison@ttm.sh>2019-03-14 03:13:02 -0400
committerBenny Morrison <benmorrison@ttm.sh>2019-03-14 03:13:02 -0400
commit4810fbc0d1f4d7788c344879afeb18c71692165d (patch)
treebc6920180c5cf54f5411e8d4e9a21a497cc9ba65 /main.go
parent1b43490caa831eb56f5f5d337b17c6b0865b4e07 (diff)
downloadgoofbot-4810fbc0d1f4d7788c344879afeb18c71692165d.tar.gz
beginning bot skeleton
Diffstat (limited to 'main.go')
-rw-r--r--main.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..006d3d0
--- /dev/null
+++ b/main.go
@@ -0,0 +1,47 @@
+package main
+
+import (
+	"log"
+	"net"
+
+	"gopkg.in/irc.v3"
+)
+
+func main() {
+
+	// set all the necessities
+	// also specifies the initial channel
+	// to join
+	config := irc.ClientConfig{
+		Nick: "goofbot",
+		Pass: "password",
+		User: "goofbot",
+		Name: "Goofus McBot",
+		Handler: irc.HandlerFunc(func(c *irc.Client, m *irc.Message) {
+			if m.Command == "001" {
+				// 001 = welcome
+				c.Write("JOIN #institute")
+			} else if m.Command == "PRIVMSG" && c.FromChannel(m) {
+				c.WriteMessage(&irc.Message{
+					Command: "PRIVMSG",
+					Params: []string{
+						m.Params[0],
+						m.Trailing(),
+					},
+				})
+			}
+		}),
+	}
+
+	conn, err := net.Dial("tcp", "irc.tilde.chat:6697")
+	if err != nil {
+		log.Fatalln(err)
+	}
+
+	// create the connection
+	client := irc.NewClient(conn, config)
+	err = client.Run()
+	if err != nil {
+		log.Fatalln(err)
+	}
+}