diff --git a/inMsg.go b/inMsg.go
index df61755..b714c3a 100644
--- a/inMsg.go
+++ b/inMsg.go
@@ -72,14 +72,26 @@ type LinkMsg struct {
//EventMsg all type of event
type EventMsg struct {
- Event string //subscribe, unsubscribe, SCAN, LOCATION, CLICK, VIEW
- EventKey string //for CLICK, VIEW, SCAN, subscribe
- Ticket string //for SCAN, subscribe
- Latitude float64 //for LOCATION
- Longitude float64 //for LOCATION
- Precision float64 //for LOCATION
- KfAccount string //for kf_close_session kf_create_session
- CloseType string // kf_close_session
+ Event string //subscribe, unsubscribe, SCAN, LOCATION, CLICK, VIEW
+ EventKey string //for CLICK, VIEW, SCAN, subscribe
+ Ticket string //for SCAN, subscribe
+ Latitude float64 //for LOCATION
+ Longitude float64 //for LOCATION
+ Precision float64 //for LOCATION
+ KfAccount string //for kf_close_session kf_create_session
+ CloseType string //for kf_close_session
+ ScanCodeInfo struct {
+ ScanType string //for scancode_push scancode_waitmsg
+ ScanResult string
+ }
+ SendPicsInfo struct { //for pic_photo_or_album pic_weixin pic_sysphoto
+ Count int
+ PicList struct {
+ Item []struct {
+ PicMd5Sum string
+ } `xml:"item"`
+ }
+ }
}
//ReadCommonHeader parse xml of common field of wechat post message
diff --git a/sample_data/kf_event.txt b/sample_data/kf_event.txt
index 420026b..13f5b17 100644
--- a/sample_data/kf_event.txt
+++ b/sample_data/kf_event.txt
@@ -14,4 +14,33 @@
-
\ No newline at end of file
+
+
+
+
+
+1495907830
+
+
+
+
+
+
+
+
+
+
+
+1495908270
+
+
+
+4
+-
+
+-
+
+-
+
+-
+
\ No newline at end of file
diff --git a/serveCommand.go b/serveCommand.go
index c7fac03..d92d3b6 100644
--- a/serveCommand.go
+++ b/serveCommand.go
@@ -18,8 +18,11 @@ func echoCommand(openID string, in InWechatMsg) (state chatState, processed bool
switch in.body.(type) {
case TextMsg:
m := in.body.(TextMsg)
- str, err = BuildTextMsg(openID, m.Content)
- processed = false
+ str, err = BuildTextMsg(openID, m.Content+"\n\n 转接 可以测试客服")
+ if m.Content == "转接" {
+ processed = false
+ }
+
case PicMsg:
m := in.body.(PicMsg)
str = buildPicMsg(openID, m.MediaId)
@@ -76,9 +79,26 @@ func echoEvents(openID string, in InWechatMsg) (state chatState, processed bool)
case "CLICK":
str, _ = BuildTextMsg(openID, m.EventKey)
case "subscribe":
+ str, _ = BuildTextMsg(openID, m.EventKey)
case "unsubscribe":
+ str, _ = BuildTextMsg(openID, m.EventKey)
case "SCAN":
+ str, _ = BuildTextMsg(openID, m.EventKey)
case "VIEW":
+ str, _ = BuildTextMsg(openID, m.EventKey)
+ case "kf_create_session":
+ kfSendTxt(openID, m.KfAccount)
+ //str, _ = BuildTextMsg(openID, m.KfAccount) // response msg is ignored by wechat
+ case "kf_close_session":
+ kfSendTxt(openID, m.KfAccount+"\n close type ="+m.CloseType)
+ //str, _ = BuildTextMsg(openID, m.KfAccount+"\n close type ="+m.CloseType) //response msg is ignored by wechat
+ case "scancode_waiting":
+ case "pic_photo_or_album":
+ log.Println(m.SendPicsInfo.Count)
+ for _, v := range m.SendPicsInfo.PicList.Item {
+ log.Println(v.PicMd5Sum)
+ }
+
default:
str, _ = BuildTextMsg(openID, " unknown event :"+m.Event)
}