-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
42 lines (28 loc) · 768 Bytes
/
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
var Twit = require('twit');
var config = require('./config');
var T = new Twit(config);
//listen to a user stream to see
//if somone follows you on twiter
//and the bot posts back a reply to them
//thanking them for following you.
var stream = T.stream('user');
stream.on('follow',followed);
function followed(eventMsg) {
var name = eventMsg.source.name;
var screenName = eventMsg.source.screen_name;
tweetIt('@'+screenName+' Thank you for following me.Do you like unicorns?');
}
function tweetIt(txt) {
var tweet = {
status: txt
};
T.post('statuses/update', tweet, tweeted);
function tweeted(err,data,response){
if(err){
console.log("something went wrong..");
}
else {
console.log("Hey it worked from a stream bot....");
}
}
}