From 0abb46b881c15ac1da2a7a55e2dc279939825aa5 Mon Sep 17 00:00:00 2001 From: Patrick Peng Sun Date: Sat, 3 Jun 2017 00:43:50 +1000 Subject: [PATCH] added voice command --- procEcho.go | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/procEcho.go b/procEcho.go index fde761d..c1fb8f5 100644 --- a/procEcho.go +++ b/procEcho.go @@ -33,16 +33,27 @@ func echoStart(ss *openIDSessionData, in InWechatMsg) { } func echoServe(ss *openIDSessionData, in InWechatMsg) { + stopEcho := false if in.header.MsgType == "text" { - if in.body.(TextMsg).Content == "结束Echo" { - in.replyText("echo 正式结束") - echoSummary(ss) - echoClean(ss) + if in.body.(TextMsg).Content == "结束Echo" || in.body.(TextMsg).Content == "结束echo" { + stopEcho = true return } } - ss.refreshExpire(600) - echoCommand(ss, in) + if in.header.MsgType == "voice" { + if in.body.(VoiceMsg).Recognition == "退出退出。" { + stopEcho = true + } + } + + if stopEcho { + in.replyText("echo 正式结束") + echoSummary(ss) + echoClean(ss) + } else { + ss.refreshExpire(600) + echoCommand(ss, in) + } }