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)) } } }
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)) } }
func ForwardToIRC(cv *xmpp.ChatView) { tokens := strings.SplitN(cv.GetText(), " ", 2) if len(tokens) == 2 { IRCSendMessage(strings.TrimSpace(tokens[0]), tokens[1]) } }
func Reply(cv *xmpp.ChatView) { if len(cv.GetText()) > 0 { XMPPSendMessage(cv.GetRemote(), fmt.Sprintf("ACK: %s", cv.GetText())) } }
func Log(cv *xmpp.ChatView) { log.Print("Received from", cv.GetRemote(), ":", cv.GetText()) }
func Print(cv *xmpp.ChatView) { fmt.Println("Received from", cv.GetRemote(), ":", cv.GetText()) }