Update November 2017: Since November 2017, I’ve updated my GitHub repository with a manual to use this bot with a Lambda function (Serverless). It’s more efficient and cost-effective than running a full-time EC2 instance.

This Node.js dead simple Twitter bot will retweet statuses based on your current search criteria, follow users based on same items, and favorite tweets too.

I’m using this to learn Node.js language and Git.

Actual Features:

  • Retweet
  • Favorite
  • Follow

Node.js Installation

Follow this great guide (Applicable to AWS Amazon Linux (EC2))

Lena Installation

  • mkdir bot
  • cd bot
  • npm init (follow the wizard)
  • npm install twitter more info
  • create your own on dev.twitter.com
    • Consumer Key
    • Consumer Secret
    • Access Token Key
    • Access Token Secret
  • Download in your bot folder all .js files

Lena Configuration

  • Setup your Consumer and Access Token (Key and Secret) in config.js file
  • Configure your search criteria (params), and iteration in each .js file
1
2
3
4
5
6
var params = {
  q: "#Nodejs OR #Github",
  count: 10,
  result_type: "recent",
  lang: "fr",
};
  • Setup crontab to periodically run your Node.js files.

    • crontab -e
    • Example for each 12 hours scheduling:

    0 */12 * * * /usr/local/bin/node /path/to/your/bot/follow.js >> /path/to/your/logs/logs-follow.txt

Todo

Don’t hesitate to create pull requests!

  • Exception on your own ID (don’t follow yourself)
  • Add users to public list (to be followed by another Twitter account)
  • Follow back followers
  • Reply to DM
  • Send DM to new followers
  • Bio description search
  • Timestamp Logs
  • #Follow Friday
  • etc…

Beware

Beware of the current Twitter rate limit

That’s all folks!

zoph.