bot.on('message', (msg) => {
var dancy_link = "dancy link";
if (msg.text.toString().toLowerCase().indexOf(dancy_link) === 0) {
bot.sendMessage(msg.chat.id, "Dancy link is here, " + msg.from.first_name + ". Enjoy!" + dancy_collection[rand_dancy_collection()], {
"reply_markup": {
"keyboard": [["More dancy links"], ["Back to choose link style"]],
"resize_keyboard": true
}
});
var date = new Date();
//console.log(msg.from.first_name, msg.from.last_name + " wants dancy link at", date.getHours(), ":", date.getMinutes());
var name7 = msg.from.first_name + msg.from.last_name + "wants dancy link at";
var str7 = name7 + date.getHours() + ":" + date.getMinutes() + os.EOL;
fs.appendFile("/root/log.txt", str7, function (err) {
if (err) {
return console.log(err);
}
console.log("The file was saved!");
});
}
})
那是我的node.js电报机器人。
一开始,我有var fs = require('fs');
来操作文件系统。
但是,我无法将行追加到log.txt上,但没有准确的描述,但会出现轮询错误。我也看不到console.log内部的appendFile函数。我究竟做错了什么?
http://prntscr.com/k3mhyn-错误的样子...