Skip to content

Instantly share code, notes, and snippets.

@raed667
Created November 2, 2014 00:51
Show Gist options
  • Save raed667/89e55d59d706f3f0e5b2 to your computer and use it in GitHub Desktop.
Save raed667/89e55d59d706f3f0e5b2 to your computer and use it in GitHub Desktop.
Simple IRC BOT written in Go
package main
import (
"fmt"
"github.com/thoj/go-ircevent"
"strings"
)
var roomName = "#botwartest2"
func main() {
con := irc.IRC("RaedsBot_", "RaedsBot_")
err := con.Connect("irc.freenode.net:6667")
if err != nil {
fmt.Println("Failed connecting")
return
} else {
con.AddCallback("001", func(e *irc.Event) {
con.Join(roomName)
})
con.AddCallback("JOIN", func(e *irc.Event) {
con.Privmsg(roomName, "Hello, I'm a bot and this is my JOIN message.")
})
con.AddCallback("PRIVMSG", func(e *irc.Event) {
if strings.Contains(e.Message(), "RaedsBot_:") {
msg := strings.TrimLeft(e.Message(),"RaedsBot_:")
con.Privmsg(roomName, msg) // AFFICHE DANS la ROOM
}
})
con.Loop()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment