-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbot.js
29 lines (23 loc) · 779 Bytes
/
bot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/** Log 'The bot is starting' to the console. */
console.log('The bot is starting');
/** Import the twit module. */
var Twit = require('twit');
/** Authenticate by importing the `config.js` file with the API keys. */
var config = require('./config');
/** Object that connects to Twitter. */
var T = new Twit(config);
/** Search for 2 tweets with the word 'atmosphere'. */
var params = {
q: 'atmosphere',
count: 2
}
/** Trigger the get and search Twitter for Tweets. */
T.get('search/tweets', params, gotData);
/** Function that will be triggered when the data has been returned from the API. */
function gotData(err, data, response) {
var tweets = data.statuses;
for (var i = 0; i < tweets.length; i++) {
console.log(tweets[i].text);
}
console.log(data);
}