Created
November 2, 2014 00:51
-
-
Save raed667/89e55d59d706f3f0e5b2 to your computer and use it in GitHub Desktop.
Simple IRC BOT written in Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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