forked from dodo-open/dodo-open-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
member.go
200 lines (177 loc) · 6.89 KB
/
member.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
package model
import (
"errors"
)
// MemberElement 获取成员列表 list element
type MemberElement struct {
DodoSourceId string `json:"dodoSourceId"` // DoDoID
NickName string `json:"nickName"` // 在群昵称
PersonalNickName string `json:"personalNickName"` // DoDo昵称
AvatarUrl string `json:"avatarUrl"` // 头像
JoinTime string `json:"joinTime"` // 加群时间
Sex int `json:"sex"` // 性别,-1:保密,0:女,1:男
Level int `json:"level"` // 等级
IsBot int `json:"isBot"` // 是否机器人,0:否,1:是
OnlineDevice int `json:"onlineDevice"` // 在线设备,0:无,1:PC在线,2:手机在线
OnlineStatus int `json:"onlineStatus"` // 在线状态,0:离线,1:在线,2:请勿打扰,3:离开
}
type (
// GetMemberListReq 获取成员列表 request
GetMemberListReq struct {
IslandSourceId string `json:"islandSourceId" binding:"required"` // 群ID
PageSize int `json:"pageSize" binding:"required"` // 页大小,最大100
MaxId uint64 `json:"maxId" binding:"required"` // 上一页最大ID值,为提升分页查询性能,需要传入上一页查询记录中的最大ID值,首页请传0
}
// GetMemberListRsp 获取成员列表 response
GetMemberListRsp struct {
MaxId uint64 `json:"maxId"` // 最大 ID 值
List []*MemberElement `json:"list"` // 列表
}
)
func (p *GetMemberListReq) ValidParams() error {
if p.IslandSourceId == "" {
return errors.New("invalid parameter IslandSourceId (empty detected)")
}
if p.PageSize <= 0 || p.PageSize > 100 {
return errors.New("invalid parameter PageSize (0 < PageSize <= 100)")
}
return nil
}
type (
// GetMemberInfoReq 获取成员信息 request
GetMemberInfoReq struct {
IslandSourceId string `json:"islandSourceId" binding:"required"` // 群ID
DodoSourceId string `json:"dodoSourceId" binding:"required"` // DoDoID
}
// GetMemberInfoRsp 获取成员信息 response
GetMemberInfoRsp struct {
MemberElement
IslandSourceId string `json:"islandSourceId"` // 群ID
}
)
func (p *GetMemberInfoReq) ValidParams() error {
if p.IslandSourceId == "" {
return errors.New("invalid parameter IslandSourceId (empty detected)")
}
if p.DodoSourceId == "" {
return errors.New("invalid parameter DodoSourceId (empty detected)")
}
return nil
}
// GetMemberRoleListReq 获取成员身份组列表 request
type GetMemberRoleListReq struct {
IslandSourceId string `json:"islandSourceId" binding:"required"` // 群ID
DodoSourceId string `json:"dodoSourceId" binding:"required"` // DoDoID
}
func (p *GetMemberRoleListReq) ValidParams() error {
if p.IslandSourceId == "" {
return errors.New("invalid parameter IslandSourceId (empty detected)")
}
if p.DodoSourceId == "" {
return errors.New("invalid parameter DodoSourceId (empty detected)")
}
return nil
}
// SetMemberNickReq 编辑成员群昵称 request
type SetMemberNickReq struct {
IslandSourceId string `json:"islandSourceId" binding:"required"` // 群ID
DodoSourceId string `json:"dodoSourceId" binding:"required"` // DoDoID
NickName string `json:"nickName" binding:"required"` // 在群昵称
}
func (p *SetMemberNickReq) ValidParams() error {
if p.IslandSourceId == "" {
return errors.New("invalid parameter IslandSourceId (empty detected)")
}
if p.DodoSourceId == "" {
return errors.New("invalid parameter DodoSourceId (empty detected)")
}
if p.NickName == "" {
return errors.New("invalid parameter NickName (empty detected)")
}
return nil
}
// MuteMemberReq 禁言成员 request
type MuteMemberReq struct {
IslandSourceId string `json:"islandSourceId" binding:"required"` // 群ID
DodoSourceId string `json:"dodoSourceId" binding:"required"` // DoDoID
Duration int64 `json:"duration" binding:"required"` // 禁言时长(单位:秒),最长 7 天
Reason string `json:"reason,omitempty"` // 禁言原因
}
func (p *MuteMemberReq) ValidParams() error {
if p.IslandSourceId == "" {
return errors.New("invalid parameter IslandSourceId (empty detected)")
}
if p.DodoSourceId == "" {
return errors.New("invalid parameter DodoSourceId (empty detected)")
}
if p.Duration <= 0 || p.Duration > (7*24*60*60) {
return errors.New("invalid parameter Duration (0 second < Duration <= 7 days)")
}
return nil
}
// UnmuteMemberReq 取消禁言成员 request
type UnmuteMemberReq struct {
IslandSourceId string `json:"islandSourceId" binding:"required"` // 群ID
DodoSourceId string `json:"dodoSourceId" binding:"required"` // DoDoID
}
func (p *UnmuteMemberReq) ValidParams() error {
if p.IslandSourceId == "" {
return errors.New("invalid parameter IslandSourceId (empty detected)")
}
if p.DodoSourceId == "" {
return errors.New("invalid parameter DodoSourceId (empty detected)")
}
return nil
}
// BanMemberReq 永久封禁成员 request
type BanMemberReq struct {
IslandSourceId string `json:"islandSourceId" binding:"required"` // 群ID
DodoSourceId string `json:"dodoSourceId" binding:"required"` // DoDoID
NoticeChannelId string `json:"noticeChannelId,omitempty"` // 通知频道ID
Reason string `json:"reason,omitempty"` // 封禁理由,理由不能大于64个字符或32个汉字
}
func (p *BanMemberReq) ValidParams() error {
if p.IslandSourceId == "" {
return errors.New("invalid parameter IslandSourceId (empty detected)")
}
if p.DodoSourceId == "" {
return errors.New("invalid parameter DodoSourceId (empty detected)")
}
return nil
}
// UnbanMemberReq 取消成员永久封禁 request
type UnbanMemberReq struct {
IslandSourceId string `json:"islandSourceId" binding:"required"` // 群ID
DodoSourceId string `json:"dodoSourceId" binding:"required"` // DoDoID
}
func (p *UnbanMemberReq) ValidParams() error {
if p.IslandSourceId == "" {
return errors.New("invalid parameter IslandSourceId (empty detected)")
}
if p.DodoSourceId == "" {
return errors.New("invalid parameter DodoSourceId (empty detected)")
}
return nil
}
type (
// GetMemberInviteInfoReq 获取成员邀请信息 request
GetMemberInviteInfoReq struct {
IslandSourceId string `json:"islandSourceId" binding:"required"` // 群ID
DodoSourceId string `json:"dodoSourceId" binding:"required"` // DoDoID
}
// GetMemberInviteInfoRsp 获取成员邀请信息 response
GetMemberInviteInfoRsp struct {
DodoSourceId string `json:"dodoSourceId"` // DoDoID
NickName string `json:"nickName"` // 在群昵称
InvitationCount int `json:"invitationCount"` // 邀请人数
}
)
func (p *GetMemberInviteInfoReq) ValidParams() error {
if p.IslandSourceId == "" {
return errors.New("invalid parameter IslandSourceId (empty detected)")
}
if p.DodoSourceId == "" {
return errors.New("invalid parameter DodoSourceId (empty detected)")
}
return nil
}