A Reddit bot for automating tasks.
Project description
Reddit Bot CLI
Reddit Bot CLI is a command-line tool that automatically monitors specific subreddits for keywords and posts comments when those keywords are found. This tool is ideal for automating responses to relevant Reddit posts.
Features
- Monitor multiple subreddits for keywords.
- Automatically post comments on matching posts.
- Configurable settings through a
.inifile.
Installation
To install the Reddit Bot CLI, use pip:
pip install reddit-bot-cli
Configuration
The bot requires a configuration file to store your Reddit API credentials and bot settings. You can create the configuration interactively using the following command:
reddit-bot-cli --create-config
This will prompt you for the required information:
- Reddit Client ID
- Reddit Client Secret
- Reddit Username
- Reddit Password
- Reddit User Agent
- Subreddits to monitor (comma-separated)
- Keywords to search for (comma-separated)
- Comment text to post when a match is found
The configuration will be saved in a file (e.g., config.ini).
Alternatively, you can manually create the config.ini file in the following format:
[reddit]
client_id = YOUR_CLIENT_ID
client_secret = YOUR_CLIENT_SECRET
username = YOUR_USERNAME
password = YOUR_PASSWORD
user_agent = YOUR_USER_AGENT
[bot_settings]
subreddits = subreddit1, subreddit2
keywords = keyword1, keyword2
comment_text = This is an automated comment matching one of the keywords!
How to Get Reddit API Credentials
- Go to the Reddit Developer Apps page.
- Click Create App or Create Another App.
- Fill out the form:
- Choose script.
- Name your app.
- Set the redirect URI to
http://localhost:8080.
- After creating, you'll get your client ID and client secret.
- Copy the client ID, client secret, and set your user agent (this can be any string, e.g.,
reddit-bot-cli/1.0).
Usage
Once the configuration is ready, you can start the bot by running:
reddit-bot-cli --config /path/to/config.ini
Example:
reddit-bot-cli --config reddit_bot/config.ini
The bot will start monitoring the specified subreddits and post comments when it finds matching keywords.
Command-line Arguments:
--config: Specify the path to your configuration file (default:config.ini).--create-config: Create a new configuration file interactively.
Logging
All bot activity is logged to the logs/bot.log file. You can check this file to see when the bot found a post and posted a comment.
Development
If you want to contribute to this project or run it locally, you can clone the repository and install dependencies in a virtual environment:
git clone https://github.com/VashonG/reddit-bot-cli.git
cd reddit-bot-cli
python -m venv venv
source venv/bin/activate # On Windows use: venv\Scripts\activate
pip install -r requirements.txt
To run the bot:
python -m reddit_bot.cli --config reddit_bot/config.ini
License
This project is licensed under the MIT License - see the LICENSE file for details.
Notes:
- Replace
YOUR_CLIENT_ID,YOUR_CLIENT_SECRET,YOUR_USERNAME,YOUR_PASSWORD, andYOUR_USER_AGENTin the example config with actual values. - Update the GitHub URL in the Development section to point to your repository.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file reddit_bot_cli-0.0.6.tar.gz.
File metadata
- Download URL: reddit_bot_cli-0.0.6.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
411ce4082a7b940460264f2ef4cadcce67bc6b4b471c86b59665c3b2763793bb
|
|
| MD5 |
5a867608eed1352885ab212fc0d78449
|
|
| BLAKE2b-256 |
947e36b737db34d6930203c49ef28c6e7e6d8d0081bfd0e49b4d27449a2b10db
|
File details
Details for the file reddit_bot_cli-0.0.6-py3-none-any.whl.
File metadata
- Download URL: reddit_bot_cli-0.0.6-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25cd94874456681295e2f459d63efd8a2964bcfb56de9391b3f1cc2aaca1f999
|
|
| MD5 |
8ee1f47d8b019a96ad8176c091259b61
|
|
| BLAKE2b-256 |
dfb8843057140ba679fe979049326aac2f259d44862ef61a31847a2a3e4a51ab
|