|
|
|
@ -184,6 +184,12 @@ func dynamicCommandHandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *
|
|
|
|
|
case "rmlunch": |
|
|
|
|
s := strings.SplitN(string(ev.Text), " ", 2) |
|
|
|
|
rmlunchhandler(rtm, ev, s[1], redisClient) |
|
|
|
|
case "newbrb": |
|
|
|
|
s := strings.SplitN(string(ev.Text), " ", 2) |
|
|
|
|
newbrbhandler(rtm, ev, s[1], redisClient) |
|
|
|
|
case "rmbrb": |
|
|
|
|
s := strings.SplitN(string(ev.Text), " ", 2) |
|
|
|
|
rmbrbhandler(rtm, ev, s[1], redisClient) |
|
|
|
|
case "rmlore": |
|
|
|
|
rmhandler(rtm, ev, content, "lore", redisClient) |
|
|
|
|
case "rek": |
|
|
|
@ -231,6 +237,8 @@ func staticCommandHandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *r
|
|
|
|
|
dubshandler(rtm, ev, redisClient) |
|
|
|
|
case "lunch": |
|
|
|
|
lunchhandler(rtm, ev, redisClient) |
|
|
|
|
case "brb": |
|
|
|
|
brbhandler(rtm, ev, redisClient) |
|
|
|
|
case "roll": |
|
|
|
|
rollhandler(rtm, ev) |
|
|
|
|
case "rr": |
|
|
|
@ -644,6 +652,54 @@ func lunchhandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Cli
|
|
|
|
|
rtm.SendMessage(rtm.NewOutgoingMessage(rngDubs, ev.Channel)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func newbrbhandler(rtm *slack.RTM, ev *slack.MessageEvent, newContent string, redisClient *redis.Client) { |
|
|
|
|
// prep content for brbification
|
|
|
|
|
// aka remove the '<' and '>' that slack adds
|
|
|
|
|
newContent = strings.Replace(newContent, "<", "", -1) |
|
|
|
|
newContent = strings.Replace(newContent, ">", "", -1) |
|
|
|
|
|
|
|
|
|
err := redisClient.SAdd("index:brb", newContent) |
|
|
|
|
if err != nil { |
|
|
|
|
rtm.SendMessage(rtm.NewOutgoingMessage("tjancism added", ev.Channel)) |
|
|
|
|
} else { |
|
|
|
|
rtm.SendMessage(rtm.NewOutgoingMessage("tjanceism addition failed", ev.Channel)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func rmbrbhandler(rtm *slack.RTM, ev *slack.MessageEvent, rmContent string, redisClient *redis.Client) { |
|
|
|
|
// prep content for brb removal
|
|
|
|
|
// aka remove the '<' and '>' that slack adds
|
|
|
|
|
rmContent = strings.Replace(rmContent, "<", "", -1) |
|
|
|
|
rmContent = strings.Replace(rmContent, ">", "", -1) |
|
|
|
|
|
|
|
|
|
err := redisClient.SRem("index:brb", rmContent) |
|
|
|
|
if err != nil { |
|
|
|
|
rtm.SendMessage(rtm.NewOutgoingMessage("tjancism removed", ev.Channel)) |
|
|
|
|
} else { |
|
|
|
|
rtm.SendMessage(rtm.NewOutgoingMessage("tjancism removal failed", ev.Channel)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func brbhandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Client) { |
|
|
|
|
// aka index:command:added
|
|
|
|
|
newType := fmt.Sprintf("index:brb") |
|
|
|
|
|
|
|
|
|
command, err := loreQuery(newType, redisClient) |
|
|
|
|
if err != nil { |
|
|
|
|
glogger.Error.Println(err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// if the array is empty, exit early
|
|
|
|
|
if len(command) <= 0 { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// pick a random one
|
|
|
|
|
rand.Seed(time.Now().UnixNano()) |
|
|
|
|
rngDubs := fmt.Sprint(command[rand.Intn(len(command))]) |
|
|
|
|
rtm.SendMessage(rtm.NewOutgoingMessage(rngDubs, ev.Channel)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func rmhandler(rtm *slack.RTM, ev *slack.MessageEvent, message, rmType string, redisClient *redis.Client) { |
|
|
|
|
// get nick from slack api
|
|
|
|
|
user, err := rtm.GetUserInfo(ev.User) |
|
|
|
|