Ver código fonte

text command branched out for stand alone process

master
Patrick Peng Sun 8 anos atrás
pai
commit
f8438b8a4d
1 arquivos alterados com 13 adições e 9 exclusões
  1. +13
    -9
      serveCommand.go

+ 13
- 9
serveCommand.go Ver arquivo

@@ -17,18 +17,23 @@ var commandMap = map[string]commandFunction{

func (ss *openIDSessionData) serveCommand(in InWechatMsg) (processed bool) {
if in.header.MsgType == "text" {
cmd := in.body.(TextMsg).Content
if f, hasFunction := commandMap[cmd]; hasFunction {
return f(ss, in)
}
if cmd == "所有命令" || cmd == "all command" {
return allCommand(ss, in)
}
return ss.serveTextCommand(in)
}
processed = false
return
}

func (ss *openIDSessionData) serveTextCommand(in InWechatMsg) (processed bool) {
cmd := in.body.(TextMsg).Content
if f, hasFunction := commandMap[cmd]; hasFunction {
return f(ss, in)
}
if cmd == "所有命令" || cmd == "all command" {
return allCommand(ss, in)
}
return false
}

func allCommand(ss *openIDSessionData, in InWechatMsg) (processed bool) {
processed = true
msg := "命令如下:\n"
@@ -38,8 +43,7 @@ func allCommand(ss *openIDSessionData, in InWechatMsg) (processed bool) {
msg = msg + fmt.Sprintf("%0d : %s \n", count, k)
}

str, _ := BuildTextMsg(in.header.FromUserName, msg)
in.replyXML(str)
in.replyText(msg)
return
}


Carregando…
Cancelar
Salvar