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 dead simple Node.js Twitter bot will retweet statuses based on your current search criteria, follow users based on the same criteria, and favorite tweets too.

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

Actual Features:

  • Retweet
  • Favorite
  • Follow

Node.js Installation

Follow this great guide (applicable to AWS Amazon Linux on 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

  • Set up your Consumer and Access Token (Key and Secret) in the 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",
};
  • Set up crontab to periodically run your Node.js files.

    • crontab -e
    • Example for a 12-hour schedule:

    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.