Skip to content

Instantly share code, notes, and snippets.

@rossdylan
Created October 29, 2013 20:42
Show Gist options
  • Select an option

  • Save rossdylan/7222245 to your computer and use it in GitHub Desktop.

Select an option

Save rossdylan/7222245 to your computer and use it in GitHub Desktop.
Annoy your friends!
package main
import "github.com/thoj/go-ircevent"
import "os"
import "os/exec"
import "strings"
import "fmt"
func CowSay(msg string) {
new_msg := strings.Replace(msg, "#", "hashtag ", -1)
cmd_msg := "(SayText \"" + new_msg + "\")"
fi, err := os.Create("/tmp/cowsay")
if err != nil {
panic(err)
}
fi.WriteString(cmd_msg)
fi.Close()
cmd := exec.Command("/usr/bin/festival", "/tmp/cowsay")
fmt.Println("Speaking :" + cmd_msg)
run_err := cmd.Run()
if run_err != nil {
fmt.Println("Shits fucked yo")
}
}
func MSGEvent(event *irc.Event) {
if strings.Contains(event.Message, "#cowsay") {
go CowSay(event.Message)
}
}
func main() {
ircobj := irc.IRC("cowbot", "dicks")
ircobj.Connect("skynet.csh.rit.edu:6667")
ircobj.Join("#usercenter")
ircobj.AddCallback("PRIVMSG", MSGEvent)
ircobj.Loop()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment