| func (ss *openIDSessionData) serveCommand(in InWechatMsg) (processed bool) { | func (ss *openIDSessionData) serveCommand(in InWechatMsg) (processed bool) { | ||||
| if in.header.MsgType == "text" { | if in.header.MsgType == "text" { | ||||
| cmd := in.body.(TextMsg).Content | |||||
| if f, hasFunction := commandMap[cmd]; hasFunction { | |||||
| return f(ss, in) | |||||
| } | |||||
| if cmd == "所有命令" || cmd == "all command" { | |||||
| return allCommand(ss, in) | |||||
| } | |||||
| return ss.serveTextCommand(in) | |||||
| } | } | ||||
| processed = false | processed = false | ||||
| return | return | ||||
| } | } | ||||
| func (ss *openIDSessionData) serveTextCommand(in InWechatMsg) (processed bool) { | |||||
| cmd := in.body.(TextMsg).Content | |||||
| if f, hasFunction := commandMap[cmd]; hasFunction { | |||||
| return f(ss, in) | |||||
| } | |||||
| if cmd == "所有命令" || cmd == "all command" { | |||||
| return allCommand(ss, in) | |||||
| } | |||||
| return false | |||||
| } | |||||
| func allCommand(ss *openIDSessionData, in InWechatMsg) (processed bool) { | func allCommand(ss *openIDSessionData, in InWechatMsg) (processed bool) { | ||||
| processed = true | processed = true | ||||
| msg := "命令如下:\n" | msg := "命令如下:\n" | ||||
| msg = msg + fmt.Sprintf("%0d : %s \n", count, k) | msg = msg + fmt.Sprintf("%0d : %s \n", count, k) | ||||
| } | } | ||||
| str, _ := BuildTextMsg(in.header.FromUserName, msg) | |||||
| in.replyXML(str) | |||||
| in.replyText(msg) | |||||
| return | return | ||||
| } | } | ||||