Browse Source

Add rng function

develop
Matthew Faltys 7 years ago
parent
commit
0b619605cd
  1. 20
      lorebot/lorebot.go

20
lorebot/lorebot.go

@ -199,7 +199,7 @@ func staticCommandHandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *r
case "help2": case "help2":
advancedhelpmsg(rtm, ev) advancedhelpmsg(rtm, ev)
case "rng": case "rng":
rtm.SendMessage(rtm.NewOutgoingMessage("command not yet supported", ev.Channel)) rnghandler(rtm, ev, redisClient)
case "version": case "version":
rtm.SendMessage(rtm.NewOutgoingMessage("command not yet supported", ev.Channel)) rtm.SendMessage(rtm.NewOutgoingMessage("command not yet supported", ev.Channel))
case "lorelist": case "lorelist":
@ -269,6 +269,24 @@ func rekhandler(rtm *slack.RTM, ev *slack.MessageEvent, target string, redisClie
rtm.SendMessage(rtm.NewOutgoingMessage(rekFmt, ev.Channel)) rtm.SendMessage(rtm.NewOutgoingMessage(rekFmt, ev.Channel))
} }
func rnghandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Client) {
// get random lore from list
rngLore, err := redisClient.SRandMember("index:lore:added").Result()
if err != nil {
fmt.Printf("%v\n", err)
}
// get lore content
rngContent, err := loreCheck(rngLore, "lore", redisClient)
if err != nil {
fmt.Printf("%v\n", err)
rtm.SendMessage(rtm.NewOutgoingMessage("beep boop.. broken bot..", ev.Channel))
return
}
rngMsg := fmt.Sprintf("Random lore: `%s`\n%s", rngLore, rngContent)
rtm.SendMessage(rtm.NewOutgoingMessage(rngMsg, ev.Channel))
}
func gnuhandler(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) gnuFmt := fmt.Sprintf("slaps the nonfree software out of %s's hands", target)
rtm.SendMessage(rtm.NewOutgoingMessage(gnuFmt, ev.Channel)) rtm.SendMessage(rtm.NewOutgoingMessage(gnuFmt, ev.Channel))

Loading…
Cancel
Save