-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
41 lines (37 loc) · 1.2 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
"use strict"
const Twit = require('twit');
const config = require('./config.js');
const dateTime = require('node-datetime');
const Twitter = new Twit(config);
const params = {
q: '#RCB',
result_type: 'recent',
lang: 'en'
}
let noOfTweets = 0;
function retweet() {
Twitter.get('search/tweets', params, function (error, data) {
if (!error) {
const tweets = data.statuses[0].id_str;
const dt = dateTime.create();
const format = dt.format('Y-m-d H:M:S');
if(data.statuses[0].retweet_count>=10) {
Twitter.post('statuses/retweet', { id: tweets }, function (error, data) {
if (!error) {
noOfTweets++;
console.log("Retweet successful on " + format);
console.log("Total number of tweets = " + noOfTweets);
} else {
console.error(error + " at " + format);
}
})
} else {
console.log('Bad tweet')
}
} else {
console.error("ERROR:", error);
}
})
}
retweet();
setInterval(retweet, 90000*5);