| @@ -17,18 +17,23 @@ var commandMap = map[string]commandFunction{ | |||
| func (ss *openIDSessionData) serveCommand(in InWechatMsg) (processed bool) { | |||
| 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 | |||
| 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) { | |||
| processed = true | |||
| msg := "命令如下:\n" | |||
| @@ -38,8 +43,7 @@ func allCommand(ss *openIDSessionData, in InWechatMsg) (processed bool) { | |||
| msg = msg + fmt.Sprintf("%0d : %s \n", count, k) | |||
| } | |||
| str, _ := BuildTextMsg(in.header.FromUserName, msg) | |||
| in.replyXML(str) | |||
| in.replyText(msg) | |||
| return | |||
| } | |||