Last active
December 8, 2016 07:36
-
-
Save amandeepmittal/1293895bad816dda43590a8f8e58e4ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Streams API for interacting with a USER ========== | |
// set up a user stream | |
var stream = Twitter.stream('user'); | |
// FOLLOW-Reply BOT =========================== | |
// when someone follows | |
stream.on('follow', followed); | |
// ...trigger the callback | |
function followed(event) { | |
console.log('Follow Event is running'); | |
//get their twitter handler (screen name) | |
var | |
name = event.source.name, | |
screenName = event.source.screen_name; | |
// function that replies back to the user who followed | |
tweetNow('@' + screenName + ' Thank you for the follow up.'); | |
} | |
// function definition to tweet back to user who followed | |
function tweetNow(tweetTxt) { | |
var tweet = { | |
status: tweetTxt | |
} | |
Twitter.post('statuses/update', tweet, function(err, data, response) { | |
if(err){ | |
console.log("Error in Replying"); | |
} | |
else{ | |
console.log("Gratitude shown successfully"); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment