diff --git a/lorebot/lorebot.go b/lorebot/lorebot.go index 4066225..81b082b 100644 --- a/lorebot/lorebot.go +++ b/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,12 +490,19 @@ 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 - rollhandler(rtm, ev) + // 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) {