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