DiscoverQuotesDaily Bot is a Python-based bot that generates and posts inspirational quotes daily on Twitter. It can fetch quotes from various categories and generate visually appealing images featuring these quotes. The bot schedules daily posts and interacts with the Twitter API to share the generated images.
- Daily Inspirational Quotes: Automatically posts a new quote each day.
- Customizable Quotes: Fetches quotes based on various tags from the Quotable API.
- Image Generation: Creates images with quotes using the Pillow library.
- Twitter Integration: Posts images and quotes on Twitter using Tweepy.
- Python 3.6 or higher
- pip (Python package installer)
-
Clone the Repository
git clone https://github.com/yourusername/DiscoverQuoteBot.git cd DiscoverQuoteBot
-
Install Dependencies
Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
Install the required packages:
pip install -r requirements.txt
-
Configuration
-
Quotes API: No additional configuration required.
-
Twitter API: Create a
twitterCredentials.json
file in the root directory with the following structure:{ "access_token" : "YOUR_ACCESS_TOKEN", "access_token_secret" : "YOUR_ACCESS_TOKEN_SECRET", "bearer_token": "YOUR_BEARER_TOKEN_SECRET", "api_key":"YOUR_API_KEY", "api_key_secret":"YOUR_API_KEY_SECRET", "client_id":"YOUR_CLIENT_ID", "client_secret":"YOUR_CLIENT_SECRET" }
-
-
Run the Bot
Start the bot using:
python DiscoverQuoteBot.py
- DiscoverQuoteBot.py: Main script that runs the bot, schedules daily posts, and handles image generation and Twitter posting.
- bot_utils.py: Contains utility classes for interacting with the Quotable API, generating quote images, and posting to Twitter.
The main function daily_post_loop
fetches a quote, generates an image with the quote, saves it, and posts it to Twitter. The bot is scheduled to run this function daily.
- Quote: Retrieves a random quote from the Quotable API and handles tag selection.
- QuoteImageGenerator: Generates images with quotes using the Pillow library, adjusting text wrapping and font size dynamically.
- TwitterConnHandler: Manages Twitter API connections and handles posting of tweets with images.
- The bot runs continuously and posts a new quote daily.
- Modify
tags.json
to change the categories of quotes. - Adjust image generation settings by editing the
QuoteImageGenerator
class.
If you want to contribute to DiscoverQuoteBot, please follow these steps:
- Fork the repository.
- Create a new branch for your changes.
- Commit your changes and push them to your fork.
- Open a pull request with a clear description of your changes.
This project is licensed under the GPL License. See the LICENSE file for details.
For questions or feedback, please contact:
- Email: adityagaur.home@gmail.com
- GitHub: xdityagr
Enjoy using DiscoverQuotesDaily! Made with <3 In India!