/
irc_bot.go
36 lines (32 loc) · 1.06 KB
/
irc_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
// IRC - Internet Relay Chat package provides a convenient method of writing IRC clients and chat bots (RFC 2812).
package main
import (
"./irc";
"log"; // TODO: implement actual Loggers
"time";
)
func main() {
// Dial freenode
log.Stdout("Dialing server");
server, err := irc.IRCDial("tcp", "", "irc.freenode.net:6667"); // TODO: make this not hardcoded
if err != nil {
log.Exit("Dialing error:", err)
}
// Login to the server
log.Stdout("Logging in to server");
server.Login("goo_bot", irc.FlagInvisible);
// Send a PM to NickServ to identify
log.Stdout("Identifying to Nickserv");
server.PrivMsg("NickServ", "identify go_bot turing");
// Join a chat
log.Stdout("Joining #bottest");
bottest, _ := server.Join("#bottest"); // TODO: log the errors
// Send the chat a message
log.Stdout("Greeting #bottest");
bottest.Write("hi guys!");
// We're done with the connection, close it
log.Stdout("Sleeping before closing");
time.Sleep(1e10);
log.Stdout("Closing");
server.Close();
}