|
|
|
@ -1,6 +1,7 @@
@@ -1,6 +1,7 @@
|
|
|
|
|
package main |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"fmt" |
|
|
|
|
"log" |
|
|
|
|
"os" |
|
|
|
|
"os/signal" |
|
|
|
@ -82,19 +83,20 @@ func run(c *cli.Context) error {
@@ -82,19 +83,20 @@ func run(c *cli.Context) error {
|
|
|
|
|
b.Debug = c.Bool("debug") |
|
|
|
|
b.JSON = c.Bool("json") |
|
|
|
|
b.LogWriter = os.Stdout |
|
|
|
|
b.LogConv = chat1.ConvIDStr(c.String("log-convid")) |
|
|
|
|
//b.LogConv = chat1.ConvIDStr(c.String("log-convid"))
|
|
|
|
|
// set the bot owner for private commands
|
|
|
|
|
if c.String("owner") != "" { |
|
|
|
|
b.Meta["owner"] = c.String("owner") |
|
|
|
|
} |
|
|
|
|
allowedTeams := make(map[chat1.ConvIDStr]bool) |
|
|
|
|
if c.String("kvstore-team") != "" { |
|
|
|
|
b.Meta["kvstore"] = c.String("kvstore-team") |
|
|
|
|
loadNsfwAllowed(b) |
|
|
|
|
allowedTeams = loadNsfwAllowed(b) |
|
|
|
|
} |
|
|
|
|
// set reddit login, which enables reddit commands
|
|
|
|
|
if c.String("reddit-user") != "" && c.String("reddit-pass") != "" { |
|
|
|
|
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
|
|
|
|
@ -166,7 +168,7 @@ func run(c *cli.Context) error {
@@ -166,7 +168,7 @@ func run(c *cli.Context) error {
|
|
|
|
|
}, |
|
|
|
|
keybasebot.BotCommand{ |
|
|
|
|
Name: "boobs", |
|
|
|
|
Ad: nil, |
|
|
|
|
Ad: nil, // send nil advertisement and send fake per-convid ones later
|
|
|
|
|
Run: keybasebot.Adapt( |
|
|
|
|
cmd.Boobs, |
|
|
|
|
keybasebot.MessageType("text"), |
|
|
|
@ -175,6 +177,22 @@ func run(c *cli.Context) error {
@@ -175,6 +177,22 @@ func run(c *cli.Context) error {
|
|
|
|
|
), |
|
|
|
|
}, |
|
|
|
|
) |
|
|
|
|
for convID, allowed := range allowedTeams { |
|
|
|
|
fmt.Printf("loading NSFW conversations\n") |
|
|
|
|
if allowed { |
|
|
|
|
fmt.Printf("NSFW allowed in %s\n", string(convID)) |
|
|
|
|
b.Commands = append(b.Commands, |
|
|
|
|
keybasebot.BotCommand{ |
|
|
|
|
Name: "boobs", |
|
|
|
|
Ad: &cmd.BoobsAd, |
|
|
|
|
AdType: "conv", |
|
|
|
|
AdTeamName: "", |
|
|
|
|
AdConv: convID, |
|
|
|
|
Run: cmd.FakeNsfwAction, |
|
|
|
|
}, |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// catch ctrl-c so we can clean up
|
|
|
|
@ -190,16 +208,14 @@ func run(c *cli.Context) error {
@@ -190,16 +208,14 @@ func run(c *cli.Context) error {
|
|
|
|
|
}() |
|
|
|
|
// then run
|
|
|
|
|
b.Run() |
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func loadNsfwAllowed(b *keybasebot.Bot) { |
|
|
|
|
func loadNsfwAllowed(b *keybasebot.Bot) (allowedTeams map[chat1.ConvIDStr]bool) { |
|
|
|
|
// get the team from meta
|
|
|
|
|
data, ok := b.Meta["kvstore"] |
|
|
|
|
if ok { |
|
|
|
|
// make something to fill
|
|
|
|
|
allowedTeams := make(map[chat1.ConvIDStr]bool) |
|
|
|
|
team := data.(string) |
|
|
|
|
kvKey := kvstore.New("nsfwAllowed", &allowedTeams, -1) |
|
|
|
|
err := kvstore.Get(b.KB, team, "ssh0le", &kvKey) |
|
|
|
|