I'm assuming you have Git and NodeJS on your system.
I used yarn in this project, so type: (if you don't have it installed)
npm install -g yarn
Code download:
git clone https://github.com/pedroperegrinaa/twitter-stalker.git
Download the modules:
yarn install
(warning: dependencies weigh around 428MB )
Create a .env file and fill it with the following values:
BEARER_TOKEN=
EMAIL_ADDRESS=
EMAIL_PASSWORD=
USER_STALKED=
BEARER_TOKEN: It is your authorization token to use the Twitter API V2. You can get more information about here: Bearer token Twitter. There is a limit of 500,000 tweet requests per month. This information is important.
EMAIL_ADDRESS: Your gmail where you will send emails to yourself. You need to allow the use of "less secure apps". More information here: Google's least secure applications. Note: This code was made with use in gmail in mind and, if you want to use another service, you will need to modify something in the email.js
file.
EMAIL_PASSWORD: Yes, your email password.
USER_STALKED: You need to set the ID of the account you want to stalk. To get the user ID, use this website: https://tweeterid.com/
node index.js
This will start monitoring. At the end of the index.js
file we have the following function:
setInterval(getTweets, 60000);
The second parameter is the time between each check for the last tweet made and is in milliseconds. The default value is 1 minute. Feel free to change this, but be aware of the limit of 500,000 tweet requests per month. Every minute 5 tweets are returned (this is the minimum value of the endpoint 2/users/${user}/tweets/?max_results=5
). Keep this in mind if you want to modify this value.
This code was developed on Ubuntu 20.04.4 LTS, within WSL2 on Windows 10 64 bits. I had problems with Chromium ( puppeteer
dependency) and I got the solution here:
puppeteer/puppeteer#1837
the issue took me to this site and it solved my problem on Ubuntu:
https://scottspence.com/posts/use-chrome-in-ubuntu-wsl
(I had the same problem on Arch and unfortunately I couldn't solve it. If you try to install it and succeed, please tell me how so I can improve this documentation.)
If you have any problems, send a message on my Twitter!