简体   繁体   中英

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}"

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}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM