This is an IRC bot that converts rss feeds into irc channel messages.
It also ops users that match a certain ident if the bot has op.
Go-ircevent is callback based. The package controls the worker thread, and it handles delegation of events. This is not very idiomatic, particularly because an IRC socket behaves like a pair of channels, one for receiving, and one for sending.
That is how this library works. A main loop will look something like this:
import ("github.com/liamzdenek/go-irc/irc");
import ("github.com/liamzdenek/go-irc/irc/irce"); // extras
func main() {
name := "testbot9000";
channel := "#testbot9000";
i := irc.NewIRC("irc.stormbit.net:6667");
for e := range i.Rx {
irce.LogHandler(e); // log.Printf() this event
// handle IRC pings
if i.PingHandler(e) {
continue;
}
switch l := e.(type) {
case *irc.EConnect:
i.Tx <- &irc.Line{
Command: "NICK",
Arguments: []string{name},
};
i.Tx <- &irc.Line{
Command: "USER",
Arguments: []string{name, "8", "*"},
Suffix: "The cake is a lie",
};
case *irc.Line:
switch l.Command {
case "001":
i.Tx <-&irc.Line{
Command: "JOIN",
Arguments: []string{channel},
};
}
}
}
}