Skip to content

Instantly share code, notes, and snippets.

@adityathebe
Last active September 15, 2017 15:13
Show Gist options
  • Save adityathebe/a73900625f873ac0dde356adab62cf32 to your computer and use it in GitHub Desktop.
Save adityathebe/a73900625f873ac0dde356adab62cf32 to your computer and use it in GitHub Desktop.
Twitter Bot Tutorial Code - Aditya Thebe
const TWIT = require('twit')
const config = require('./config');
var Twit = new TWIT(config);
function makeTweet(tweet) {
Twit.post('statuses/update', { status: tweet }, function(err, data, response) {
if(err) {
console.log(err)
} else {
console.log("Tweet Made Successfully")
}
});
};
// setInterval(makeTweet, 60 * 1000, Math.random() * 20)
function trackTweet(keyword) {
let stream = Twit.stream('statuses/filter', {track: keyword})
stream.on('tweet', function (tweet) {
console.log(tweet.text)
});
}
trackTweet('trump');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment