Welcome to Reddit-Ribbit-Ribbit! This project is an AI-powered Reddit agent designed to hop into discussions, share some insights (and maybe a frog pun or two! ๐ธ), and engage with communities using a fun, friendly, and modern voice, including Gen Alpha slang and emojis! โจ
It uses the power of Google's Gemini API for its intelligent comment generation and image understanding capabilities.
Reddit-Ribbit-Ribbit is a Python-based bot that:
- ๐ Monitors specified subreddits for new posts.
- ๐ Filters posts based on keywords in their titles.
- ๐ง Analyzes post content, including text, linked URLs, and images.
- ๐ค Uses the Google Gemini API (specifically a model like
gemini-1.5-pro-latest
or your configuredgemini-2.5-pro-exp-03-25
) to generate contextually relevant and engaging comments. - ๐ฃ๏ธ Speaks in a customizable persona, incorporating Gen Alpha slang and emojis for a modern, quirky vibe.
- ๐ Posts these comments to Reddit, adding a unique voice to discussions.
- โฐ Manages a cooldown period to avoid spamming.
- ๐พ Remembers posts it has replied to.
Built With:
- ๐ Python
- ๐ค Google Gemini API
- praw (Python Reddit API Wrapper)
- ๐ Dotenv, Requests, BeautifulSoup4, Pillow
graph TD
A[Start Ribbit Agent ๐ธ] --> B{Scan Subreddits for New Posts};
B -- Post Found --> C{Match Keywords in Title?};
C -- Yes --> D{Time Since Last Comment OK? โฑ๏ธ};
C -- No --> B;
D -- No --> B;
D -- Yes --> E[Process Post Content: Text, URLs, Images ๐ผ๏ธ];
E --> F[Fetch Persona & Brain Files ๐ง ];
F --> G[Generate Comment with Gemini AI โจ];
G --> H[Post Comment to Reddit โ
];
H --> I[Log Replied Post & Update Timestamp ๐พ];
I --> B;
Simplified Workflow:
- Launch: Start the
ribbit_agent.py
script. - Scan & Filter: The bot checks your chosen subreddits for new posts that match your keywords.
- Cooldown Check: Ensures it waits a random interval (1-2 hours by default) before commenting again.
- Understand: If a post is a match and the cooldown is over, the bot reads the post's text. If there are links, it tries to scrape their content. If it's an image post, it downloads and uses Gemini to describe the image.
- Think (with Gemini!): It combines the post's info with its "brain" files (
persona_and_instructions.txt
,good_comment_examples.txt
, etc.) to create a prompt for the Gemini API. - Craft Reply: Gemini generates a comment based on all this context, aiming for a helpful, engaging, and on-brand (lowercase, slang, emojis!) response.
- Post & Remember: The bot posts the comment to Reddit and saves the post ID so it doesn't reply again.
- Repeat: The cycle continues!
Reddit-Ribbit-Ribbit/
โโโ .env # Stores your API keys and credentials (KEEP THIS SECRET!)
โโโ README.md # You are here! ๐
โโโ requirements.txt # Lists Python dependencies for the project
โโโ ribbit_agent.py # The main Python script that runs the bot ๐ค
โโโ bot_brain_files/ # Folder containing the bot's personality and knowledge
โ โโโ persona_and_instructions.txt # Defines the bot's core persona and general instructions
โ โโโ good_comment_examples.txt # Examples of good comments for the bot to learn from
โ โโโ knowledge_snippets.txt # Specific facts or info for the bot
โ โโโ output_rules.txt # Strict rules for the bot's output (e.g., lowercase, emojis)
โ โโโ avoid_these_comments.txt # Examples of comments the bot should NOT make
โ โโโ replied_posts.txt # Keeps track of posts already replied to (created by script)
โโโ img/ # Directory for temporarily storing downloaded images (created by script)
Follow these steps to get Reddit-Ribbit-Ribbit hopping on your machine!
- Python 3.7+ installed.
- A Reddit account for your bot.
- A Google Cloud Project with the Gemini API enabled (to get your Google API Key).
-
Clone the Repository:
git clone https://github.com/VinsmokeSomya/Reddit-Ribbit-Ribbit.git cd Reddit-Ribbit-Ribbit
-
Install Dependencies: It's recommended to use a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
Then install the required packages:
pip install -r requirements.txt
(Make sure
requirements.txt
includesgoogle-generativeai
and other necessary packages likepraw
,python-dotenv
,requests
,beautifulsoup4
,Pillow
) -
Reddit App Setup:
- Go to https://www.reddit.com/prefs/apps.
- Scroll down and click "are you a developer? create an app...".
- Fill in the details:
- name: RedditRibbitRibbit (or anything you like)
- type: select
script
- description: (optional)
- about url: (optional)
- redirect uri:
http://localhost:8080
(important for script apps)
- Click "create app".
- You will get a CLIENT ID (under your app name) and a CLIENT SECRET.
-
Google Gemini API Key:
- Go to the Google AI Studio or your Google Cloud Console.
- Create an API key for the Gemini API. Refer to the official Google documentation for the latest steps.
-
Environment Variables (.env file):
- Create a file named
.env
in the root directory of the project. - Add your credentials like this (replace
xxx
andyour_..._here
with your actual values):REDDIT_CLIENT_ID="YOUR_REDDIT_CLIENT_ID" REDDIT_CLIENT_SECRET="YOUR_REDDIT_CLIENT_SECRET" REDDIT_USER_AGENT="RedditRibbitRibbit v1.0 by YourUsername" # Make this unique and descriptive REDDIT_USERNAME="YOUR_BOTS_REDDIT_USERNAME" REDDIT_PASSWORD="YOUR_BOTS_REDDIT_PASSWORD" GOOGLE_API_KEY="YOUR_GOOGLE_GEMINI_API_KEY"
- Create a file named
-
Configure the Bot's Brain ๐ง :
- Navigate to the
bot_brain_files/
directory. - Edit the following files to customize Reddit-Ribbit-Ribbit's personality and knowledge:
persona_and_instructions.txt
: Define how your bot should act, its primary goals, and overall tone. Get creative with its froggy, Gen Alpha persona!good_comment_examples.txt
: Provide high-quality examples of comments (with slang and emojis!) you want the bot to emulate.knowledge_snippets.txt
: Add any specific facts, frog trivia, or information you want the bot to know.output_rules.txt
: Define strict rules for its comments (e.g., sentence length, emoji usage).avoid_these_comments.txt
: Give examples of what the bot shouldn't say.
- Navigate to the
-
Configure Subreddits & Keywords:
- Open
ribbit_agent.py
. - Modify these lines with your target subreddits and keywords:
subreddits = ["yoursubreddit1", "anothersub", "askreddit"] keywords = ["yourkeyword", "another keyword", "help me find"]
- Open
Once everything is configured:
- Make sure your virtual environment is activated (if you used one).
- Run the script from the project's root directory:
python ribbit_agent.py
- Watch the console for output! The bot will print the subreddits it's searching and any comments it posts.
- Persona & Voice: The core of customization lies in the
.txt
files within thebot_brain_files/
directory. Experiment with different instructions, examples, and rules to shape Reddit-Ribbit-Ribbit's unique character. - Targeting: Change the
subreddits
andkeywords
lists inribbit_agent.py
to target different communities and topics. - Comment Frequency: Adjust the
random.randint(3600, 7200)
values inribbit_agent.py
to change the cooldown period between comments (values are in seconds). - Gemini Model: You can change the Gemini model used (e.g.,
gemini-1.5-pro-latest
,gemini-1.5-flash-latest
, or other specific versions) inribbit_agent.py
wherecomment_generation_model
andimage_description_model
are initialized.
- This project was inspired by and evolved from concepts demonstrated in various AI agent tutorials.
- Special thanks to the creators of PRAW and the Google Gemini API for their excellent tools.
- Original YouTube Tutorial (if applicable, you mentioned one earlier): [Link to Tutorial if you have one]
Happy Ribbiting! ๐ธ๐ฌ