diff --git a/pkg/bot/handlers.go b/pkg/bot/handlers.go index c2d9ae9..c4af0e6 100644 --- a/pkg/bot/handlers.go +++ b/pkg/bot/handlers.go @@ -22,7 +22,7 @@ var ( // User commands "msg": " ...", "status": "[Discord Mention...]", - "privacy": "", + "privacy": " ", } ) @@ -280,22 +280,44 @@ func (b *Type) handleUserPrivacy(ds *discordgo.Session, dm *discordgo.Message, c uu, _ := b.getUserByDiscordID(dm.Author.ID) c := strings.TrimSpace(ctx.Content) p := strings.Split(c, " ") - if len(p) != 2 { + if len(p) != 3 { b.replyInvalidCommandFormat(ds, dm, ctx, "privacy") return } - pp := strings.ToLower(p[1:][0]) - if !utils.SliceContainsString([]string{"none", "join", "part", "status", "all"}, pp) { + pa := strings.ToLower(p[1:][0]) + pp := strings.ToLower(p[1:][1]) + if !utils.SliceContainsString([]string{"set", "unset"}, pa) { b.replyInvalidCommandFormat(ds, dm, ctx, "privacy") return } - if pp == userPrivacyNone.String() { - uu.Privacy = userPrivacyNone + if !utils.SliceContainsString([]string{"join", "part", "status", "all"}, pp) { + b.replyInvalidCommandFormat(ds, dm, ctx, "privacy") + return + } + if pa == "unset" { + uu.Privacy = upClear(uu.Privacy, userPrivacyFromString(pp)) + } else { + uu.Privacy = upSet(uu.Privacy, userPrivacyFromString(pp)) + } + // XXX + pr := strings.ToTitle(pa) + " " + pp + ". Privacy mode: " + if uu.Privacy == userPrivacyAll { + pr += userPrivacyAll.String() + } else if uu.Privacy == userPrivacyNone { + pr += userPrivacyNone.String() } else { - upSet(uu.Privacy, userPrivacyFromString(pp)) + if upHas(uu.Privacy, userPrivacyJoin) { + pr += "join " + } + if upHas(uu.Privacy, userPrivacyPart) { + pr += "part " + } + if upHas(uu.Privacy, userPrivacyStatus) { + pr += "status " + } } b.dg.Session.ChannelMessageSendReply(dm.ChannelID, - b.getMessageString("all_done", uu)+" Privacy set to: "+uu.Privacy.String(), + b.getMessageString("all_done", uu)+" "+pr, &discordgo.MessageReference{ MessageID: dm.ID, ChannelID: dm.ChannelID,