Beispiel #1
0
//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)
}
Beispiel #2
0
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 ""
}
Beispiel #3
0
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 ""
}