-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
34 lines (26 loc) · 766 Bytes
/
Copy pathserver.js
File metadata and controls
34 lines (26 loc) · 766 Bytes
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
const { createServer } = require('https');
const twit = require('twit');
const config = require('./config');
const bot = new twit(config.twitterKeys);
const retweet = require('./api/retweet');
const reply = require('./api/reply');
console.log('Starting...');
retweet();
setInterval(retweet, config.twitterConfig.retweet);
const userStream = bot.stream('user');
userStream.on('follow', reply);
const server = createServer((req, res) => {
res.writeHead(302, {
Location: `https://twitter.com/${config.twitterConfig.username}`
});
res.end();
});
const port = process.env.PORT || 3000;
if (!module.parent){
if (!port){
throw new Error('Forgot to specify PORT');
}
}
server.listen(port, () => {
console.log(`Listening on port ${port}...`);
});