From 7af94f3473cfed7d0c6eaaf67ecec00bbd85ce55 Mon Sep 17 00:00:00 2001 From: Chris Sexton <3216719+chrissexton@users.noreply.github.com> Date: Tue, 2 Aug 2022 13:29:49 -0400 Subject: [PATCH] admin: conditionally require admin for nick change --- plugins/admin/admin.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/admin/admin.go b/plugins/admin/admin.go index f65ddce..e64f9a4 100644 --- a/plugins/admin/admin.go +++ b/plugins/admin/admin.go @@ -57,7 +57,7 @@ func New(b bot.Bot) *AdminPlugin { b.RegisterRegexCmd(p, bot.Message, pushConfigRegex, p.isAdmin(p.pushConfigCmd)) b.RegisterRegexCmd(p, bot.Message, setKeyConfigRegex, p.isAdmin(p.setKeyConfigCmd)) b.RegisterRegexCmd(p, bot.Message, getConfigRegex, p.isAdmin(p.getConfigCmd)) - b.RegisterRegexCmd(p, bot.Message, setNickRegex, p.isAdmin(p.setNick)) + b.RegisterRegexCmd(p, bot.Message, setNickRegex, p.setNick) b.Register(p, bot.Help, p.help) p.registerWeb() @@ -411,6 +411,9 @@ func (p *AdminPlugin) modList(query, channel, plugin string) error { } func (p *AdminPlugin) setNick(r bot.Request) bool { + if needAdmin := p.cfg.GetInt("nick.needsadmin", 1); needAdmin == 1 && !p.bot.CheckAdmin(r.Msg.User.ID) { + return false + } nick := r.Values["nick"] if err := r.Conn.Nick(nick); err != nil { log.Error().Err(err).Msg("set nick")