| @@ -4,6 +4,7 @@ import ( | |||
| "fmt" | |||
| "log" | |||
| "os" | |||
| "time" | |||
| ) | |||
| const idProcEcho = "Echo" | |||
| @@ -28,29 +29,31 @@ func echoClean(ss *openIDSessionData) { | |||
| } | |||
| func echoStart(ss *openIDSessionData, in InWechatMsg) { | |||
| ss.setKvPair("started at", time.Now().Format("2006/03:04:05")) | |||
| } | |||
| func echoServe(ss *openIDSessionData, in InWechatMsg) { | |||
| if in.header.MsgType == "text" { | |||
| if in.body.(TextMsg).Content == "结束Echo" { | |||
| in.replyText("echo 正式结束") | |||
| echoSummary(ss) | |||
| echoClean(ss) | |||
| return | |||
| } | |||
| } | |||
| ss.refreshExpire(600) | |||
| echoCommand(ss, in) | |||
| kfSendTxt(ss.OpenID, "10 分钟之后 Echo将自动结束,\n输入 [结束Echo] 清除Echo模式") | |||
| } | |||
| func echoSummary(ss *openIDSessionData) { | |||
| msg := ss.getVal("started at") | |||
| msg = msg + "\n" + ss.getVal("msg") | |||
| kfSendTxt(ss.OpenID, msg) | |||
| } | |||
| func echoInto(ss *openIDSessionData) { | |||
| kfSendTxt(ss.OpenID, "10 分钟没有输入之后 Echo将自动结束,\n输入 [结束Echo] 清除Echo模式") | |||
| } | |||
| func echoCommand(ss *openIDSessionData, in InWechatMsg) { | |||
| @@ -61,6 +64,9 @@ func echoCommand(ss *openIDSessionData, in InWechatMsg) { | |||
| case TextMsg: | |||
| m := in.body.(TextMsg) | |||
| str, err = BuildTextMsg(openID, m.Content+"\n\n关键词 [转接] 将后续信息都转接到 客服 测试版") | |||
| msg := ss.getVal("msg") | |||
| msg = msg + m.Content | |||
| ss.setKvPair("msg", msg) | |||
| in.replyXML(str) | |||
| case PicMsg: | |||
| m := in.body.(PicMsg) | |||