Compare commits

...

3 Commits

Author SHA1 Message Date
coward
c3fdb33b17 🎨新增接口,获取群成员信息 2024-01-09 15:58:34 +08:00
comma
418e4e7980 🎨优化代码 2024-01-06 16:37:02 +08:00
coward
919f53913a 🎨为response添加String方法 2024-01-05 17:29:43 +08:00
3 changed files with 72 additions and 1 deletions

View File

@ -141,7 +141,7 @@ func (w *WxHelper) GetContactList(isShowTool bool) (friends []Friend, err error)
var onlyFriends []Friend
for _, v := range friends {
// 固定开头
if strings.HasPrefix(v.Wxid, "wxid") {
if strings.HasPrefix(v.Wxid, "wxid") || strings.HasSuffix(v.Wxid, "@chatroom") {
onlyFriends = append(onlyFriends, v)
}
}
@ -324,3 +324,26 @@ func (w *WxHelper) GetChatRoomMember(param ChatRoomId) (members *ChatRoomMembers
_ = json.Unmarshal(data, &members)
return
}
// GetChatRoomMemberProfile
// @description: 获取群成员详细信息
// @receiver w
// @return memberProfile
// @return err
func (w *WxHelper) GetChatRoomMemberProfile(param WxId) (memberProfile *ChatRoomMemberProfile, err error) {
req := w.client.R()
req.Header.Set("Content-Type", "application/json")
req.SetBody(param)
_, err = req.SetResult(&w.tmpResult).Post(w.GetAddr("/api/getContactProfile"))
if err != nil {
return nil, fmt.Errorf("获取群成员详细信息失败: %v", err.Error())
}
if w.tmpResult.Code <= 0 {
return nil, fmt.Errorf("获取群成员详细信息失败: %v", w.tmpResult.Msg)
}
data, _ := json.Marshal(w.tmpResult.Data)
_ = json.Unmarshal(data, &memberProfile)
return
}

View File

@ -58,3 +58,9 @@ type ForwardMsg struct {
Wxid string `json:"wxid"`
MsgId string `json:"msgId"`
}
// WxId
// @description: 微信ID
type WxId struct {
WxId string `json:"wxId"`
}

View File

@ -1,5 +1,7 @@
package wx_helper_sdk
import "encoding/json"
// CommonResponse
// @description: 公共返回
type CommonResponse struct {
@ -8,6 +10,11 @@ type CommonResponse struct {
Data any `json:"data"`
}
func (r *CommonResponse) String() string {
data, _ := json.Marshal(r)
return string(data)
}
// UserInfo
// @description: 当前用户信息
type UserInfo struct {
@ -25,6 +32,11 @@ type UserInfo struct {
Wxid string `json:"wxid"`
}
func (r *UserInfo) String() string {
data, _ := json.Marshal(r)
return string(data)
}
// Friend
// @description: 朋友信息
type Friend struct {
@ -40,6 +52,11 @@ type Friend struct {
Wxid string `json:"wxid"`
}
func (r *Friend) String() string {
data, _ := json.Marshal(r)
return string(data)
}
// ChatRoomDetail
// @description: 群聊详情
type ChatRoomDetail struct {
@ -49,6 +66,11 @@ type ChatRoomDetail struct {
Xml string `json:"xml"`
}
func (r *ChatRoomDetail) String() string {
data, _ := json.Marshal(r)
return string(data)
}
// ChatRoomMembers
// @description: 群聊人员信息
type ChatRoomMembers struct {
@ -58,3 +80,23 @@ type ChatRoomMembers struct {
MemberNickname string `json:"memberNickname"`
Members string `json:"members"`
}
func (r *ChatRoomMembers) String() string {
data, _ := json.Marshal(r)
return string(data)
}
// ChatRoomMemberProfile
// @description: 获取群成员详细信息
type ChatRoomMemberProfile struct {
Account string `json:"account"`
HeadImage string `json:"headImage"`
Nickname string `json:"nickname"`
V3 string `json:"v3"`
Wxid string `json:"wxid"`
}
func (r *ChatRoomMemberProfile) String() string {
data, _ := json.Marshal(r)
return string(data)
}