From ac99f6d0ba43dafa83bc024c0876491b5e465bb3 Mon Sep 17 00:00:00 2001 From: Matthew Faltys Date: Fri, 2 Mar 2018 08:13:51 -0600 Subject: [PATCH] Add russian roulette rng roll --- lorebot/lorebot.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lorebot/lorebot.go b/lorebot/lorebot.go index 5a30f71..b5ab538 100644 --- a/lorebot/lorebot.go +++ b/lorebot/lorebot.go @@ -211,6 +211,10 @@ func staticCommandHandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *r depricatedrnghandler(rtm, ev, redisClient) case "roll": rollhandler(rtm, ev) + case "d20": + d20handler(rtm, ev) + case "rr": + rrhandler(rtm, ev) case "dice": dicerollhandler(rtm, ev) case "listen": @@ -309,6 +313,24 @@ func dicerollhandler(rtm *slack.RTM, ev *slack.MessageEvent) { rtm.SendMessage(rtm.NewOutgoingMessage(rndStr, ev.Channel)) } +func rrhandler(rtm *slack.RTM, ev *slack.MessageEvent) { + //fmt.Print(rand.Intn(100)) + dice := []string{"*click*", "*BANG*", "*click*", "*click*", "*click*", "*click*"} + rand.Seed(time.Now().UnixNano()) + rndStr := dice[rand.Intn(len(dice)-1)] + + rtm.SendMessage(rtm.NewOutgoingMessage(rndStr, ev.Channel)) +} + +func d20handler(rtm *slack.RTM, ev *slack.MessageEvent) { + //fmt.Print(rand.Intn(100)) + dice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} + rand.Seed(time.Now().UnixNano()) + rndStr := fmt.Sprintf("%d", dice[rand.Intn(len(dice)-1)]) + + rtm.SendMessage(rtm.NewOutgoingMessage(rndStr, ev.Channel)) +} + func depricatedrnghandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Client) { // get random lore from list rngLore, err := redisClient.SRandMember("index:lore:added").Result()