Inspiration

MLH-LHD

What it does

It automatically prints a random number every 1 hour which some cool hashtag and some text

How we built it

We build it using node.js and Twit package First

npm install twit

well all the packages are install make index.js and config.js In config.js we will write -

module.exports={

        consumer_key:         'API_KEY',
        consumer_secret:      'API_KEY_SECRET',
        access_token:         'ACCESS_TOKEN',
        access_token_secret:  'ACCESS_TOKEN_SECRET',
        timeout_ms:           60*1000,  // optional HTTP request timeout to apply to all requests.
        strictSSL:            true,     // optional - requires SSL certificates to be valid.

}

Then we right some basic code-

console.log("Bot is starting");

var Twit = require('twit');
var config = require('./config');

var T = new Twit(config);

// var params ={
//     q: 'rainbow', 
//     count: 5
// }

// T.get('search/tweets', params, gotData);
//  function gotData(err, data, response) {
//      var tweets = data.statuses;
//      for(var i=0; i<tweets.length; i++)
//     console.log(tweets[i].text);
//   }

TweetIt();
setInterval(TweetIt,1000*20)

function TweetIt(){
    var r = Math.floor(Math.random()*100);
var tweet = {
    status: 'GoodEvening :)))))! #codingRainbow and here is a random number '+r+' #saks26'
}

T.post('statuses/update', tweet, tweeted);


 function tweeted(err, data, response) {
     if(err){
         console.log("Something goes wrong");
        // console.log(err);
     }else{
     console.log("It worked!")
     }
  }
}

We used get and post method here

Accomplishments that we're proud of

Made our Twitter Bot !!

What we learned

About Twit Package and how to create Bot on Twitter

What's next for Automate Something to Share Daily

We can Improve our bot and make it do more fun stuff

Built With

Share this project:

Updates