Browse Source

remove require owner adapter in favor of builtin adapter

master
David Haukeness 5 years ago
parent
commit
4336026a5b
  1. 24
      adapters.go
  2. 2
      main.go

24
adapters.go

@ -36,27 +36,3 @@ func nsfwFilter() keybasebot.Adapter { @@ -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
}
}
}

2
main.go

@ -142,7 +142,7 @@ func run(c *cli.Context) error { @@ -142,7 +142,7 @@ func run(c *cli.Context) error {
setNsfw,
keybasebot.MessageType("text"),
keybasebot.CommandPrefix("!nsfw"),
requireOwner(),
keybasebot.FromUser(c.String("owner")),
),
},
)

Loading…
Cancel
Save