Skip to content

Commit 3344bda

Browse files
committed
mute: 禁言批量成员 (merge request !51)
Squash merge branch 'feature_20220420_kodypan_multimute_story_873489705' into 'master' mute: 禁言批量成员 1、批量禁言指定成员 --story=873489705 TAPD: --story=873489705
1 parent d52d75b commit 3344bda

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

dto/mute.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,12 @@ type UpdateGuildMute struct {
66
MuteEndTimestamp string `json:"mute_end_timestamp,omitempty"`
77
// 禁言多少秒(两个字段二选一,默认以mute_end_timstamp为准)
88
MuteSeconds string `json:"mute_seconds,omitempty"`
9+
// 批量禁言的成员列表(全员禁言时不填写该字段)
10+
UserIDs []string `json:"user_ids,omitempty"`
11+
}
12+
13+
// UpdateGuildMuteResponse 批量禁言的回参
14+
type UpdateGuildMuteResponse struct {
15+
// 批量禁言成功的成员列表
16+
UserIDs []string `json:"user_ids,omitempty"`
917
}

examples/apitest/mute_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,17 @@ func Test_mute(t *testing.T) {
3838
t.Logf("Testing_Succ")
3939
},
4040
)
41+
t.Run(
42+
"频道指定批量成员禁言", func(t *testing.T) {
43+
mute := &dto.UpdateGuildMute{
44+
MuteEndTimestamp: strconv.FormatInt(time.Now().Unix()+600, 10),
45+
UserIDs: []string{testMuteUserID},
46+
}
47+
_, err := api.MultiMemberMute(ctx, testGuildID, mute)
48+
if err != nil {
49+
t.Error(err)
50+
}
51+
t.Logf("Testing_Succ")
52+
},
53+
)
4154
}

openapi/iface.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,11 @@ type MemberAPI interface {
134134
ctx context.Context,
135135
guildID string, roleID dto.RoleID, userID string, value *dto.MemberAddRoleBody,
136136
) error
137-
// 频道指定成员禁言
137+
//MemberMute 频道指定单个成员禁言
138138
MemberMute(ctx context.Context, guildID, userID string, mute *dto.UpdateGuildMute) error
139+
//MultiMemberMute 频道指定批量成员禁言
140+
MultiMemberMute(ctx context.Context, guildID string,
141+
mute *dto.UpdateGuildMute) (*dto.UpdateGuildMuteResponse, error)
139142
}
140143

141144
// DirectMessageAPI 信息相关接口

openapi/v1/mute.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package v1
22

33
import (
44
"context"
5+
"errors"
6+
7+
"github.com/tencent-connect/botgo/log"
58

69
"github.com/tencent-connect/botgo/dto"
710
)
@@ -31,3 +34,20 @@ func (o *openAPI) MemberMute(ctx context.Context, guildID, userID string,
3134
}
3235
return nil
3336
}
37+
38+
//MultiMemberMute 频道批量成员禁言
39+
func (o *openAPI) MultiMemberMute(ctx context.Context, guildID string,
40+
mute *dto.UpdateGuildMute) (*dto.UpdateGuildMuteResponse, error) {
41+
if len(mute.UserIDs) == 0 {
42+
return nil, errors.New("no user id param")
43+
}
44+
rsp, err := o.request(ctx).
45+
SetPathParam("guild_id", guildID).
46+
SetBody(mute).
47+
Patch(o.getURL(guildMuteURI))
48+
if err != nil {
49+
return nil, err
50+
}
51+
log.Infof("MultiMemberMute rsp: %#v", rsp)
52+
return rsp.Result().(*dto.UpdateGuildMuteResponse), nil
53+
}

0 commit comments

Comments
 (0)