Пример #1
0
func UName(cv *xmpp.ChatView) {
	if cv.GetText() == "uname" {
		cmd := exec.Command("uname", "-a")
		output, err := cmd.CombinedOutput()
		if err != nil {
			XMPPSendMessage(cv.GetRemote(), fmt.Sprintf("%s", err))
		} else {
			XMPPSendMessage(cv.GetRemote(), string(output))
		}
	}
}
Пример #2
0
func DoMath(cv *xmpp.ChatView) {
	if strings.HasSuffix(cv.GetText(), "= ?") {
		expr := strings.TrimSpace(cv.GetText()[0 : len(cv.GetText())-3])
		answer, err := math.Parse("STEVE!", expr)
		if err != nil {
			XMPPSendMessage(cv.GetRemote(), "Steve not know!")
			return
		}
		XMPPSendMessage(cv.GetRemote(), fmt.Sprintf("%d", answer))
	}
}
Пример #3
0
func ForwardToIRC(cv *xmpp.ChatView) {
	tokens := strings.SplitN(cv.GetText(), " ", 2)
	if len(tokens) == 2 {
		IRCSendMessage(strings.TrimSpace(tokens[0]), tokens[1])
	}
}
Пример #4
0
func Reply(cv *xmpp.ChatView) {
	if len(cv.GetText()) > 0 {
		XMPPSendMessage(cv.GetRemote(), fmt.Sprintf("ACK: %s", cv.GetText()))
	}
}
Пример #5
0
func Log(cv *xmpp.ChatView) {
	log.Print("Received from", cv.GetRemote(), ":", cv.GetText())
}
Пример #6
0
func Print(cv *xmpp.ChatView) {
	fmt.Println("Received from", cv.GetRemote(), ":", cv.GetText())
}