Compare commits

..

No commits in common. "3482c0c8e49b4fc91514b448ccb40902e4c82850" and "1488033c5260bcac09b2d670875bd5110970b61a" have entirely different histories.

4 changed files with 10 additions and 9 deletions

View File

@ -260,11 +260,11 @@ func IsCmd(c *config.Config, message string) (bool, string) {
return iscmd, message
}
func (b *bot) CheckAdmin(ID string) bool {
func (b *bot) CheckAdmin(nick string) bool {
admins := b.Config().GetArray("Admins", []string{})
log.Info().Interface("admins", admins).Msgf("Checking admin for %s", ID)
log.Info().Interface("admins", admins).Msgf("Checking admin for %s", nick)
for _, u := range admins {
if ID == u {
if nick == u {
log.Info().Msg("%s admin check: passed")
return true
}

View File

@ -109,7 +109,7 @@ var getConfigRegex = regexp.MustCompile(`(?i)^get (?P<key>\S+)$`)
func (p *AdminPlugin) isAdmin(rh bot.ResponseHandler) bot.ResponseHandler {
return func(r bot.Request) bool {
if !p.bot.CheckAdmin(r.Msg.User.ID) {
if !p.bot.CheckAdmin(r.Msg.User.Name) {
log.Debug().Msgf("User %s is not an admin", r.Msg.User.Name)
return false
}

View File

@ -179,7 +179,7 @@ func (p *FirstPlugin) register() {
{Kind: bot.Message, IsCmd: true,
Regex: regexp.MustCompile(`(?i)^clear first$`),
Handler: func(r bot.Request) bool {
if !p.bot.CheckAdmin(r.Msg.User.ID) {
if !p.bot.CheckAdmin(r.Msg.User.Name) {
p.bot.Send(r.Conn, bot.Message, r.Msg.Channel, "You are not authorized to do that.")
return true
}

View File

@ -46,9 +46,10 @@ func (p *RolesPlugin) Register() {
Handler: p.lsRoles,
},
{
Kind: bot.Message, IsCmd: true,
Regex: regexp.MustCompile(`(?i)^setoffering (?P<offering>.+)$`),
Handler: p.setOffering,
Kind: bot.Help, IsCmd: true,
Regex: regexp.MustCompile(`.`),
HelpText: "Lists roles with an optional offering set specifier",
Handler: p.lsRoles,
},
}
p.b.Register(p, bot.Help, func(c bot.Connector, k bot.Kind, m msg.Message, args ...any) bool {
@ -123,7 +124,7 @@ func (p *RolesPlugin) lsRoles(r bot.Request) bool {
}
func (p *RolesPlugin) setOffering(r bot.Request) bool {
if !p.b.CheckAdmin(r.Msg.User.ID) {
if !p.b.CheckAdmin(r.Msg.User.Name) {
p.b.Send(r.Conn, bot.Message, r.Msg.Channel, "You must be an admin to set an offering.")
return true
}