-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmgollnir.go
56 lines (48 loc) · 926 Bytes
/
mgollnir.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"./core"
"./core/extra"
"./core/irclib"
"./core/irclib/commands"
"./core/irclib/handler"
)
var bot = core.Bot{
Server: core.Server{
Server: "irc.azzurra.org",
Port: 6667,
SSL: false,
Channels: []core.Channel{
core.Channel{Name: "#unity", Key: ""},
},
},
Identity: core.Identity{
Username: "Mgollnir",
Hostname: "*",
Servername: "*",
Realname: "Mgollnir",
},
}
func main() {
bot.Server.Connect()
bot.Server.Send(commands.Nick(bot.Identity))
bot.Server.Send(commands.User(bot.Identity))
// Handle Ctrl+C
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
bot.Server.Send(commands.Quit("Bug!"))
os.Exit(0)
}()
go extra.ConsoleReader(bot.Server)
for {
line := bot.Server.Recv()
fmt.Println(line)
ircmsg := irclib.Parser(line)
handler.Handle(bot, ircmsg)
}
}