無法在Hubot中檢索用戶的用戶名

[英]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}"

1 个解决方案

#1


22  

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:

我猜你在看錯了。 Hubot腳本編寫接口並未完全記錄,但示例中的notify.coffee說明了這一點:

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:

所以你可能想看一下msg.message而不是msg:

robot.enter (msg) ->
   msg.send "#{msg.message.user.name}"

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2012/02/08/729edd43965665e0eb255da86bec2e17.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com