Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

50 linhas
1.0KB

  1. package main
  2. import (
  3. "log"
  4. "net/http"
  5. )
  6. //
  7. //InWechatMsg what we received currently from wechat
  8. type InWechatMsg struct {
  9. header CommonHeader
  10. body interface{} //dynamic type
  11. req *http.Request
  12. instantResponse chan string //instance reply channel
  13. replied bool //whether instant response has been replied
  14. }
  15. func (m *InWechatMsg) init() {
  16. m.replied = false
  17. m.instantResponse = make(chan string)
  18. }
  19. func (m *InWechatMsg) destroy() {
  20. close(m.instantResponse)
  21. }
  22. func (m *InWechatMsg) replyXML(xml string) {
  23. if !m.replied {
  24. m.replied = true
  25. m.instantResponse <- xml
  26. } else {
  27. log.Println("BUG::doubl reply for wechat message")
  28. }
  29. }
  30. func (m *InWechatMsg) replyText(s string) {
  31. str, _ := BuildTextMsg(m.header.FromUserName, s)
  32. m.replyXML(str)
  33. }
  34. func (m *InWechatMsg) transfer2KF() {
  35. str, _ := BuildKFTransferAnyOneMsg(m.header.FromUserName)
  36. m.replyXML(str)
  37. }
  38. func (m *InWechatMsg) transfer2SpecificKF(kf string) {
  39. str := buildKfForwardMsg(m.header.FromUserName, kf)
  40. m.replyXML(str)
  41. }