Parcourir la source

text command branched out for stand alone process

master
Patrick Peng Sun il y a 8 ans
Parent
révision
f8438b8a4d
1 fichiers modifiés avec 13 ajouts et 9 suppressions
  1. +13
    -9
      serveCommand.go

+ 13
- 9
serveCommand.go Voir le fichier

@@ -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
}


Chargement…
Annuler
Enregistrer