mirror of https://github.com/velour/catbase.git
Compare commits
2 Commits
1488033c52
...
3482c0c8e4
Author | SHA1 | Date |
---|---|---|
Chris Sexton | 3482c0c8e4 | |
Chris Sexton | c3e1a72f9a |
|
@ -260,11 +260,11 @@ func IsCmd(c *config.Config, message string) (bool, string) {
|
||||||
return iscmd, message
|
return iscmd, message
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bot) CheckAdmin(nick string) bool {
|
func (b *bot) CheckAdmin(ID string) bool {
|
||||||
admins := b.Config().GetArray("Admins", []string{})
|
admins := b.Config().GetArray("Admins", []string{})
|
||||||
log.Info().Interface("admins", admins).Msgf("Checking admin for %s", nick)
|
log.Info().Interface("admins", admins).Msgf("Checking admin for %s", ID)
|
||||||
for _, u := range admins {
|
for _, u := range admins {
|
||||||
if nick == u {
|
if ID == u {
|
||||||
log.Info().Msg("%s admin check: passed")
|
log.Info().Msg("%s admin check: passed")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ var getConfigRegex = regexp.MustCompile(`(?i)^get (?P<key>\S+)$`)
|
||||||
|
|
||||||
func (p *AdminPlugin) isAdmin(rh bot.ResponseHandler) bot.ResponseHandler {
|
func (p *AdminPlugin) isAdmin(rh bot.ResponseHandler) bot.ResponseHandler {
|
||||||
return func(r bot.Request) bool {
|
return func(r bot.Request) bool {
|
||||||
if !p.bot.CheckAdmin(r.Msg.User.Name) {
|
if !p.bot.CheckAdmin(r.Msg.User.ID) {
|
||||||
log.Debug().Msgf("User %s is not an admin", r.Msg.User.Name)
|
log.Debug().Msgf("User %s is not an admin", r.Msg.User.Name)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@ func (p *FirstPlugin) register() {
|
||||||
{Kind: bot.Message, IsCmd: true,
|
{Kind: bot.Message, IsCmd: true,
|
||||||
Regex: regexp.MustCompile(`(?i)^clear first$`),
|
Regex: regexp.MustCompile(`(?i)^clear first$`),
|
||||||
Handler: func(r bot.Request) bool {
|
Handler: func(r bot.Request) bool {
|
||||||
if !p.bot.CheckAdmin(r.Msg.User.Name) {
|
if !p.bot.CheckAdmin(r.Msg.User.ID) {
|
||||||
p.bot.Send(r.Conn, bot.Message, r.Msg.Channel, "You are not authorized to do that.")
|
p.bot.Send(r.Conn, bot.Message, r.Msg.Channel, "You are not authorized to do that.")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,10 +46,9 @@ func (p *RolesPlugin) Register() {
|
||||||
Handler: p.lsRoles,
|
Handler: p.lsRoles,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Kind: bot.Help, IsCmd: true,
|
Kind: bot.Message, IsCmd: true,
|
||||||
Regex: regexp.MustCompile(`.`),
|
Regex: regexp.MustCompile(`(?i)^setoffering (?P<offering>.+)$`),
|
||||||
HelpText: "Lists roles with an optional offering set specifier",
|
Handler: p.setOffering,
|
||||||
Handler: p.lsRoles,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
p.b.Register(p, bot.Help, func(c bot.Connector, k bot.Kind, m msg.Message, args ...any) bool {
|
p.b.Register(p, bot.Help, func(c bot.Connector, k bot.Kind, m msg.Message, args ...any) bool {
|
||||||
|
@ -124,7 +123,7 @@ func (p *RolesPlugin) lsRoles(r bot.Request) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *RolesPlugin) setOffering(r bot.Request) bool {
|
func (p *RolesPlugin) setOffering(r bot.Request) bool {
|
||||||
if !p.b.CheckAdmin(r.Msg.User.Name) {
|
if !p.b.CheckAdmin(r.Msg.User.ID) {
|
||||||
p.b.Send(r.Conn, bot.Message, r.Msg.Channel, "You must be an admin to set an offering.")
|
p.b.Send(r.Conn, bot.Message, r.Msg.Channel, "You must be an admin to set an offering.")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue