您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

51 行
1.1KB

  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. d := decryptToXML(xml)
  28. log.Println("BUG::double reply for wechat message\n" + d + "\n")
  29. }
  30. }
  31. func (m *InWechatMsg) replyText(s string) {
  32. str, _ := BuildTextMsg(m.header.FromUserName, s)
  33. m.replyXML(str)
  34. }
  35. func (m *InWechatMsg) transfer2KF() {
  36. str, _ := BuildKFTransferAnyOneMsg(m.header.FromUserName)
  37. m.replyXML(str)
  38. }
  39. func (m *InWechatMsg) transfer2SpecificKF(kf string) {
  40. str := buildKfForwardMsg(m.header.FromUserName, kf)
  41. m.replyXML(str)
  42. }