Skip to content

Instantly share code, notes, and snippets.

@amandeepmittal
Last active December 8, 2016 07:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amandeepmittal/1293895bad816dda43590a8f8e58e4ed to your computer and use it in GitHub Desktop.
Save amandeepmittal/1293895bad816dda43590a8f8e58e4ed to your computer and use it in GitHub Desktop.
// 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