-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
56 lines (46 loc) · 1.1 KB
/
bot.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
console.log('bot is starting');
var Twit =require('twit');
var config = require('./config');
//config file contains all tokens and keys
var T = new Twit(config);
//get
/*
var params = {
q: 'akarshan16',
count: 100
}
T.get('search/tweets', params, gotData);
function gotData(err, data, response) {
var tweets = data.statuses;
for(var i = 0; i <tweets.length; i++) {
console.log(tweets[i].text);
console.log(tweets[i].created_at);
}
};
*/
//post
//tweetthetweet();
//setInterval(tweetthetweet, 10000000); calls the function after interval
function tweetthetweet(text) {
var tweet = {
status: text
}
T.post('statuses/update', tweet, postData);
function postData(err, data, response) {
if(err) {
console.log("something is wrong");
} else {
console.log("it worked!");
}
};
}
//stream
//setting up a usser stream
var stream = T.stream('user');
//anytime someone follows me
stream.on('follow', followed);
function followed(eventMsg) {
var name = eventMsg.source.name;
var screenName = eventMsg.source.screen_name;
tweetthetweet('.@' + screenName +' Thanks for following me!');
}