12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package hook
- import (
- "fmt"
- "strings"
- )
- // 获取好友和群信息
- func (h *Hook) GetFriendAndChatRoomList(typeStr string) (result GetFriendAndChatRoomListReap, err error) {
- resp, err := h.Client.R().SetBody(&GetFriendAndChatRoomListReq{
- Type: typeStr,
- }).SetSuccessResult(&result).Post("http://" + h.ServerIp + ":" + h.WxPort + "/GetFriendAndChatRoomList")
- if err != nil {
- return
- }
- if !resp.IsSuccessState() {
- err = fmt.Errorf("GetFriendAndChatRoomList failed with status code %d", resp.StatusCode)
- return
- }
- return
- }
- // 批量获取联系人简明信息(每次100个)
- func (h *Hook) BatchGetContactBriefInfo(wxids []string) (result BatchGetContactBriefInfoReap, err error) {
- wxidList := strings.Join(wxids, ",")
- resp, err := h.Client.R().SetBody(&BatchGetContactBriefInfoReq{
- WxidList: wxidList,
- }).SetSuccessResult(&result).Post("http://" + h.ServerIp + ":" + h.WxPort + "/BatchGetContactBriefInfo")
- if err != nil {
- return
- }
- if !resp.IsSuccessState() {
- err = fmt.Errorf("BatchGetChatRoomMemberWxid failed with status code %d", resp.StatusCode)
- return
- }
- return
- }
- // 添加新的好友
- func (h *Hook) AddNewFriend(v3_wxid string, v4 string, desc string, addType string, role string) (result AddNewFriendReap, err error) {
- resp, err := h.Client.R().SetBody(&AddNewFriendReq{
- V3Wxid: v3_wxid,
- V4: v4,
- Desc: desc,
- AddType: addType,
- Role: role,
- }).SetSuccessResult(&result).Post("http://" + h.ServerIp + ":" + h.WxPort + "/AddNewFriend")
- if err != nil {
- return
- }
- if !resp.IsSuccessState() {
- err = fmt.Errorf("AddNewFriend failed with status code %d", resp.StatusCode)
- return
- }
- return
- }
|