Przeglądaj źródła

text command branched out for stand alone process

master
Patrick Peng Sun 8 lat temu
rodzic
commit
f8438b8a4d
1 zmienionych plików z 13 dodań i 9 usunięć
  1. +13
    -9
      serveCommand.go

+ 13
- 9
serveCommand.go Wyświetl plik



func (ss *openIDSessionData) serveCommand(in InWechatMsg) (processed bool) { func (ss *openIDSessionData) serveCommand(in InWechatMsg) (processed bool) {
if in.header.MsgType == "text" { 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 processed = false
return 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) { func allCommand(ss *openIDSessionData, in InWechatMsg) (processed bool) {
processed = true processed = true
msg := "命令如下:\n" msg := "命令如下:\n"
msg = msg + fmt.Sprintf("%0d : %s \n", count, k) msg = msg + fmt.Sprintf("%0d : %s \n", count, k)
} }


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



Ładowanie…
Anuluj
Zapisz