This bot is current in v0.5 so is in beta. May have some unexpected errors. As always, use at your own risk.
This bot is build using Twitter API V2 only. You can check the code, is very simple. Works with functions and curl api calls directly. It does not go through any external server or need other dependencies. It can be run on any computer or server running Linux or Mac.
Have working currently:
To do (next versions):
- Detect commands need and install or ask to install
- Save unfollows to not follow again (need change the logic of the functions)
- Get the token without need postman (only first config, later it auto update the token)
- Whitelist_users to ignore when follow or unfollow
Go to https://developer.twitter.com/en/portal/dashboard and login.
It will prompt to enter some things as:
- What country are you based in?
- What's your use case?
We accept the terms and conditions and we are already inside.
In some cases, especially when you already have a certain number of followers, you may get: You do not qualify for Essential access at this time. But they let you access Elevated access.
Remember read the https://help.twitter.com/en/rules-and-policies/twitter-automation and https://developer.twitter.com/en/docs/twitter-api/rate-limits#v2-limits
To create a Project, click on "New Project" in the Projects & Apps page inside the developer portal.
Set:
- If you are using postman in the browser is https://oauth.pstmn.io/v1/browser-callback if you are using in the app is https://oauth.pstmn.io/v1/callback
This has to be done only 1 time. Then the script is automatically refreshed. I recommend downloading the Postman app for convenience, but it can still be done in the browser.
Go to the public postman workspace: https://www.postman.com/twitter/workspace/twitter-s-public-workspace/request/9956214-419497de-aefc-4a8e-9ff5-1b4f73d948e3
Change type to: OAuth 2.0
In Configure New Token -> Configure options:
Search | Input |
---|---|
Token Name | login-example |
Grant Type | Authorization Code (With PKCE) |
Auth URL | https://twitter.com/i/oauth2/authorize |
Access Token URL | https://api.twitter.com/2/oauth2/token |
Client ID | Generate in Twitter dashboard |
Client Secret | Generate in Twitter dashboard |
Scope | tweet.read users.read follows.write offline.access follows.read like.write |
State | state |
Now copy the Access Token to TK_POSTMAN_ACCESS and refresh_token to TK_POSTMAN_REFRESH in config.json
To configure this bot. Change the parameters of the config.json file.
Search | Input |
---|---|
your_username | Your screen username. Without @ |
CLIENT_ID | Check Twitter dashboard |
API_KEY | Check Twitter dashboard |
API_SECRET_KEY | Check Twitter dashboard |
TK_POSTMAN_ACCESS | Check Postman |
TK_POSTMAN_REFRESH | Check Postman |
Just run:
bash twitter-bot.sh
Have English menu:
And Spanish menu:
You can change the language by changing the language variable in config.json. Currently just English and Spanish supported. But feel free to MR and update.
The script read the header and detect when the API have a limit and will auto refresh every minute until can continue.
The script will generate a graph of all actions: Follow, Unfollow and Likes.
You can check in the dir gnuplot.