-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreplier.js
35 lines (29 loc) · 815 Bytes
/
replier.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
var Twitter = require('./twitter');
var _ = require('lodash');
function processTweet(tweet) {
if (tweet.user.screen_name == 'yoazt') {
return
}
console.log('Incoming tweet: ' + tweet);
if (tweet.text.indexOf('@yoazt') == -1) {
console.log('=> (not a mention)');
return;
}
postReply(tweet);
}
function postReply(tweet) {
var replyText = "Hoi en leuk dat je @yoazt mentiont, maar inmiddels heet ik @joostlubach. Groetjes!"
var reply = {
status: '@' + tweet.user.screen_name + ' ' + replyText,
in_reply_to_status_id: tweet.id_str
};
Twitter.post('statuses/update', reply, function (error, data) {
if (error) {
console.log(error);
}
});
}
var stream = Twitter.stream('user', {with: 'user'});
stream.on('tweet', function (tweet) {
processTweet(tweet);
});