예제 #1
0
파일: example.go 프로젝트: ckolbeck/ircbot
//Whether the bot is addressed with its attention char, in a private message, or with example-bot:
//cmd will hold the meaningful part of the message
//msg holds the raw irc message broken into prefix, command, args, trailing, and possibly a CTCP command
//For PRIVMSGs, trailing holds the text of the message
func sayHi(cmd string, msg *irc.Message) string {
	//CTCP Version needs to be handled here, since it will generally be sent in a pm
	if msg.Ctcp == "VERSION" {
		return "GoIRC example bot"
	}

	return fmt.Sprintf("Hi there, %s. You said: %s", msg.GetSender(), msg.Trailing)
}
예제 #2
0
파일: io.go 프로젝트: ckolbeck/mc-bot
func echoIRCToServer(_ string, m *irc.Message) string {
	sanitized := sanitizeRegex.ReplaceAllString(m.Trailing, " ")

	if m.Ctcp == "" { //Line was normal chat
		server.In <- fmt.Sprintf("say <%s> %s", m.GetSender(), sanitized)
	} else if m.Ctcp == "ACTION" { //Line was a Ctcp req
		server.In <- fmt.Sprintf("say * %s %s", m.GetSender(), sanitized)
	} //Else ignore

	return ""
}
예제 #3
0
파일: commands.go 프로젝트: ckolbeck/mc-bot
func directedIRC(cmd string, m *irc.Message) string {

	if m.Args[0] == config.Nick {
		commands <- &command{cmd, m.GetSender(), m.GetSender(), SOURCE_IRC}
	} else {
		commands <- &command{cmd, m.GetSender(), m.Args[0], SOURCE_IRC}
	}

	return ""
}