Help with a Hubot script?

78 views
Skip to first unread message

sapg

unread,
Feb 6, 2014, 5:56:47 PM2/6/14
to nod...@googlegroups.com

Hello all,

I'm trying to wrote a hubot script that will use the API at http://www.macvendorlookup.com to give me information on a Vendor for a MAC.  My script is over at https://github.com/sapg/hubot-scripts/blob/master/mac-lookup.coffee

I'm not sure how to get what I want in the format I want in the chat.  The most frustrating thing is that it appears exactly the way I want it on the console.

In the console -

Hubot> hubot mac 00:1d:e0:64:82:75
Hubot> [ 'hubot mac 00:1d:e0:64:82:75',
  '00:1d:e0:64:82:75',
  index: 0,
  input: 'hubot mac 00:1d:e0:64:82:75' ]
[Thu Feb 06 2014 22:44:41 GMT+0000 (GMT)] WARNING @http() is going to be deprecated in 3.0.0 use @robot.http()
[ { starthex: '001DE0000000',
    endhex: '001DE0FFFFFF',
    startdec: '128312147968',
    enddec: '128328925183',
    company: 'Intel Corporate',
    department: 'Lot 8, Jalan Hi-Tech 2/3',
    address1: 'Kulim Hi-Tech Park',
    address2: 'Kulim Kedah 09000',
    country: 'MALAYSIA',
    db: 'oui24' } ]

In the chat -

[{"starthex":"001DE0000000","endhex":"001DE0FFFFFF","startdec":"128312147968","enddec":"128328925183","company":"Intel Corporate","department":"Lot 8, Jalan Hi-Tech 2\/3","address1":"Kulim Hi-Tech Park","address2":"Kulim Kedah 09000","country":"MALAYSIA","db":"oui24"}]
Hubot>    company: undefined
           department: undefined
           address1: undefined
           address2: undefined
           country: undefined
 
Hubot> Er, couldn't find the vendor for that MAC

I'm confused, can anyone help?

Thanks.

Stanley Stuart

unread,
Feb 6, 2014, 6:09:17 PM2/6/14
to nod...@googlegroups.com
Your json is returning an array, so to get to the first object in the array, you'd need to do json = json[0]


--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
 
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Sapan Ganguly

unread,
Feb 6, 2014, 7:54:00 PM2/6/14
to nod...@googlegroups.com
Hi, thanks for the reply.  If I do something like this -

  msg.send "#{json[0]}"

I get this in the chat

  [object Object]

What am I missing?


You received this message because you are subscribed to a topic in the Google Groups "nodejs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodejs/E4IU3b4l5_s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.

Alex Kocharin

unread,
Feb 6, 2014, 7:59:05 PM2/6/14
to nod...@googlegroups.com
 
json[0] is an object, not a string
 
maybe `msg.send "#{require('util').inspect(json[0])}"` ?
 
 
07.02.2014, 04:54, "Sapan Ganguly" <sapan....@gmail.com>:

Sapan Ganguly

unread,
Feb 7, 2014, 4:32:22 PM2/7/14
to nod...@googlegroups.com
Excellent, thanks Alex, that works.
Reply all
Reply to author
Forward
0 new messages