Browse Source

Fix links from slack

develop
Matthew Faltys 7 years ago
parent
commit
107b219219
  1. 4
      lorebot/botfunc.go
  2. 11
      lorebot/lorebot.go

4
lorebot/botfunc.go

@ -31,6 +31,8 @@ func loreCheck(searchTerm, searchType string, redisClient *redis.Client) (string
func loreNewString(nick, newString, newType string, redisClient *redis.Client) error {
s := strings.SplitN(newString, " ", 2)
command, content := s[0], []byte(s[1])
stripContent := strings.Replace(fmt.Sprintf("%s", content), "<", "", -1)
stripLinks := strings.Replace(stripContent, ">", "", -1)
t := time.Now()
@ -39,7 +41,7 @@ func loreNewString(nick, newString, newType string, redisClient *redis.Client) e
// create the redis hash
_, err := redisClient.HMSet(fmt.Sprintf("%s:%s", newType, command), map[string]string{
"content": string(content),
"content": stripLinks,
"cdate": cdate,
"owner": nick,
}).Result()

11
lorebot/lorebot.go

@ -320,11 +320,12 @@ 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, ";:,.'\"!$%^*()/\\") {
// reject user input, it has unwanted chars
rtm.SendMessage(rtm.NewOutgoingMessage("entry could not be created, unwanted characters", ev.Channel))
return
}
//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 {

Loading…
Cancel
Save