I'm trying to code a script for Github's Hubot that uses TooTallNate's Node-Spotify-Web to play music through spotify, and I'm somewhat new to CoffeeScript (What Hubot scripts are written in). I wrote out the first command "Play" here:
lame = require('lame')
Speaker = require('speaker')
Spotify = require('spotify-web')
username = "INSERTUSERNAMEHERE"
password = "INSERTPASSWORDHERE"
robot.respond /play (.*)/i, (message) ->
uri = message.match[1]
Spotify.login(username, password, function (err, spotify)) {
if (err) throw err;
console.log('Playing: %s - %s', track.artist[0].name, track.name)
}
spotify.get(uri, function(err, track){
if err throw err;
message.send("Playing:" + track.artist[0].name, track.name)
})
Upon running bin/hubot I got the Error "Syntax Error, Reserved word "function" so I said, ok and changed 'function' to '->' as recommend in another StackOverflow question. Making it so it appeared as:
But still get the error
ERROR Unable to load /home/xbmc/cbot/lisa/scripts/spotify: SyntaxError: reserved word "function"
Is it because of the dependencies? I'm really stuck here.