-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.js
76 lines (53 loc) · 1.69 KB
/
app.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
67
var http = require("http");
var Twit = require('twit')
var Spark = require("spark");
var dotenv = require('dotenv');
dotenv.load();
Spark.login({ username: process.env.USER_NAME, password: process.env.PASS_WORD }, function(err, body) {
//to handle
});
//var server = http.createServer(function(request, response) {
var T = new Twit({
consumer_key: process.env.CONSUMER_KEY
, consumer_secret: process.env.CONSUMER_SECRET
, access_token: process.env.ACCESS_TOKEN
, access_token_secret: process.env.ACCESS_TOKEN_SECRET
})
var stream = T.stream('user')
stream.on('connect',function(){
console.log("connected");
})
stream.on('disconnect',function(){
console.log("disconnected");
})
stream.on('favorite', function (tweet) {
Spark.callFunction(process.env.SPARK_ID,'setMode','3',function(err,data){
console.log("favorite called?");
});
})
stream.on('follow', function (tweet) {
console.log('HAS BEEN FOLLOWED',tweet)
if(tweet['target']['screen_name'] == "bitchwhocodes"){
Spark.callFunction(process.env.SPARK_ID,'setMode','4',function(err,data){
console.log("followed");
});
}
})
stream.on('unfollow', function (tweet) {
if(tweet['target']['screen_name'] == "bitchwhocodes"){
Spark.callFunction(process.env.SPARK_ID,'setMode','5',function(err,data){
console.log("unfollowed");
});
}
})
stream.on('list_member_added', function (tweet) {
Spark.callFunction(process.env.SPARK_ID,'setMode','6',function(err,data){
console.log("added to a list");
});
})
stream.on('tweet', function (tweet) {
if(tweet['retweeted_status']!=null){
Spark.callFunction(process.env.SPARK_ID,'setMode','7',function(err,data){
});
}
})