From 784736660623a96fb901ff2a6bc1240283727d52 Mon Sep 17 00:00:00 2001 From: Patrick Peng Sun Date: Mon, 10 Jul 2017 17:19:35 +1000 Subject: [PATCH] polished echo recording event and other type of message as well. --- procEcho.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/procEcho.go b/procEcho.go index 82e6aac..09a995f 100644 --- a/procEcho.go +++ b/procEcho.go @@ -85,6 +85,7 @@ func echoCommand(ss *openIDSessionData, in InWechatMsg) { m := in.body.(PicMsg) str = buildPicMsg(openID, m.MediaId) in.replyXML(str) + procEchoRecordMsg(ss, "图片:..") case VoiceMsg: m := in.body.(VoiceMsg) str = buildVoiceMsg(openID, m.MediaId) @@ -95,10 +96,12 @@ func echoCommand(ss *openIDSessionData, in InWechatMsg) { m := in.body.(VideoMsg) str = buildVideoMsg(openID, "e2iNEiSxCX5TV1WbFd0TQMn5lilY3bylh1--lDBwi7I", "航拍春日哈工大", m.MediaId) in.replyXML(str) + procEchoRecordMsg(ss, "视频:..") case ShortVideoMsg: m := in.body.(ShortVideoMsg) str = buildVideoMsg(openID, "e2iNEiSxCX5TV1WbFd0TQMn5lilY3bylh1--lDBwi7I", "航拍春日哈工大", m.MediaId) in.replyXML(str) + procEchoRecordMsg(ss, "小视频:..") case LocationMsg: m := in.body.(LocationMsg) mid := location2MediaID(m.Location_X, m.Location_Y) @@ -106,13 +109,15 @@ func echoCommand(ss *openIDSessionData, in InWechatMsg) { in.replyXML(str) url := location2URL(m.Location_X, m.Location_Y) kfSendTxt(openID, url+"\n"+fmt.Sprintf("long=%f, lat=%f, scale=%d", m.Location_X, m.Location_Y, m.Scale)) + procEchoRecordMsg(ss, "坐标:..") case LinkMsg: m := in.body.(LinkMsg) str, _ = BuildTextMsg(openID, m.Url) in.replyXML(str) kfSendTxt(openID, m.Title+m.Description) + procEchoRecordMsg(ss, "链接:"+m.Title) case EventMsg: - echoEvents(in) + echoEvents(ss, in) default: str, err = BuildTextMsg(openID, "text message") } @@ -123,11 +128,12 @@ func echoCommand(ss *openIDSessionData, in InWechatMsg) { return } -func echoEvents(in InWechatMsg) { +func echoEvents(ss *openIDSessionData, in InWechatMsg) { openID := in.header.FromUserName str := "" m := in.body.(EventMsg) - log.Println("Event = " + m.Event) + //log.Println("Event = " + m.Event) + procEchoRecordMsg(ss, "事件:"+m.Event) switch m.Event { case "LOCATION": mid := location2MediaID(m.Latitude, m.Longitude)