Browse Source

Add RIP command

develop
Matthew Faltys 7 years ago
parent
commit
3f529521c4
  1. 11
      lorebot/lorebot.go

11
lorebot/lorebot.go

@ -174,6 +174,9 @@ func dynamicCommandHandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *
case "rek": case "rek":
s := strings.SplitN(string(ev.Text), " ", 2) s := strings.SplitN(string(ev.Text), " ", 2)
rekhandler(rtm, ev, s[1], redisClient) rekhandler(rtm, ev, s[1], redisClient)
case "rip":
s := strings.SplitN(string(ev.Text), " ", 2)
riphandler(rtm, ev, s[1])
case "gnu": case "gnu":
s := strings.SplitN(string(ev.Text), " ", 2) s := strings.SplitN(string(ev.Text), " ", 2)
gnuhandler(rtm, ev, s[1]) gnuhandler(rtm, ev, s[1])
@ -268,6 +271,14 @@ 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 riphandler(rtm *slack.RTM, ev *slack.MessageEvent, target string) {
// create a timestamp to use
t := time.Now()
tstamp := t.Format("01-02-2006")
ripFmt := fmt.Sprintf("here lies %s, disrespected to death %s..", target, tstamp)
rtm.SendMessage(rtm.NewOutgoingMessage(ripFmt, ev.Channel))
}
func rnghandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Client) { func rnghandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Client) {
// get random lore from list // get random lore from list
rngLore, err := redisClient.SRandMember("index:lore:added").Result() rngLore, err := redisClient.SRandMember("index:lore:added").Result()

Loading…
Cancel
Save