diff --git a/lorebot/lorebot.go b/lorebot/lorebot.go index afc4876..5a30f71 100644 --- a/lorebot/lorebot.go +++ b/lorebot/lorebot.go @@ -209,6 +209,10 @@ func staticCommandHandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *r rnghandler(rtm, ev, redisClient) case "depricatedrng": depricatedrnghandler(rtm, ev, redisClient) + case "roll": + rollhandler(rtm, ev) + case "dice": + dicerollhandler(rtm, ev) case "listen": rtm.SendMessage(rtm.NewOutgoingMessage("*it's what you hearin*", ev.Channel)) case "lorelist": @@ -290,6 +294,21 @@ func riphandler(rtm *slack.RTM, ev *slack.MessageEvent, target string) { rtm.SendMessage(rtm.NewOutgoingMessage(ripFmt, ev.Channel)) } +func rollhandler(rtm *slack.RTM, ev *slack.MessageEvent) { + //fmt.Print(rand.Intn(100)) + rndStr := fmt.Sprintf("%08d", rand.Int63n(1e8)) + rtm.SendMessage(rtm.NewOutgoingMessage(rndStr, ev.Channel)) +} + +func dicerollhandler(rtm *slack.RTM, ev *slack.MessageEvent) { + //fmt.Print(rand.Intn(100)) + dice := []int{1, 2, 3, 4, 5, 6} + 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()