/babybot

I made a stupid bot that retweets #iamababy

Primary LanguageShell

Gomix Twitter bot template

Tweetin'

This is a template for making fun Twitter bots with Gomix and the Twit node.js library.

A quick tutorial

  1. First, create a new Twitter account and a new Twitter app. This tutorial explains how to do this.
  2. Update the .env file with your Twitter API key/secrets. (Again, check the tutorial above to see how to get these.)
  3. Finally, update server.js with some cool Twitter bot code.

The included example simply tweets out "Hello world!". Check out the Twit module documentation for more examples of what your bot can do, such as retweet a specific tweet by its ID:

T.post('statuses/retweet/:id', { id: '799687419259797504' }, function (err, data, response) {
  console.log(data)
});

Or perhaps respond to people talking to your bot:

var stream = T.stream('statuses/filter', { track: '@yourbotsname' });

stream.on('tweet', function (tweet) {
  if (tweet.text === 'hello'){
    T.post('statuses/update',{
      status: 'hello there 👋',
      in_reply_to_status_id: tweet.id
    }, function(err, data, response) {
      if (err){
        console.log('ERROR');
        console.log(err);          
      }
    });
  }
});

You can find more tutorials and open source Twitter bots on Botwiki. And be sure to join the Botmakers online hangout and submit your bot to Botwiki :-)

Powered by Gomix

\ ゜o゜)ノ