making use of the extended perms and added future work

This commit is contained in:
ari committed 2026-11-01 13:55:25 -05:00
1 parent 296e465f48
commit 22fd8fbce8
19 files changed
+617 -40

No files matched your search

+34
View File
@@ -240,6 +240,40 @@ func ParseToggle(word string) (on, ok bool) {
return false, false
}
var listenModes = map[string]model.ListenMode{
"all": model.ListenAll, "all-messages": model.ListenAll, "all-message": model.ListenAll, "everything": model.ListenAll,
"mentions": model.ListenMentions, "only-mentions": model.ListenMentions, "only-mention": model.ListenMentions,
"mentions-only": model.ListenMentions,
}
type ListenCmd struct {
Channel bool
// Empty means show the current setting.
Mode model.ListenMode
}
// IsListen accepts `listen` and `/listen`. Slack only treats a leading slash
// as a slash command, so `@slacker /listen …` reaches the bot as text.
func IsListen(verb string) bool { return verb == "listen" || verb == "/listen" }
func ParseListen(args string) (ListenCmd, error) {
var c ListenCmd
words := strings.Fields(strings.ToLower(args))
if len(words) > 0 && (words[0] == "channel" || words[0] == "default") {
c.Channel, words = true, words[1:]
}
switch len(words) {
case 0:
return c, nil
case 1:
if mode, ok := listenModes[words[0]]; ok {
c.Mode = mode
return c, nil
}
}
return c, ErrNotCommand
}
func NeededPermission(verb, args string) model.Action {
switch verb {
case "scale":