Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging/printing in a Hubot script

Tags:

node.js

hubot

I'm trying to debug an existing Hubot script and in the future write my own, and I need an easy way to debug it or at least print values somewhere (but not to the channel). How can I do so?

Bonus points if this can be done with just using Node in some interactive local mode. I'm really not sure where to start.

All scripts Hubot uses are written in Coffeescript.

P.S. I'm using Hubot with Hipchat.

like image 558
Artem Russakovskii Avatar asked Jun 12 '12 05:06

Artem Russakovskii


2 Answers

I don't know if this helps but I found a way to inspect objects.

Util = require "util"

module.exports = (robot) ->
  robot.hear /hi robot/i, (msg) ->
    user = robot.brain.usersForFuzzyName(msg.message.user.name)
    msg.send "#{Util.inspect(user)}"

This allowed be to see all the elements of the object so I could figure out what I was doing wrong...

like image 120
radixhound Avatar answered Oct 13 '22 11:10

radixhound


I have discovered the answer myself: console.log MSG in a .coffee Coffeescript source does exactly what I needed.

like image 23
Artem Russakovskii Avatar answered Oct 13 '22 10:10

Artem Russakovskii