我正在尝试为hubot编写脚本,似乎我有一个未关闭的字符串。内容将以html格式显示,表情符号如下:smile:等。它不是在Cofeescript中编译。我是javascript的新手,任何帮助都将不胜感激。
我得到的错误是
ERROR Unable to load /var/discourse/avebot/scripts/test: /var/discourse/avebot/scripts/test.js:5
msg.reply("Hello! I’m Avebot, and I will be your guide throughout your training. :smile: <br>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Invalid or unexpected token
at new Script (vm.js:51:7)
,脚本是:
robot.hear(/hi bot/, function(msg) {
msg.reply("Hello! I’m a bot, and I will be your guide your training. :smile: <br>
<br>After finishing this training, you will be able to do x y z. :tada:<br>
Are you ready? If so, let me know you are ready by replying 'yes I’m ready!'");
//Start a dialog with the user that sent this message.
var dialog = switchBoard.startDialog(msg);
//Provide choices for the next step, wait for the user.
dialog.addChoice(/yes/, function(msg2){ msg2.reply('Okay');}
dialog.addChoice( /no/, function(msg2){ msg2.reply("Okay, I'll wait"); }
//The dialog will expire after 30 secods.
});
答案 0 :(得分:0)
你需要通过在撇号之前放一个反斜杠来逃避'
中的I'm Avebot
(所以它是I\'m Avebot
)。
在此处查看this网站,了解有关JS转义序列的更多信息。
答案 1 :(得分:0)
为了在Javascript中定义多行字符串,您可以在新行之前使用反斜杠FIRAuthErrorCodeUserTokenExpired
\