-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
39 lines (35 loc) · 835 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
30
31
32
33
34
35
36
37
38
39
const config = require("./config");
const twit = require("twit");
const T = new twit(config);
let params = {
q: "#javascript OR #vuejs OR #Vue OR #reactjs",
count: 10,
recent_type: "recent",
};
function retweet() {
searchTweets(params);
}
setInterval(retweet, 120000);
function searchTweets(params) {
T.get("search/tweets", params, (err, data, response) => {
let tweets = data.statuses;
if (!err) {
for (let dat of tweets) {
let retweetId = dat.id_str;
postTweet(retweetId);
}
}
});
}
function postTweet(retweetId) {
T.post("/statuses/retweet/:id", { id: retweetId }, (err, response) => {
if (response) {
console.log("Retweeted!!!");
}
if (err) {
console.log(
"Something went wrong while retweeting. Duplication maybe..."
);
}
});
}