all repos — paprika @ 90f2396d71393631a9f0df11815218cbd49b0071

go rewrite of taigabot

main.go (view raw)

 1package main
 2
 3import (
 4	"log"
 5	"net"
 6
 7	"git.icyphox.sh/taigobot/plugins"
 8	"gopkg.in/irc.v3"
 9)
10
11func ircHandler(c *irc.Client, m *irc.Message) {
12	switch m.Command {
13	case "001":
14		// TODO: load this from config
15		c.Write("JOIN #taigobot-test")
16	case "PRIVMSG":
17		if m.Trailing()[:1] == "." {
18			err := plugins.ProcessCommands(m.Trailing())
19			if err != nil {
20				c.Writef("error: %v", err)
21			}
22		}
23	}
24}
25
26func main() {
27	// TODO: load this from config
28	conn, err := net.Dial("tcp", "irc.rizon.net:6667")
29	if err != nil {
30		log.Fatal(err)
31	}
32
33	config := irc.ClientConfig{
34		Nick:    "taigobot",
35		Pass:    "",
36		User:    "taigobot",
37		Name:    "taigobot",
38		Handler: irc.HandlerFunc(ircHandler),
39	}
40
41	client := irc.NewClient(conn, config)
42	err = client.Run()
43	if err != nil {
44		log.Fatal(err)
45	}
46}