Browse Source

Fix rmlore parsing wrong slack url

develop
Matthew Faltys 7 years ago
parent
commit
9bbdc048cc
  1. 17
      lorebot/lorebot.go

17
lorebot/lorebot.go

@ -11,6 +11,7 @@ import (
"net/http"
"net/textproto"
"os"
"regexp"
"strings"
"time"
@ -465,6 +466,11 @@ func newdubshandler(rtm *slack.RTM, ev *slack.MessageEvent, newContent string, r
}
func rmdubshandler(rtm *slack.RTM, ev *slack.MessageEvent, rmContent string, redisClient *redis.Client) {
// prep content for dubs removal
// aka remove the '<' and '>' that slack adds
rmContent = strings.Replace(rmContent, "<", "", -1)
rmContent = strings.Replace(rmContent, ">", "", -1)
err := redisClient.SRem("index:dubs", rmContent)
if err != nil {
rtm.SendMessage(rtm.NewOutgoingMessage("dubs unchecked", ev.Channel))
@ -484,13 +490,20 @@ func dubshandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Clie
// pick a random one
rand.Seed(time.Now().UnixNano())
rngDubs := fmt.Sprint(command[rand.Intn(len(command))])
// DEBUG
//println(rngDubs)
rtm.SendMessage(rtm.NewOutgoingMessage(rngDubs, ev.Channel))
// roll after we've proccessed dubs
// you already know tho..
re := regexp.MustCompile(`taylor|swift|2725225`)
if re.MatchString(rngDubs) {
rndInt := 1 + rand.Intn(10-1)
rndStr := fmt.Sprintf("%06d", rand.Int63n(1e6))
finStr := fmt.Sprintf("%s%d%d", rndStr, rndInt, rndInt)
rtm.SendMessage(rtm.NewOutgoingMessage(finStr, ev.Channel))
} else {
rollhandler(rtm, ev)
}
}
func rmhandler(rtm *slack.RTM, ev *slack.MessageEvent, message, rmType string, redisClient *redis.Client) {
// get nick from slack api

Loading…
Cancel
Save