Browse Source

Add unwanted character parsing

develop
Matthew Faltys 7 years ago
parent
commit
c43acfc250
  1. 10
      lorebot/lorebot.go

10
lorebot/lorebot.go

@ -156,11 +156,11 @@ func dynamicCommandHandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *
contenthandler(rtm, ev, s[1], "lore", redisClient) contenthandler(rtm, ev, s[1], "lore", redisClient)
case "newlore": case "newlore":
if strings.Contains(content, " ") { if strings.Contains(content, " ") {
newhandler(rtm, ev, content, "lore", redisClient)
} else { } else {
rtm.SendMessage(rtm.NewOutgoingMessage("not proper syntax", ev.Channel)) rtm.SendMessage(rtm.NewOutgoingMessage("not proper syntax", ev.Channel))
return return
} }
newhandler(rtm, ev, content, "lore", redisClient)
case "rmlore": case "rmlore":
rmhandler(rtm, ev, content, "lore", redisClient) rmhandler(rtm, ev, content, "lore", redisClient)
case "rek": 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) { 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 // get nick from slack api
user, err := rtm.GetUserInfo(ev.User) user, err := rtm.GetUserInfo(ev.User)
if err != nil { if err != nil {

Loading…
Cancel
Save