Skip to content

Commit

Permalink
Workaround for robot undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
cycomachead committed Feb 14, 2017
1 parent ff70473 commit 0043ff4
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/alias.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ getGroups = (robot, text) ->
groupMap[group] = users
matches = regex.exec(text)
for own group, members of groupMap
list = _.map(members, userFromName)
list = _.map(members, userFromName(robot))
list = _.map(list, mentionName)
groupMap[group] = listToMentions(list)
return groupMap
Expand All @@ -71,12 +71,15 @@ getGroupsList = (robot) ->
else
return Object.keys(buildGroupObject())

userFromName = (name) ->
allUsers = robot.brain.data.users
for own id, user of allUsers
if user.name == name
return user
return {}
# Returns a function that lets this be used inside _.map
# TODO: This closure isn't totally necessary... bleh.
userFromName = (robot) ->
return (name) ->
allUsers = robot.brain.data.users
for own id, user of allUsers
if user.name == name
return user
return {}

mentionName = (user) ->
# mention_name is for Hipchat
Expand Down

0 comments on commit 0043ff4

Please sign in to comment.