Skip to content

Commit

Permalink
🎨 修复能对自己进行权限操作的BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
WhitePaper233 committed Aug 2, 2022
1 parent a96f355 commit 1406118
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions builtin/user_manager/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func handleUser(ctx *zero.Ctx) {

// 处理set命令
if set > 0 {
if ctx.Event.UserID == user {
ctx.SendChain(message.Text("你不能设置自己的权限等级"))
return
}
if control.CheckPremission(ctx.Event.UserID, 9) {
err := setPermissionLevel(user, set)
if err != nil {
Expand All @@ -97,6 +101,10 @@ func handleUser(ctx *zero.Ctx) {

// 处理unban命令
if pardon {
if ctx.Event.UserID == user {
ctx.SendChain(message.Text("你不能解除封禁自己"))
return
}
if control.CheckPremission(ctx.Event.UserID, 9) {
err := pardonUser(user)
if err != nil {
Expand All @@ -112,6 +120,10 @@ func handleUser(ctx *zero.Ctx) {

// 处理reset命令
if reset {
if ctx.Event.UserID == user {
ctx.SendChain(message.Text("你不能重置自己的权限等级"))
return
}
if control.CheckPremission(ctx.Event.UserID, 9) {
err := resetUser(user)
if err != nil {
Expand All @@ -126,6 +138,10 @@ func handleUser(ctx *zero.Ctx) {
}

// 处理ban命令
if ctx.Event.UserID == user {
ctx.SendChain(message.Text("你不能封禁自己"))
return
}
if control.CheckPremission(ctx.Event.UserID, 9) {
err := banUser(user, ban)
if err != nil {
Expand Down

0 comments on commit 1406118

Please sign in to comment.