-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
66 lines (61 loc) · 1.69 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const Twit = require("twit");
const dotenv = require("dotenv");
var schedule = require("node-schedule");
dotenv.config();
const {
APPLICATION_CONSUMER_KEY,
APPLICATION_CONSUMER_SECRET,
ACCESS_TOKEN,
ACCESS_TOKEN_SECRET,
} = process.env;
const T = new Twit({
consumer_key: APPLICATION_CONSUMER_KEY,
consumer_secret: APPLICATION_CONSUMER_SECRET,
access_token: ACCESS_TOKEN,
access_token_secret: ACCESS_TOKEN_SECRET,
});
function retweet() {
let params = {
q: `#dailyInspiration OR #100DaysOfCode`,
count: 15,
};
T.get("search/tweets", params, (err, data, response) => {
let tweets = data.statuses;
if (!err) {
for (let dat of tweets) {
let retweetId = dat.id_str;
T.post("statuses/retweet/:id", { id: retweetId }, (err, response) => {
if (response) console.log("Retweeted! " + retweetId);
if (err) console.log("Something went wrong! Maybe a duplicate.");
});
}
}
});
}
setInterval(retweet, 10000);
schedule.scheduleJob("0 0 0 13 8 *", function () {
T.post(
"statuses/update",
{
status:
"Today is the birthday of my creator @victorkarangwa4 \n Help me to wish him HAPPY BIRTHDAY 🥳🙌🎂🍰",
},
function (err, data, response) {
if (response) console.log("Tweeted! " + data);
if (err) console.log(err);
}
);
});
schedule.scheduleJob("0 0 0 1 10 *", function () {
T.post(
"statuses/update",
{
status:
"May all that you do in this new month be productive and successful. Happy New Month to you all!",
},
function (err, data, response) {
if (response) console.log("Tweeted! " + data);
if (err) console.log(err);
}
);
});