The code you see here represents a Python script that automates commenting on new posts made by a specific Reddit user. It utilizes the PRAW library, which provides a convenient wrapper for the Reddit API.
Before you can execute or deploy this script, make sure you have the following prerequisites installed:
For execution:
- Python (https://www.python.org/downloads/)
For deployment on a Linux VPS:
- pm2 (Process Manager for Node.js, can be installed via
npm install pm2 -g
)
To configure the script, you need to provide the necessary credentials in a separate configuration file named config.py
. Ensure you have the following information available:
REDDIT_API_APP_ID
- The client ID for your Reddit API application. This uniquely identifies your app to Reddit's API.
REDDIT_API_KEY
- The client secret key for your Reddit API application. Used to authenticate your app.
REDDIT_USERNAME
- The username of the Reddit account the bot will use to perform actions.
REDDIT_PASSWORD
- The password for the Reddit account specified in REDDIT_USERNAME
.
COMMENT_TEXT
- The text the bot will post as a comment on new posts it finds.
MAX_POST_AGE
- The maximum age (in months) of posts the bot will search and comment on. Posts older than this will be ignored.
DEBUG
- When true, runs the bot immediately instead of scheduling it and exits. For development/testing.
Copy the config.py.example file and enter your configuration parameters.
To execute the script or deploy it on a Linux VPS:
-
Clone the repository using the following command:
git clone https://github.com/simwai/reddit-auto-comment-bot
-
Navigate to the project directory:
cd reddit-auto-comment-bot
-
Configure the
config.py
file as mentioned in the previous section. -
(Windows) Run the script with
deploy.bat
-
(Linux VPS) Make sure the
deploy.sh
script is executable:sudo chmod +x deploy.sh
-
(Linux VPS) Run the script manually
sudo ./deploy.sh
or start the script as a pm2 process with a specified name:
pm2 start ./index.py --name reddit-auto-comment-bot --interpreter python --log-date-format="HH:mm DD-MM-YYYY"
Now, the Reddit auto comment bot is up and running, ready to monitor new posts and comment on them based on your configuration.
This project is licensed under the MIT License.