Last active
September 15, 2017 15:13
-
-
Save adityathebe/a73900625f873ac0dde356adab62cf32 to your computer and use it in GitHub Desktop.
Twitter Bot Tutorial Code - Aditya Thebe
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
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