Follow my Threads profile!
fetch_and_post_earthquake.py
is run via a cron job on Dreamhost that is scheduled to run every 5 minutes.
fetch_new_earthquakes()
gets the latest data from the USGS API. I use Oakland, CA as the lat/long coordinates and use a ~50 mile radius to fetch earthquakes that happened in the last 5 minutes within that circle.
post_to_threads()
takes the earthquake data and calls the threads API to publish a post. I include the USGS link to the earthquake details plus a google maps link to the coordinates of the earthquake epicenter.
I also schedule th_access_token.py
to be a cron job that's run every month to keep the access token valid.
-
Clone the repository:
git clone https://github.com/0xjessel/earthquake-bot.git cd earthquake-bot
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- On Windows:
-
Install the required packages:
pip install -r requirements.txt
-
Create a
.env.local
file:- Copy the
.env.example
file to create your own environment configuration:cp .env.example .env.local
- Copy the
-
Edit the
.env.local
file:- Open
.env.local
in a text editor and fill in the required values
- Open
-
Run the script
python fetch_and_post_earthquake.py
What other bots can I make hmm..