0
因此Im試圖automaically檢索來自於一個單獨的node.js列出的陣列的隨機入口文件挑從外部陣列節點隨機條目
功能碼
var replies = require('./replies');
function followed(event) {
var name = event.source.name;
var flname = event.source.screen_name;
var myArray = [replies];
var item = myArray[(Math.random()*myArray.length)|0];
var followtweet = '@' + flname + item;
if(flname != "UserName") {
tweetIt(followtweet);
console.log('\[email protected]' + flname + ' Followed You');
console.log('\nYou Tweeted:\n ' + followtweet);
} else {
console.log(' Interferance From Another Bot! \n');
}
}
外部數組
module.exports = {
followedone: 'one',
followedtwo: 'two',
followedthre: 'three',
replyone: ' one',
replytwo: ' two',
replythre: ' three',
}
當我運行這個和函數運行我得到這個
@LandscapesLucid Followed You
You Tweeted:
@LandscapesLucid[object Object]
Waiting For The Next Action
我不知道爲什麼它只顯示代替的翻譯:無論是一個兩個或三個像陣列