From a6ba3f679440f9146c2b2a8af7f32f4ae971e882 Mon Sep 17 00:00:00 2001 From: Matthew Faltys Date: Wed, 6 Sep 2017 21:00:12 -0500 Subject: [PATCH] Refactor rek/gnu handler --- lorebot/lorebot.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lorebot/lorebot.go b/lorebot/lorebot.go index a3096d1..507f9ad 100644 --- a/lorebot/lorebot.go +++ b/lorebot/lorebot.go @@ -157,10 +157,10 @@ func dynamicCommandHandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient * rtm.SendMessage(rtm.NewOutgoingMessage("command not yet supported", ev.Channel)) case "rek": s := strings.SplitN(string(ev.Text), " ", 2) - rekhandler(redisClient, rtm, ev, s[1]) + rekhandler(rtm, ev, s[1], redisClient) case "gnu": s := strings.SplitN(string(ev.Text), " ", 2) - gnuhandler(redisClient, rtm, ev, s[1]) + gnuhandler(rtm, ev, s[1]) case "created": rtm.SendMessage(rtm.NewOutgoingMessage("command not yet supported", ev.Channel)) case "owner": @@ -238,13 +238,13 @@ func contenthandler(rtm *slack.RTM, ev *slack.MessageEvent, message, queryType s } } -func rekhandler(redisClient *redis.Client, rtm *slack.RTM, ev *slack.MessageEvent, target string) { +func rekhandler(rtm *slack.RTM, ev *slack.MessageEvent, target string, redisClient *redis.Client) { rektBit, _ := redisClient.SRandMember("index:rekt").Result() rekFmt := fmt.Sprintf("%s %s", target, rektBit) rtm.SendMessage(rtm.NewOutgoingMessage(rekFmt, ev.Channel)) } -func gnuhandler(redisClient *redis.Client, rtm *slack.RTM, ev *slack.MessageEvent, target string) { +func gnuhandler(rtm *slack.RTM, ev *slack.MessageEvent, target string) { gnuFmt := fmt.Sprintf("slaps the nonfree software out of %s's hands", target) rtm.SendMessage(rtm.NewOutgoingMessage(gnuFmt, ev.Channel)) }