-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.js
More file actions
29 lines (26 loc) · 1007 Bytes
/
app.js
File metadata and controls
29 lines (26 loc) · 1007 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
var TwitterPackage = require('twitter');
var BookingListener = require('./models/SocietyBookingListener.js');
var secret = require("./secret")
var Twitter = new TwitterPackage(secret)
Twitter.stream('statuses/filter', {track: '@UCLSocBot'}, function(stream) {
stream.on('data', function(tweet) {
// console.log(tweet.text);
if (tweet.text.includes("#societybookings")) {
bookingReply = BookingListener.reply(tweet);
bookObj = {status: bookingReply}
Twitter.post('statuses/update', bookObj, function(error, tweetReply, response){
console.log(tweetReply)
});
} else {
Twitter.post('statuses/update', {status: "@" + tweet.user.screen_name + ". Tweet to us with #societybookings and the name of your society to learn its next booking."}, function(error, tweet, response){
if(error){
console.log(error);
}
console.log(tweet);
});
}
});
stream.on('error', function(error) {
console.log(error);
});
});