-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.go
36 lines (27 loc) · 837 Bytes
/
bot.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"github.com/jspc-bots/bottom"
"github.com/lrstanley/girc"
)
type Bot struct {
bottom bottom.Bottom
}
func New(user, password, server string, verify bool) (b Bot, err error) {
b.bottom, err = bottom.New(user, password, server, verify)
if err != nil {
return
}
b.bottom.Client.Handlers.Add(girc.CONNECTED, func(c *girc.Client, e girc.Event) {
c.Cmd.Join(Chan)
})
router := bottom.NewRouter()
router.AddRoute(`hello\s+world\!`, b.hello)
b.bottom.Middlewares.Push(router)
return
}
// hello will respond to a sender on the appropriate channel (an irc channel if the
// message was recieved in a channel, and a message if received directly
func (b Bot) hello(sender, channel string, groups []string) error {
b.bottom.Client.Cmd.Messagef(channel, "And hello to you too %s", sender)
return nil
}