From c43acfc250798e6f84007c70316902ccbcb72a79 Mon Sep 17 00:00:00 2001 From: Matthew Faltys Date: Thu, 7 Sep 2017 13:53:02 -0500 Subject: [PATCH] Add unwanted character parsing --- lorebot/lorebot.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lorebot/lorebot.go b/lorebot/lorebot.go index 420f3bd..7a9f92c 100644 --- a/lorebot/lorebot.go +++ b/lorebot/lorebot.go @@ -156,11 +156,11 @@ func dynamicCommandHandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient * contenthandler(rtm, ev, s[1], "lore", redisClient) case "newlore": if strings.Contains(content, " ") { + newhandler(rtm, ev, content, "lore", redisClient) } else { rtm.SendMessage(rtm.NewOutgoingMessage("not proper syntax", ev.Channel)) return } - newhandler(rtm, ev, content, "lore", redisClient) case "rmlore": rmhandler(rtm, ev, content, "lore", redisClient) case "rek": @@ -319,6 +319,14 @@ func lorestatus(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Clien } func newhandler(rtm *slack.RTM, ev *slack.MessageEvent, message, newType string, redisClient *redis.Client) { + // dont allow certain chars + //if strings.ContainsAny(message, ";:.,'\"\\/!$&^\(\)") { + println(message) + if strings.ContainsAny(message, ";:,.'\"!$%^*()/\\") { + // reject user input, it has unwanted chars + rtm.SendMessage(rtm.NewOutgoingMessage("entry could not be created, unwanted characters", ev.Channel)) + return + } // get nick from slack api user, err := rtm.GetUserInfo(ev.User) if err != nil {