| //put into user session based pipeline | //put into user session based pipeline | ||||
| AllInMessage <- in | AllInMessage <- in | ||||
| } | } | ||||
| //uncomment the followin two lines to enable echo test | |||||
| // state, _ := echoCommand(in.header.FromUserName, in) | |||||
| // reply = state.response | |||||
| fmt.Fprint(w, reply) | fmt.Fprint(w, reply) | ||||
| } | } | ||||
| // func (session) ProcessInput(w, r) { | |||||
| // //are we in an existing procedure | |||||
| // inProc, state := isInProc(openID) //if inside a procedure, resume last saved state | |||||
| // if inProc { | |||||
| // state = serveProc(state, in) //transit to new state | |||||
| // reply = state.response //xml response | |||||
| // } else { | |||||
| // state, processed := serveCommand(openID, in) //menu or txt command e.g. search | |||||
| // if !processed { // transfer to Customer Service (kf) | |||||
| // reply = buildKfForwardMsg(openID, "") | |||||
| // kfSendTxt(openID, "未识别的命令,已转接校友会理事会,稍后答复您") | |||||
| // } else { | |||||
| // reply = state.response | |||||
| // } | |||||
| // } | |||||
| // log.Println(reply) //instant reply, answering user's request | |||||
| // w.Header().Set("Content-Type", "text/xml; charset=utf-8") | |||||
| // fmt.Fprint(w, reply) | |||||
| // if !isEndingState(state) { | |||||
| // err := saveChatState(openID, state.Procedure, state) | |||||
| // if err != nil { | |||||
| // log.Println("Error Cannot Save chat sate") | |||||
| // log.Println(err) | |||||
| // log.Println(state) | |||||
| // } | |||||
| // } else { //state ending | |||||
| // cleanProcedure(openID, state.Procedure) | |||||
| // } | |||||
| // return | |||||
| // } | |||||
| func readWechatInput(r *http.Request) (result InWechatMsg, valid bool) { | func readWechatInput(r *http.Request) (result InWechatMsg, valid bool) { | ||||
| body, err := ioutil.ReadAll(r.Body) | body, err := ioutil.ReadAll(r.Body) | ||||
| if err != nil { | if err != nil { |