contact.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package hook
  2. import (
  3. "fmt"
  4. "strings"
  5. )
  6. // 获取好友和群信息
  7. func (h *Hook) GetFriendAndChatRoomList(typeStr string) (result GetFriendAndChatRoomListReap, err error) {
  8. resp, err := h.Client.R().SetBody(&GetFriendAndChatRoomListReq{
  9. Type: typeStr,
  10. }).SetSuccessResult(&result).Post("http://" + h.ServerIp + ":" + h.WxPort + "/GetFriendAndChatRoomList")
  11. if err != nil {
  12. return
  13. }
  14. if !resp.IsSuccessState() {
  15. err = fmt.Errorf("GetFriendAndChatRoomList failed with status code %d", resp.StatusCode)
  16. return
  17. }
  18. return
  19. }
  20. // 批量获取联系人简明信息(每次100个)
  21. func (h *Hook) BatchGetContactBriefInfo(wxids []string) (result BatchGetContactBriefInfoReap, err error) {
  22. wxidList := strings.Join(wxids, ",")
  23. resp, err := h.Client.R().SetBody(&BatchGetContactBriefInfoReq{
  24. WxidList: wxidList,
  25. }).SetSuccessResult(&result).Post("http://" + h.ServerIp + ":" + h.WxPort + "/BatchGetContactBriefInfo")
  26. if err != nil {
  27. return
  28. }
  29. if !resp.IsSuccessState() {
  30. err = fmt.Errorf("BatchGetChatRoomMemberWxid failed with status code %d", resp.StatusCode)
  31. return
  32. }
  33. return
  34. }