Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't retrieve username of user in Hubot

I can't seem to make this work, I'm just trying to print out the username of people who've just entered

robot.enter (msg) ->
   msg.send "#{msg.user.name}"
like image 600
lemon Avatar asked Feb 08 '12 17:02

lemon


1 Answers

I'd guess that you're looking at the wrong thing. The Hubot scripting interface isn't exactly documented but notify.coffee in the examples says this:

module.exports = (robot) ->
  robot.hear /@(\w+)/i, (msg) ->
    sender   = msg.message.user.name.toLowerCase()
    #...

So you probably want to look at msg.message instead of msg:

robot.enter (msg) ->
   msg.send "#{msg.message.user.name}"
like image 112
mu is too short Avatar answered Nov 15 '22 22:11

mu is too short