Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Commit 46e6478

Browse files
committed
Update calls of the user* functions
that were moved from Robot to Brain by hubotio/hubot@ae9e939
1 parent a8506fc commit 46e6478

14 files changed

+20
-20
lines changed

src/scripts/ambush.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = (robot) ->
2424
robot.brain.data.ambushes ||= {}
2525

2626
robot.respond /ambush (.*): (.*)/i, (msg) ->
27-
users = robot.usersForFuzzyName(msg.match[1].trim())
27+
users = robot.brain.usersForFuzzyName(msg.match[1].trim())
2828
if users.length is 1
2929
user = users[0]
3030
appendAmbush(robot.brain.data.ambushes, user, msg.message.user, msg.match[2])

src/scripts/auth.coffee

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = (robot) ->
2929

3030
class Auth
3131
hasRole: (name, role) ->
32-
user = robot.userForName(name)
32+
user = robot.brain.userForName(name)
3333
if user? and user.roles?
3434
if role in user.roles then return true
3535

@@ -42,7 +42,7 @@ module.exports = (robot) ->
4242
newRole = msg.match[3].trim().toLowerCase()
4343

4444
unless name.toLowerCase() in ['', 'who', 'what', 'where', 'when', 'why']
45-
user = robot.userForName(name)
45+
user = robot.brain.userForName(name)
4646
user.roles = user.roles or [ ]
4747

4848
if newRole in user.roles
@@ -61,7 +61,7 @@ module.exports = (robot) ->
6161
newRole = msg.match[3].trim().toLowerCase()
6262

6363
unless name.toLowerCase() in ['', 'who', 'what', 'where', 'when', 'why']
64-
user = robot.userForName(name)
64+
user = robot.brain.userForName(name)
6565
user.roles = user.roles or [ ]
6666
if newRole == 'admin'
6767
msg.reply "Sorry, the 'admin' role can only be removed from the HUBOT_AUTH_ADMIN env variable."
@@ -74,7 +74,7 @@ module.exports = (robot) ->
7474
robot.respond /(what role does|what roles does) @?([\w .-]+) (have)\?*$/i, (msg) ->
7575
name = msg.match[2].trim()
7676

77-
user = robot.userForName(name)
77+
user = robot.brain.userForName(name)
7878
user.roles = user.roles or [ ]
7979

8080
if name.toLowerCase() in admin.toLowerCase().split(',') then isAdmin = ' and is also an admin' else isAdmin = ''

src/scripts/availability.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = (robot) ->
1515
# Returns a user object if a single user is found, an array of users if more
1616
# than one user matched the name or false if no user is found.
1717
findUser = (name) ->
18-
users = robot.usersForFuzzyName name
18+
users = robot.brain.usersForFuzzyName name
1919
if users.length is 1
2020
users[0]
2121
else if users.length > 1

src/scripts/github-credentials.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = (robot) ->
2222
robot.respond /who do you know(\?)?$/i, (msg) ->
2323
theReply = "Here is who I know:\n"
2424

25-
for own key, user of robot.brain.data.users
25+
for own key, user of robot.brain.users
2626
if(user.githubLogin)
2727
theReply += user.name + " is " + user.githubLogin + "\n"
2828

src/scripts/harvest.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ check_user = (robot, msg, test_user = null) ->
8686
# Detect the user; if none is passed, assume the sender.
8787
user = null
8888
if test_user
89-
user = robot.userForName(test_user)
89+
user = robot.brain.userForName(test_user)
9090
unless user
9191
msg.reply "#{msg.match[2]}? Whoʼs that?"
9292
return null

src/scripts/http-post-say.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = (robot) ->
2929

3030
robot.logger.info "Message '#{message}' received for room #{room}"
3131

32-
user = robot.adapter.userForId 'broadcast'
32+
user = robot.brain.userForId 'broadcast'
3333
user.room = room
3434
user.type = 'groupchat'
3535

src/scripts/notify.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ module.exports = (robot) ->
129129
return
130130

131131

132-
for userId, user of robot.brain.data.users
132+
for userId, user of robot.brain.users
133133
if user.mention_name==mentionedUserName
134134
username=user.name
135135
mentionedUserId = userId

src/scripts/octospy.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ module.exports = (robot) ->
356356
message = '[octospy] ' + renderTemplate(event,context)
357357

358358
# Tell the people who care
359-
listeners = (robot.userForId(id) for id in (robot.brain.data.octospy[github_url]?[repo_name][event] || []))
359+
listeners = (robot.brain.userForId(id) for id in (robot.brain.data.octospy[github_url]?[repo_name][event] || []))
360360

361361
# group rooms together, so we don't spam with multiple people with subs
362362
for room, users of _.groupBy(listeners, 'room') when room

src/scripts/status.coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module.exports = (robot) ->
4646
if !msg.match[3]?
4747
hb_status.remove_status msg.message.user.name
4848
msg.send msg.message.user.name + " has no more status."
49-
else if (_.any (_.values _.pluck robot.brain.data.users, 'name'), (val) -> return val.toLowerCase() == msg.match[3].toLowerCase())
49+
else if (_.any (_.values _.pluck robot.brain.users, 'name'), (val) -> return val.toLowerCase() == msg.match[3].toLowerCase())
5050
if hb_status.statuses_[msg.match[2].toLowerCase()]?
5151
msg.send msg.match[3] + "'s status: " + hb_status.statuses_[msg.match[3].toLowerCase()]
5252
else
@@ -86,4 +86,4 @@ class Status
8686
delete @statuses_[name.toLowerCase()]
8787

8888
update_away: (name, message) ->
89-
@aways_[name.toLowerCase()] = message
89+
@aways_[name.toLowerCase()] = message

src/scripts/team-city-listener.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ unless room
2828
throw "Need a room to send build status messages to once we receive the web hook call"
2929
module.exports = (robot)->
3030
robot.router.post "/hubot/build/", (req, res)->
31-
user = robot.userForId 'broadcast'
31+
user = robot.brain.userForId 'broadcast'
3232
user.room = room
3333
user.type = 'groupchat'
3434
build = req.body.build

src/scripts/whos-turn.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
module.exports = (robot) ->
1717
robot.respond /(who|qui) (.+)\?/i, (msg) ->
1818
users = []
19-
for own key, user of robot.brain.data.users
19+
for own key, user of robot.brain.users
2020
users.push "#{user.name}" if "#{user.name}" != robot.name
2121
msg.send (msg.random users).split(" ")[0] + " " + msg.match[2] + "!"

src/scripts/working-on.coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = (robot) ->
1919

2020
robot.respond /(what\'s|what is) (everyone|everybody) working on(\?)?/i, (msg) ->
2121
messageText = '';
22-
users = robot.users()
22+
users = robot.brain.users()
2323
for k, u of users
2424
if u.workingon
2525
messageText += "#{u.name} is working on #{u.workingon}\n"
@@ -31,7 +31,7 @@ module.exports = (robot) ->
3131

3232
robot.respond /(i\'m|i am) working on (.*)/i, (msg) ->
3333
name = msg.message.user.name
34-
user = robot.userForName name
34+
user = robot.brain.userForName name
3535

3636
if typeof user is 'object'
3737
user.workingon = msg.match[2]

src/scripts/wunderlist.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports = (robot) ->
3333
robot.respond /wunderlist all the users/i, (msg) ->
3434
theReply = "Here is who I know:\n"
3535

36-
for own key, user of robot.brain.data.users
36+
for own key, user of robot.brain.users
3737
if(user.wunderlistmail)
3838
theReply += user.name + " is " + user.wunderlistmail + "\n"
3939

src/scripts/yell.coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ module.exports = (robot) ->
2121
_ = require 'underscore'
2222

2323
robot.respond /yell (.*)/i, (msg) ->
24-
users = _.reject((_.values _.pluck robot.brain.data.users, 'name'), (name) -> name == msg.message.user.name)
24+
users = _.reject((_.values _.pluck robot.brain.users, 'name'), (name) -> name == msg.message.user.name)
2525
msg.send if users.length then users.join(', ') + ": #{msg.match[1]}" else "If a tree falls in a forest and no one is around to hear it, does it make a sound?"
2626

2727

2828
toTitleCase = (str) ->
29-
str.replace /\w\S*/g, (txt) -> txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()
29+
str.replace /\w\S*/g, (txt) -> txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()

0 commit comments

Comments
 (0)