我正在尝试为 Github 的 Hubot 编写一个脚本,该脚本使用 TooTallNate 的 Node-Spotify-Web 通过 spotify 播放音乐,而且我对 CoffeeScript 有点陌生(Hubot 脚本是用什么编写的)。我在这里写出了第一个命令“播放”:
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)
})
在运行 bin/hubot 时,我收到错误“语法错误,保留字”“功能”,所以我说,好的,并将“功能”更改为“->”,正如另一个 StackOverflow 问题中的建议。使它看起来像:
但仍然得到错误
错误无法加载/home/xbmc/cbot/lisa/scripts/spotify:语法错误:保留字“函数”
是因为依赖吗?我真的被困在这里了。