|
|
@ -178,6 +178,12 @@ func dynamicCommandHandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient * |
|
|
|
case "rmdubs": |
|
|
|
case "rmdubs": |
|
|
|
s := strings.SplitN(string(ev.Text), " ", 2) |
|
|
|
s := strings.SplitN(string(ev.Text), " ", 2) |
|
|
|
rmdubshandler(rtm, ev, s[1], redisClient) |
|
|
|
rmdubshandler(rtm, ev, s[1], redisClient) |
|
|
|
|
|
|
|
case "newlunch": |
|
|
|
|
|
|
|
s := strings.SplitN(string(ev.Text), " ", 2) |
|
|
|
|
|
|
|
newlunchhandler(rtm, ev, s[1], redisClient) |
|
|
|
|
|
|
|
case "rmlunch": |
|
|
|
|
|
|
|
s := strings.SplitN(string(ev.Text), " ", 2) |
|
|
|
|
|
|
|
rmlunchhandler(rtm, ev, s[1], redisClient) |
|
|
|
case "rmlore": |
|
|
|
case "rmlore": |
|
|
|
rmhandler(rtm, ev, content, "lore", redisClient) |
|
|
|
rmhandler(rtm, ev, content, "lore", redisClient) |
|
|
|
case "rek": |
|
|
|
case "rek": |
|
|
@ -215,10 +221,16 @@ func staticCommandHandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *r |
|
|
|
advancedhelpmsg(rtm, ev) |
|
|
|
advancedhelpmsg(rtm, ev) |
|
|
|
case "rng": |
|
|
|
case "rng": |
|
|
|
rnghandler(rtm, ev, redisClient) |
|
|
|
rnghandler(rtm, ev, redisClient) |
|
|
|
|
|
|
|
case "egg": |
|
|
|
|
|
|
|
egghandler(rtm, ev, redisClient) |
|
|
|
|
|
|
|
case "giveup": |
|
|
|
|
|
|
|
giveuphandler(rtm, ev, redisClient) |
|
|
|
case "depricatedrng": |
|
|
|
case "depricatedrng": |
|
|
|
depricatedrnghandler(rtm, ev, redisClient) |
|
|
|
depricatedrnghandler(rtm, ev, redisClient) |
|
|
|
case "dubs": |
|
|
|
case "dubs": |
|
|
|
dubshandler(rtm, ev, redisClient) |
|
|
|
dubshandler(rtm, ev, redisClient) |
|
|
|
|
|
|
|
case "lunch": |
|
|
|
|
|
|
|
lunchhandler(rtm, ev, redisClient) |
|
|
|
case "roll": |
|
|
|
case "roll": |
|
|
|
rollhandler(rtm, ev) |
|
|
|
rollhandler(rtm, ev) |
|
|
|
case "rr": |
|
|
|
case "rr": |
|
|
@ -399,6 +411,56 @@ func rnghandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Clien |
|
|
|
rtm.SendMessage(rtm.NewOutgoingMessage(rngMsg, ev.Channel)) |
|
|
|
rtm.SendMessage(rtm.NewOutgoingMessage(rngMsg, ev.Channel)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func egghandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Client) { |
|
|
|
|
|
|
|
// aka index:command:added
|
|
|
|
|
|
|
|
newType := fmt.Sprintf("index:lore:added") |
|
|
|
|
|
|
|
//command, err := botfunc.Query(newType, redisClient)
|
|
|
|
|
|
|
|
command, err := loreQuery(newType, redisClient) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
glogger.Error.Println(err) |
|
|
|
|
|
|
|
println(err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if the array is empty, exit early
|
|
|
|
|
|
|
|
if len(command) <= 0 { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// pick a random one
|
|
|
|
|
|
|
|
rand.Seed(time.Now().UnixNano()) |
|
|
|
|
|
|
|
rngLore := fmt.Sprint(command[rand.Intn(len(command))]) |
|
|
|
|
|
|
|
println(rngLore) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// set the lore in case we cant find it.
|
|
|
|
|
|
|
|
redisClient.Del("index:egg") |
|
|
|
|
|
|
|
err = redisClient.Set("index:egg", rngLore, 0).Err() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
glogger.Error.Println("error updating redis egg index") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rngMsg := fmt.Sprintf("begin the hunt boiiz...\n ```%s```", rngContent) |
|
|
|
|
|
|
|
rtm.SendMessage(rtm.NewOutgoingMessage(rngMsg, ev.Channel)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func giveuphandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Client) { |
|
|
|
|
|
|
|
giveup, err := redisClient.Get("index:egg").Result() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
glogger.Error.Println("error getting redis egg index") |
|
|
|
|
|
|
|
glogger.Error.Println(err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
giveupMsg := fmt.Sprintf("foolz.. it was `%s`", giveup) |
|
|
|
|
|
|
|
rtm.SendMessage(rtm.NewOutgoingMessage(giveupMsg, 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)) |
|
|
@ -534,6 +596,54 @@ func dubshandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Clie |
|
|
|
rollhandler(rtm, ev) |
|
|
|
rollhandler(rtm, ev) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func newlunchhandler(rtm *slack.RTM, ev *slack.MessageEvent, newContent string, redisClient *redis.Client) { |
|
|
|
|
|
|
|
// prep content for lunchification
|
|
|
|
|
|
|
|
// aka remove the '<' and '>' that slack adds
|
|
|
|
|
|
|
|
newContent = strings.Replace(newContent, "<", "", -1) |
|
|
|
|
|
|
|
newContent = strings.Replace(newContent, ">", "", -1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err := redisClient.SAdd("index:lunch", newContent) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
rtm.SendMessage(rtm.NewOutgoingMessage("lunch location added", ev.Channel)) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
rtm.SendMessage(rtm.NewOutgoingMessage("lunch location addition failed", ev.Channel)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func rmlunchhandler(rtm *slack.RTM, ev *slack.MessageEvent, rmContent string, redisClient *redis.Client) { |
|
|
|
|
|
|
|
// prep content for lunch removal
|
|
|
|
|
|
|
|
// aka remove the '<' and '>' that slack adds
|
|
|
|
|
|
|
|
rmContent = strings.Replace(rmContent, "<", "", -1) |
|
|
|
|
|
|
|
rmContent = strings.Replace(rmContent, ">", "", -1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err := redisClient.SRem("index:lunch", rmContent) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
rtm.SendMessage(rtm.NewOutgoingMessage("lunch location removed", ev.Channel)) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
rtm.SendMessage(rtm.NewOutgoingMessage("lunch location removal failed", ev.Channel)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func lunchhandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Client) { |
|
|
|
|
|
|
|
// aka index:command:added
|
|
|
|
|
|
|
|
newType := fmt.Sprintf("index:lunch") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
command, err := loreQuery(newType, redisClient) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
glogger.Error.Println(err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if the array is empty, exit early
|
|
|
|
|
|
|
|
if len(command) <= 0 { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// pick a random one
|
|
|
|
|
|
|
|
rand.Seed(time.Now().UnixNano()) |
|
|
|
|
|
|
|
rngDubs := fmt.Sprint(command[rand.Intn(len(command))]) |
|
|
|
|
|
|
|
rtm.SendMessage(rtm.NewOutgoingMessage(rngDubs, ev.Channel)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func rmhandler(rtm *slack.RTM, ev *slack.MessageEvent, message, rmType string, redisClient *redis.Client) { |
|
|
|
func rmhandler(rtm *slack.RTM, ev *slack.MessageEvent, message, rmType string, redisClient *redis.Client) { |
|
|
|
// get nick from slack api
|
|
|
|
// get nick from slack api
|
|
|
|
user, err := rtm.GetUserInfo(ev.User) |
|
|
|
user, err := rtm.GetUserInfo(ev.User) |
|
|
|