Browse Source

Refactor rek/gnu handler

master
Matthew Faltys 7 years ago
parent
commit
a6ba3f6794
  1. 8
      lorebot/lorebot.go

8
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))
}

Loading…
Cancel
Save