Honor allowed users list
This commit is contained in:
@@ -175,7 +175,7 @@ func (b *Bot) runStop(ctx context.Context, checkAllowed bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if checkAllowed && !cfg.Allowed(b.noowner, evt.Sender) {
|
if checkAllowed && !cfg.Allowed(b.noowner, evt.Sender, b.allowedUsers) {
|
||||||
b.Notice(ctx, evt.RoomID, "you don't have permission to do that")
|
b.Notice(ctx, evt.RoomID, "you don't have permission to do that")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -251,7 +251,7 @@ func (b *Bot) setOption(ctx context.Context, name, value string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !cfg.Allowed(b.noowner, evt.Sender) {
|
if !cfg.Allowed(b.noowner, evt.Sender, b.allowedUsers) {
|
||||||
b.Notice(ctx, evt.RoomID, "you don't have permission to do that, kupo")
|
b.Notice(ctx, evt.RoomID, "you don't have permission to do that, kupo")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package bot
|
package bot
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -20,7 +21,11 @@ type settingsOld struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Allowed checks if change is allowed
|
// Allowed checks if change is allowed
|
||||||
func (s settings) Allowed(noowner bool, userID id.UserID) bool {
|
func (s settings) Allowed(noowner bool, userID id.UserID, allowedUsers []*regexp.Regexp) bool {
|
||||||
|
if !utils.Match(userID.String(), allowedUsers) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
if noowner {
|
if noowner {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user