remove require owner adapter in favor of builtin adapter
This commit is contained in:
-24
@@ -36,27 +36,3 @@ func nsfwFilter() keybasebot.Adapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func requireOwner() keybasebot.Adapter {
|
|
||||||
return func(action keybasebot.BotAction) keybasebot.BotAction {
|
|
||||||
return func(m chat1.MsgSummary, b *keybasebot.Bot) (bool, error) {
|
|
||||||
b.Logger.Debug("checking owner command auth")
|
|
||||||
// if the team is in the allowed list, nsfw is allowed
|
|
||||||
data, ok := b.Meta["owner"]
|
|
||||||
if !ok {
|
|
||||||
b.Logger.Debug("unable to fetch owner from meta")
|
|
||||||
err := fmt.Errorf("owner command used without owner set")
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
myOwner := data.(string)
|
|
||||||
if m.Sender.Username == myOwner {
|
|
||||||
b.Logger.Debug("owner command approved")
|
|
||||||
return action(m, b)
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the team is not allowed, fail silently
|
|
||||||
b.Logger.Info("@%s tried to user owner command without auth.", m.Sender.Username)
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ func run(c *cli.Context) error {
|
|||||||
setNsfw,
|
setNsfw,
|
||||||
keybasebot.MessageType("text"),
|
keybasebot.MessageType("text"),
|
||||||
keybasebot.CommandPrefix("!nsfw"),
|
keybasebot.CommandPrefix("!nsfw"),
|
||||||
requireOwner(),
|
keybasebot.FromUser(c.String("owner")),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user