433 lines
14 KiB
Go
433 lines
14 KiB
Go
package core
|
||
|
||
import (
|
||
"github.com/goWxHook/goWxHook/utils/json"
|
||
)
|
||
|
||
type GetFriendListResponse struct {
|
||
Data []GetFriendListResponseDateItem `json:"data"`
|
||
Type int `json:"type"`
|
||
}
|
||
type GetFriendListResponseDateItem struct {
|
||
Account string `json:"account"` // 微信账号,友情的直接连线
|
||
Avatar string `json:"avatar"` // 头像的风景画,好友的形象代言
|
||
City string `json:"city"` // 都市的温馨角落,好友的日常坐标
|
||
Country string `json:"country"` // 国界的另一端,好友的远方故事
|
||
LabelidList string `json:"labelid_list"` // 标签的彩虹桥,连接不同朋友圈的密码
|
||
Nickname string `json:"nickname"` // 昵称的诗篇,好友的个性签名
|
||
Province string `json:"province"` // 省份的风土人情,好友的地域色彩
|
||
Remark string `json:"remark"` // 备注的小秘密,只有你知道的代号
|
||
Sex int `json:"sex"` // 性别的罗盘,1为蓝海,2为红颜
|
||
Wxid string `json:"wxid"` // 微信ID,好友的唯一坐标
|
||
}
|
||
|
||
// GetFriendList 获取好友列表
|
||
func (w *WxApi) GetFriendList() ([]GetFriendListResponseDateItem, error) {
|
||
resp, err := w.internalCall(MtDataFriendsMsg, 10, MtDataFriendsMsg, map[string]interface{}{}, nil)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
var rdata GetFriendListResponse
|
||
err = json.Unmarshal([]byte(resp), &rdata)
|
||
if err != nil {
|
||
return nil, WxError{-1, err.Error()}
|
||
}
|
||
return rdata.Data, nil
|
||
}
|
||
|
||
type GetFriendInfoResponse struct {
|
||
Data GetFriendListResponseDateItem `json:"data"`
|
||
Type int `json:"type"`
|
||
}
|
||
|
||
// GetFriendInfo 获取单个好友信息
|
||
func (w *WxApi) GetFriendInfo(wxid string) (*GetFriendListResponseDateItem, error) {
|
||
resp, err := w.internalCall(MtDataWxidMsg, 10, MtDataWxidMsg, map[string]interface{}{"wxid": wxid}, nil)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
var rdata GetFriendInfoResponse
|
||
err = json.Unmarshal([]byte(resp), &rdata)
|
||
if err != nil {
|
||
return nil, WxError{-1, err.Error()}
|
||
}
|
||
return &rdata.Data, nil
|
||
}
|
||
|
||
type GetFriendBriefInfoByProtocolResponseData struct {
|
||
Account string `json:"account"`
|
||
Avatar string `json:"avatar"`
|
||
City string `json:"city"`
|
||
Country string `json:"country"`
|
||
Nickname string `json:"nickname"`
|
||
Province string `json:"province"`
|
||
Remark string `json:"remark"`
|
||
Sex int `json:"sex"`
|
||
Signature string `json:"signature"`
|
||
SmallAvatar string `json:"small_avatar"`
|
||
SnsPic string `json:"sns_pic"`
|
||
SourceType int `json:"source_type"`
|
||
Status int `json:"status"`
|
||
V1 string `json:"v1"`
|
||
V2 string `json:"v2"`
|
||
Wxid string `json:"wxid"`
|
||
}
|
||
type GetFriendBriefInfoByProtocolResponse struct {
|
||
Data GetFriendBriefInfoByProtocolResponseData `json:"data"`
|
||
Type int `json:"type"`
|
||
}
|
||
|
||
// GetFriendBriefInfoByProtocol 获取好友简要信息(协议)
|
||
func (w *WxApi) GetFriendBriefInfoByProtocol(wxid string) (*GetFriendBriefInfoByProtocolResponseData, error) {
|
||
resp, err := w.internalCall(MtUpdateWxidMsg, 20, MtUpdateWxidMsg, map[string]interface{}{"wxid": wxid}, nil)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
var rdata GetFriendBriefInfoByProtocolResponse
|
||
err = json.Unmarshal([]byte(resp), &rdata)
|
||
if err != nil {
|
||
return nil, WxError{-1, err.Error()}
|
||
}
|
||
return &rdata.Data, nil
|
||
}
|
||
|
||
type GetFriendDetailInfoByProtocolResponseData struct {
|
||
BaseResponse struct {
|
||
ErrMsg struct {
|
||
} `json:"errMsg"`
|
||
Ret int `json:"ret"`
|
||
} `json:"baseResponse"`
|
||
ContactCount int `json:"contactCount"`
|
||
ContactList []GetFriendDetailInfoByProtocolResponseDataContactListItem `json:"contactList"`
|
||
RetList []struct {
|
||
RetList int `json:"retList"`
|
||
} `json:"retList"`
|
||
VerifyUserValidTicketList []interface{} `json:"verifyUserValidTicketList"`
|
||
}
|
||
|
||
type GetFriendDetailInfoByProtocolResponseDataContactListItem struct {
|
||
AddContactScene int `json:"addContactScene"`
|
||
AdditionalContactList struct {
|
||
LinkedinContactItem struct {
|
||
} `json:"linkedinContactItem"`
|
||
} `json:"additionalContactList"`
|
||
AlbumBgImgId string `json:"albumBgImgId"`
|
||
AlbumFlag int `json:"albumFlag"`
|
||
AlbumStyle int `json:"albumStyle"`
|
||
Alias string `json:"alias"`
|
||
BigHeadImgUrl string `json:"bigHeadImgUrl"`
|
||
BitMask int64 `json:"bitMask"`
|
||
BitVal int `json:"bitVal"`
|
||
CardImgUrl string `json:"cardImgUrl"`
|
||
ChatRoomData string `json:"chatRoomData"`
|
||
ChatRoomNotify int `json:"chatRoomNotify"`
|
||
ChatRoomOwner string `json:"chatRoomOwner"`
|
||
ChatroomInfoVersion int `json:"chatroomInfoVersion"`
|
||
ChatroomMaxCount int `json:"chatroomMaxCount"`
|
||
ChatroomType int `json:"chatroomType"`
|
||
ChatroomVersion int `json:"chatroomVersion"`
|
||
City string `json:"city"`
|
||
ContactType int `json:"contactType"`
|
||
Country string `json:"country"`
|
||
CustomizedInfo struct {
|
||
BrandFlag int `json:"brandFlag"`
|
||
BrandIconURL string `json:"brandIconURL"`
|
||
BrandInfo string `json:"brandInfo"`
|
||
ExternalInfo string `json:"externalInfo"`
|
||
} `json:"customizedInfo"`
|
||
DeleteFlag int `json:"deleteFlag"`
|
||
Description string `json:"description"`
|
||
DomainList struct {
|
||
} `json:"domainList"`
|
||
EncryptUserName string `json:"encryptUserName"`
|
||
ExtInfo string `json:"extInfo"`
|
||
HasWeiXinHdHeadImg int `json:"hasWeiXinHdHeadImg"`
|
||
HeadImgMd5 string `json:"headImgMd5"`
|
||
IdcardNum string `json:"idcardNum"`
|
||
ImgBuf struct {
|
||
Buffer string `json:"buffer"`
|
||
ILen int `json:"iLen"`
|
||
} `json:"imgBuf"`
|
||
ImgFlag int `json:"imgFlag"`
|
||
LabelIdList string `json:"labelIdList"`
|
||
Level int `json:"level"`
|
||
MobileFullHash string `json:"mobileFullHash"`
|
||
MobileHash string `json:"mobileHash"`
|
||
MyBrandList string `json:"myBrandList"`
|
||
NewChatroomData struct {
|
||
ChatRoomMemberList []interface{} `json:"chatRoomMemberList"`
|
||
InfoMask int `json:"infoMask"`
|
||
MemberCount int `json:"memberCount"`
|
||
} `json:"newChatroomData"`
|
||
NickName struct {
|
||
String string `json:"string"`
|
||
} `json:"nickName"`
|
||
PersonalCard int `json:"personalCard"`
|
||
PhoneNumListInfo struct {
|
||
Count int `json:"count"`
|
||
PhoneNumList []interface{} `json:"phoneNumList"`
|
||
} `json:"phoneNumListInfo"`
|
||
Province string `json:"province"`
|
||
PyInitial struct {
|
||
String string `json:"string"`
|
||
} `json:"pyInitial"`
|
||
QuanPin struct {
|
||
String string `json:"string"`
|
||
} `json:"quanPin"`
|
||
RealName string `json:"realName"`
|
||
Remark struct {
|
||
} `json:"remark"`
|
||
RemarkPYInitial struct {
|
||
} `json:"remarkPYInitial"`
|
||
RemarkQuanPin struct {
|
||
} `json:"remarkQuanPin"`
|
||
RoomInfoCount int `json:"roomInfoCount"`
|
||
RoomInfoList []interface{} `json:"roomInfoList"`
|
||
Sex int `json:"sex"`
|
||
Signature string `json:"signature"`
|
||
SmallHeadImgUrl string `json:"smallHeadImgUrl"`
|
||
SnsUserInfo struct {
|
||
SnsBgImgId string `json:"snsBgImgId"`
|
||
SnsBgObjectId string `json:"snsBgObjectId"`
|
||
SnsFlag int `json:"snsFlag"`
|
||
SnsFlagEx int `json:"snsFlagEx"`
|
||
} `json:"snsUserInfo"`
|
||
Source int `json:"source"`
|
||
UserName struct {
|
||
String string `json:"string"`
|
||
} `json:"userName"`
|
||
VerifyContent string `json:"verifyContent"`
|
||
VerifyFlag int `json:"verifyFlag"`
|
||
VerifyInfo string `json:"verifyInfo"`
|
||
WeiDianInfo string `json:"weiDianInfo"`
|
||
Weibo string `json:"weibo"`
|
||
WeiboFlag int `json:"weiboFlag"`
|
||
WeiboNickname string `json:"weiboNickname"`
|
||
}
|
||
|
||
type GetFriendDetailInfoByProtocolResponse struct {
|
||
Data GetFriendDetailInfoByProtocolResponseData `json:"data"`
|
||
Type int `json:"type"`
|
||
}
|
||
|
||
// GetFriendDetailInfoByProtocol 获取好友详细信息(协议)
|
||
func (w *WxApi) GetFriendDetailInfoByProtocol(wxid string) ([]GetFriendDetailInfoByProtocolResponseDataContactListItem, error) {
|
||
resp, err := w.internalCall(MtGetFriendDetailMsg, 20, MtGetFriendDetailMsg, map[string]interface{}{"wxid": wxid}, nil)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
var rdata GetFriendDetailInfoByProtocolResponse
|
||
err = json.Unmarshal([]byte(resp), &rdata)
|
||
if err != nil {
|
||
return nil, WxError{-1, err.Error()}
|
||
}
|
||
|
||
return rdata.Data.ContactList, nil
|
||
}
|
||
|
||
// GetFriendDetailInfoListByProtocol 批量获取好友详细信息(协议)
|
||
func (w *WxApi) GetFriendDetailInfoListByProtocol(wxids []string) ([]GetFriendDetailInfoByProtocolResponseDataContactListItem, error) {
|
||
resp, err := w.internalCall(MtGetFriendDetailMsg, 20, MtGetFriendDetailMsg, map[string]interface{}{"username_list": wxids}, nil)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
var rdata GetFriendDetailInfoByProtocolResponse
|
||
err = json.Unmarshal([]byte(resp), &rdata)
|
||
if err != nil {
|
||
return nil, WxError{-1, err.Error()}
|
||
}
|
||
return rdata.Data.ContactList, nil
|
||
}
|
||
|
||
type EditFriendRemarkRequest struct {
|
||
Wxid string `json:"wxid"`
|
||
Remark string `json:"remark"`
|
||
}
|
||
|
||
// EditFriendRemark 编辑好友备注
|
||
func (w *WxApi) EditFriendRemark(request EditFriendRemarkRequest) (err error) {
|
||
_, err = w.internalCall(0, -1, MtModFriendRemarkMsg, request, nil)
|
||
return err
|
||
}
|
||
|
||
type AddFriendRequest struct {
|
||
Wxid string `json:"wxid"`
|
||
Remark string `json:"remark"`
|
||
RoomWxid string `json:"room_wxid"`
|
||
SourceType int `json:"source_type"`
|
||
}
|
||
|
||
// AddFriend 发送好友申请
|
||
// 参数:
|
||
// clientId: 客户端ID,用于标识发起请求的客户端
|
||
// wxid: 待添加好友的微信ID
|
||
// remark: 对好友的备注信息
|
||
// roomWxid: 若是在某个群聊中发起的好友申请,此参数为群聊的微信ID
|
||
// sourceType: 好友申请的来源类型,群聊14
|
||
func (w *WxApi) AddFriend(request AddFriendRequest) (err error) {
|
||
_, err = w.internalCall(0, -1, MtAddFriendMsg, request, nil)
|
||
return err
|
||
}
|
||
|
||
type AcceptFriendRequest struct {
|
||
Encryptusername string `json:"encryptusername"`
|
||
Ticket string `json:"ticket"`
|
||
Scene int `json:"scene"`
|
||
}
|
||
type AcceptFriendResponse struct {
|
||
Data WxCommonData `json:"data"`
|
||
Type int `json:"type"`
|
||
}
|
||
|
||
// AcceptFriend 同意加好友申请
|
||
func (w *WxApi) AcceptFriend(request AcceptFriendRequest) *WxCommonData {
|
||
resp, err := w.internalCall(MtAcceptFriendMsg, 30, MtAcceptFriendMsg, request, nil)
|
||
if err != nil {
|
||
return &WxCommonData{Errcode: -1, Errmsg: err.Error()}
|
||
}
|
||
var rdata AcceptFriendResponse
|
||
err = json.Unmarshal([]byte(resp), rdata)
|
||
if err != nil {
|
||
return &WxCommonData{Errcode: -1, Errmsg: err.Error()}
|
||
}
|
||
return &rdata.Data
|
||
}
|
||
|
||
// DelFriend 删除好友
|
||
func (w *WxApi) DelFriend(wxid string) (err error) {
|
||
_, err = w.internalCall(0, -1, MtDelFriendMsg, map[string]interface{}{
|
||
"wxid": wxid,
|
||
}, nil)
|
||
return err
|
||
}
|
||
|
||
type SearchWxUserResponseData struct {
|
||
Account string `json:"account"`
|
||
Avatar string `json:"avatar"`
|
||
City string `json:"city"`
|
||
Country string `json:"country"`
|
||
Keyword string `json:"keyword"`
|
||
Nickname string `json:"nickname"`
|
||
Provice string `json:"provice"`
|
||
Search string `json:"search"`
|
||
Sex int `json:"sex"`
|
||
Signature string `json:"signature"`
|
||
SmallAvatar string `json:"small_avatar"`
|
||
Status int `json:"status"`
|
||
V1 string `json:"v1"`
|
||
V2 string `json:"v2"`
|
||
Wxid string `json:"wxid"`
|
||
}
|
||
|
||
type SearchWxUserResponse struct {
|
||
Data SearchWxUserResponseData `json:"data"`
|
||
Type int `json:"type"`
|
||
}
|
||
|
||
// SearchWxUser 搜索微信用户
|
||
func (w *WxApi) SearchWxUser(keyword string) (*SearchWxUserResponseData, error) {
|
||
resp, err := w.internalCall(MtSearchWxUserMsg, 20, MtSearchWxUserMsg, map[string]interface{}{"search": keyword}, nil)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
var rdata SearchWxUserResponse
|
||
err = json.Unmarshal([]byte(resp), &rdata)
|
||
if err != nil {
|
||
return nil, WxError{-1, err.Error()}
|
||
}
|
||
return &rdata.Data, nil
|
||
}
|
||
|
||
type AddSearchWxUserRequest struct {
|
||
V1 string `json:"v1"`
|
||
V2 string `json:"v2"`
|
||
Remark string `json:"remark"`
|
||
}
|
||
|
||
type AddSearchWxUserResponse struct {
|
||
Data WxCommonData `json:"data"`
|
||
Type int `json:"type"`
|
||
}
|
||
|
||
// AddSearchWxUser 添加搜索用户
|
||
func (w *WxApi) AddSearchWxUser(request AddSearchWxUserRequest) *WxCommonData {
|
||
resp, err := w.internalCall(MtAddSearchUserMsg, 30, MtAddSearchUserMsg, request, nil)
|
||
if err != nil {
|
||
return &WxCommonData{Errcode: -1, Errmsg: err.Error()}
|
||
}
|
||
var rdata AddSearchWxUserResponse
|
||
err = json.Unmarshal([]byte(resp), &rdata)
|
||
if err != nil {
|
||
return &WxCommonData{Errcode: -1, Errmsg: err.Error()}
|
||
}
|
||
return &rdata.Data
|
||
}
|
||
|
||
// CheckFriendStatus 检测好友状态(发送无痕清粉消息)
|
||
func (w *WxApi) CheckFriendStatus(wxid string) *WxCommonData {
|
||
resp, err := w.internalCall(MtZombieCheckMsg, 10, MtZombieCheckMsg, map[string]interface{}{"wxid": wxid}, nil)
|
||
if err != nil {
|
||
return &WxCommonData{Errcode: -1, Errmsg: err.Error()}
|
||
}
|
||
var rdata WxCommonResponse
|
||
err = json.Unmarshal([]byte(resp), &rdata)
|
||
if err != nil {
|
||
return &WxCommonData{Errcode: -1, Errmsg: err.Error()}
|
||
}
|
||
return &rdata.Data
|
||
}
|
||
|
||
type AutoAcceptAddFriendRequest struct {
|
||
Auto int `json:"auto"` // 1自动同意 0取消自动同意
|
||
}
|
||
|
||
// AutoAcceptAddFriend 自动同意好友申请
|
||
func (w *WxApi) AutoAcceptAddFriend(request AutoAcceptAddFriendRequest) (err error) {
|
||
_, err = w.internalCall(0, -1, MtAutoAcceptFriendMsg, request, nil)
|
||
return err
|
||
}
|
||
|
||
type AutoAcceptCardRequest struct {
|
||
Auto int `json:"auto"` // 1自动接收 0取消自动接收
|
||
}
|
||
|
||
// AutoAcceptCard 自动接收名片
|
||
func (w *WxApi) AutoAcceptCard(request AutoAcceptCardRequest) error {
|
||
_, err := w.internalCall(0, -1, MtAutoAcceptCardMsg, request, nil)
|
||
return err
|
||
}
|
||
|
||
type AutoAcceptWCPayRequest struct {
|
||
Auto int `json:"auto"` // 1自动接收 0取消自动接收
|
||
}
|
||
|
||
// AutoAcceptWCPay 自动接收好友转账
|
||
func (w *WxApi) AutoAcceptWCPay(request AutoAcceptWCPayRequest) error {
|
||
_, err := w.internalCall(0, -1, MtAutoAcceptWcpayMsg, request, nil)
|
||
return err
|
||
}
|
||
|
||
type GetPublicUserListResponse struct {
|
||
Data []GetPublicUserListResponseData `json:"data"`
|
||
Type int `json:"type"`
|
||
}
|
||
|
||
type GetPublicUserListResponseData struct {
|
||
Avatar string `json:"avatar"`
|
||
Nickname string `json:"nickname"`
|
||
Wxid string `json:"wxid"`
|
||
}
|
||
|
||
func (w *WxApi) GetPublicUserList() ([]GetPublicUserListResponseData, error) {
|
||
resp, err := w.internalCall(MtDataPublicsMsg, 30, MtDataPublicsMsg, nil, map[string]interface{}{})
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
var rdata GetPublicUserListResponse
|
||
err = json.Unmarshal([]byte(resp), &rdata)
|
||
if err != nil {
|
||
return nil, WxError{-1, err.Error()}
|
||
}
|
||
return rdata.Data, nil
|
||
}
|