restart fix + slack commands

This commit is contained in:
ari committed 2026-11-01 15:10:39 -05:00
1 parent e90c9f324b
commit 25fcf85855
22 files changed
+1077 -119

No files matched your search

+9 -12
View File
@@ -32,14 +32,11 @@ func actionList(actions []model.Action) string {
// manageCommand handles permission changes. It returns false if the message
// isn't one of these commands, so it goes to the agent.
func (b *Bot) manageCommand(ctx context.Context, m incoming, verb, args string) bool {
func (b *Bot) manageCommand(ctx context.Context, m incoming, verb, args string) (string, bool) {
_, kind := m.owner()
p := b.store.Permissions()
reply := func(text string) bool {
b.say(ctx, m.channel, m.threadTS, text)
return true
}
denied := func(global bool) bool {
reply := func(text string) (string, bool) { return text, true }
denied := func(global bool) (string, bool) {
who := "user managers"
if !global {
who = "user managers and people with *manage* permission here"
@@ -58,7 +55,7 @@ func (b *Bot) manageCommand(ctx context.Context, m incoming, verb, args string)
case "grant", "revoke":
g, err := commands.ParseGrant(args)
if errors.Is(err, commands.ErrNotCommand) {
return false
return "", false
}
if err != nil {
return reply(":warning: " + err.Error() + ". Try `grant @alice move scale` or `revoke @alice`.")
@@ -119,11 +116,11 @@ func (b *Bot) manageCommand(ctx context.Context, m incoming, verb, args string)
case "dm":
words := strings.Fields(strings.ToLower(args))
if len(words) != 2 || !slices.Contains(model.AllActions, model.Action(words[0])) {
return false
return "", false
}
on, ok := commands.ParseToggle(words[1])
if !ok {
return false
return "", false
}
if !p.IsManager(m.user) {
return denied(true)
@@ -145,7 +142,7 @@ func (b *Bot) manageCommand(ctx context.Context, m incoming, verb, args string)
op := strings.ToLower(words[0])
g, err := commands.ParseGrant(strings.Join(words[1:], " "))
if (op != "add" && op != "remove") || err != nil || len(g.Actions) > 0 {
return false
return "", false
}
if !p.IsManager(m.user) {
return denied(true)
@@ -171,7 +168,7 @@ func (b *Bot) manageCommand(ctx context.Context, m incoming, verb, args string)
case "permissions":
if strings.ToLower(args) != "reset" {
return false
return "", false
}
if kind == model.OwnerUser {
return reply("DMs don't have a super-user list to reset.")
@@ -184,5 +181,5 @@ func (b *Bot) manageCommand(ctx context.Context, m incoming, verb, args string)
}
return reply("Done. This channel uses the default super-user list again.")
}
return false
return "", false
}