You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
610B

  1. package main
  2. import "net/http"
  3. //
  4. //InWechatMsg what we received currently from wechat
  5. type InWechatMsg struct {
  6. header CommonHeader
  7. body interface{} //dynamic type
  8. req *http.Request
  9. instantResponse chan string //instance reply channel
  10. }
  11. func (m *InWechatMsg) init() {
  12. m.instantResponse = make(chan string)
  13. }
  14. func (m *InWechatMsg) destroy() {
  15. close(m.instantResponse)
  16. }
  17. func (m *InWechatMsg) replyXML(xml string) {
  18. m.instantResponse <- xml
  19. }
  20. func (m *InWechatMsg) replyText(s string) {
  21. str, _ := BuildTextMsg(m.header.FromUserName, s)
  22. m.instantResponse <- str
  23. }