diff --git a/lorebot/lorebot.go b/lorebot/lorebot.go index 4d4c465..472dd22 100644 --- a/lorebot/lorebot.go +++ b/lorebot/lorebot.go @@ -136,16 +136,6 @@ func initRedisConnection() (*redis.Client, error) { } func dynamicCommandHandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Client) { - //nick := ev.User - //fmt.Printf("%s", ev.User) - user, err := rtm.GetUserInfo(ev.User) - if err != nil { - fmt.Printf("%s\n", err) - return - } - println(user.Name) - nick := fmt.Sprintf("%s", user.Name) - message := ev.Text if strings.Count(message, " ") < 1 { glogger.Debug.Println("not proper syntax") @@ -166,7 +156,7 @@ func dynamicCommandHandler(rtm *slack.RTM, ev *slack.MessageEvent, redisClient * rtm.SendMessage(rtm.NewOutgoingMessage("not proper syntax", ev.Channel)) return } - newhandler(rtm, ev, nick, content, "lore", redisClient) + newhandler(rtm, ev, content, "lore", redisClient) case "rmlore": rtm.SendMessage(rtm.NewOutgoingMessage("command not yet supported", ev.Channel)) case "rek": @@ -388,8 +378,16 @@ func lorestatus(rtm *slack.RTM, ev *slack.MessageEvent, redisClient *redis.Clien rtm.SendMessage(rtm.NewOutgoingMessage(status, ev.Channel)) } -func newhandler(rtm *slack.RTM, ev *slack.MessageEvent, nick, message, newType string, redisClient *redis.Client) { - err := loreNewString(nick, message, newType, redisClient) +func newhandler(rtm *slack.RTM, ev *slack.MessageEvent, message, newType string, redisClient *redis.Client) { + // get nick from slack api + user, err := rtm.GetUserInfo(ev.User) + if err != nil { + fmt.Printf("%s\n", err) + return + } + nick := fmt.Sprintf("%s", user.Name) + + err = loreNewString(nick, message, newType, redisClient) if err == nil { rtm.SendMessage(rtm.NewOutgoingMessage("entry created", ev.Channel)) } else {