Unable to get username in Hubot

I can’t do this job, I’m just trying to print the username of the just entered

robot.enter (msg) -> msg.send "#{msg.user.name}" 
+6
source share
1 answer

I would suggest that you are not looking at anything. The Hubot script interface is not well documented, but notify.coffee in the examples says the following:

 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}" 
+21
source

Source: https://habr.com/ru/post/907971/


All Articles