A reddit bot replying to comments, containing factorials, with the solution. This little fella is currently running on r/mathmemes and on r/ProgrammerHumor.
Follow these steps to set up and run the Factorion bot on your local machine and account.
- Rust (latest stable version) - Install Rust
- Reddit Account - To run the bot, you'll need a Reddit account. Reddit
You can go to Reddit API Documentation to checkout all the different endpoints you can access.
- We need
Application ID
andSecret Key
so that Reddit can know about our app. preferences/apps - Click the are you a Developer? button to start setting up the bot.
- Fill in the required details:
- Name: Choose a name for your bot.
- App type: Select Script.
- Redirect URI: Use
http://localhost:8080
(or any URI; it’s not used for script bots).
- After creating the app, you'll receive:
client_id
(listed under the app name)client_secret
- A
username
andpassword
(for the Reddit account that created the app)
Fork/Clone the repository and navigate to the project directory:
git clone https://github.com/yourusername/factorion-bot.git
cd factorion-bot
Create a .env
file in the project root with the following variables:
CLIENT_ID=<your_client_id>
CLIENT_SECRET=<your_client_secret>
USERNAME=<reddit_app_username>
PASSWORD=<reddit_app_password>
SLEEP_BETWEEN_REQUESTS=<sleep_time>
SUBREDDITS=<subreddits>
Replace <your_client_id>
, <your_client_secret>
, <reddit_app_username>
, and <reddit_app_password>
with the values you received from the Reddit App creation.
cargo build
Run the bot with:
cargo run
-
Create a new user for the bot so it can be mentioned by
/u/<botname>
-
Create a new subreddit
/r/<botname>
as a test play ground.
The recommended way would be running the bot using docker.
git clone https://github.com/tolik518/factorion-bot
docker build -t factorion-bot .
# either create a network called `service-network` or remove the network if not needed
docker run --rm -d --name factorion-bot --volume $(pwd):/usr/factorion factorion-bot:latest ./run.sh
Feel free to submit issues or pull requests if you would like to contribute to this project.