nsfw functioning, enables/disables boobs
This commit is contained in:
33
cmd/nsfw.go
33
cmd/nsfw.go
@ -79,7 +79,11 @@ func addNsfwTeam(b *keybasebot.Bot, c chat1.ConvIDStr) bool {
|
|||||||
// the key doesn't exist yet so go ahead and create it
|
// the key doesn't exist yet so go ahead and create it
|
||||||
allowedTeams[c] = true
|
allowedTeams[c] = true
|
||||||
} else {
|
} else {
|
||||||
// the key exists and needs to be updated
|
// the key exists
|
||||||
|
if allowedTeams[c] == true {
|
||||||
|
// its already allowed so just return
|
||||||
|
return true
|
||||||
|
}
|
||||||
allowedTeams = data.(map[chat1.ConvIDStr]bool)
|
allowedTeams = data.(map[chat1.ConvIDStr]bool)
|
||||||
allowedTeams[c] = true
|
allowedTeams[c] = true
|
||||||
}
|
}
|
||||||
@ -95,6 +99,19 @@ func addNsfwTeam(b *keybasebot.Bot, c chat1.ConvIDStr) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// now we need to add the key to the Commands/Ads and re-advertise
|
||||||
|
b.ClearCommands()
|
||||||
|
b.Commands = append(b.Commands,
|
||||||
|
keybasebot.BotCommand{
|
||||||
|
Name: "boobs",
|
||||||
|
Ad: &BoobsAd,
|
||||||
|
AdType: "conv",
|
||||||
|
AdTeamName: "",
|
||||||
|
AdConv: c,
|
||||||
|
Run: FakeNsfwAction,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
b.AdvertiseCommands()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,9 +139,23 @@ func delNsfwTeam(b *keybasebot.Bot, c chat1.ConvIDStr) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// then delete the advertisement
|
||||||
|
b.ClearCommands()
|
||||||
|
oldCommands := b.Commands
|
||||||
|
b.Commands = nil
|
||||||
|
for _, cmd := range oldCommands {
|
||||||
|
if cmd.AdConv != c {
|
||||||
|
b.Commands = append(b.Commands, cmd)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
b.AdvertiseCommands()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FakeNsfwAction(m chat1.MsgSummary, b *keybasebot.Bot) (bool, error) {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
func isConversationId(s string) bool {
|
func isConversationId(s string) bool {
|
||||||
if len(s) != 64 {
|
if len(s) != 64 {
|
||||||
return false
|
return false
|
||||||
|
|||||||
9
main.go
9
main.go
@ -96,7 +96,7 @@ func run(c *cli.Context) error {
|
|||||||
// set reddit login, which enables reddit commands
|
// set reddit login, which enables reddit commands
|
||||||
if c.String("reddit-user") != "" && c.String("reddit-pass") != "" {
|
if c.String("reddit-user") != "" && c.String("reddit-pass") != "" {
|
||||||
b.Meta["reddit-user"] = c.String("reddit-user")
|
b.Meta["reddit-user"] = c.String("reddit-user")
|
||||||
b.Meta["reddit-pass"] = c.String("reddit-user")
|
b.Meta["reddit-pass"] = c.String("reddit-pass")
|
||||||
}
|
}
|
||||||
|
|
||||||
// register the bot commands
|
// register the bot commands
|
||||||
@ -186,8 +186,9 @@ func run(c *cli.Context) error {
|
|||||||
Name: "boobs",
|
Name: "boobs",
|
||||||
Ad: &cmd.BoobsAd,
|
Ad: &cmd.BoobsAd,
|
||||||
AdType: "conv",
|
AdType: "conv",
|
||||||
|
AdTeamName: "",
|
||||||
AdConv: convID,
|
AdConv: convID,
|
||||||
Run: fakeAction,
|
Run: cmd.FakeNsfwAction,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -226,7 +227,3 @@ func loadNsfwAllowed(b *keybasebot.Bot) (allowedTeams map[chat1.ConvIDStr]bool)
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func fakeAction(m chat1.MsgSummary, b *keybasebot.Bot) (bool, error) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user