-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (37 loc) · 1.02 KB
/
index.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
42
43
44
//twitter lib
const Twit = require("twit");
//config file
const twit = new Twit(require("./config.js"));
const handleSearch = {
q: "@KolkataCOVIDbot",
count: 50,
result_type: "recent",
};
const retweetLatest = () => {
twit.get("search/tweets", handleSearch, (error, data) => {
console.log(error, data);
if (!error) {
let retweetId = data.statuses[0].id_str;
twit.post("statuses/retweet/" + retweetId, {}, (error, response) => {
if (response) {
console.log("Success, your bot should have rt-ed something!");
}
if (error) {
console.log("There was an error with twitter: ", error);
}
});
} else {
console.log("There was an error with your hashtag search: ", error);
}
});
};
retweetLatest();
// in milisecs; 1000 ms = 1 second, 1 sec * 60 = 1 min
setInterval(retweetLatest, 1000 * 60 * 1);
//server
const http = require("http");
const server = http.createServer((req, res) => {
res.writeHead(200);
res.end("ok");
});
server.listen(3000);