From 3a8194dffee6148b3f48953d01ef2535ad3b7dcd Mon Sep 17 00:00:00 2001 From: Patrick Peng Sun Date: Thu, 1 Jun 2017 01:40:48 +1000 Subject: [PATCH] echo intro, summary --- procEcho.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/procEcho.go b/procEcho.go index 68dc496..fde761d 100644 --- a/procEcho.go +++ b/procEcho.go @@ -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)