This project endeavors to develop a Twitter bot programmed to share a diverse array of inspirational quotes daily, scheduled precisely for 9:00 AM. Leveraging the ZenQuotes API alongside the Tweepy library, the bot will seamlessly curate and deliver thought-provoking content to engage and uplift its audience.
Before running the script, make sure you have the following:
-
Python 3 installed
- If not installed, click here to download the latest version of Python.
-
Tweepy library installed
Run the following command in cmd if tweepy is not installed.
pip install tweepy
-
Tokens and API Keys for Twitter Account Authentication and Access
- Click here to learn more about Twitter's Developer Platform
-
Clone the repository:
git clone https://github.com/anujeshify/QuoterX.git
-
Install the required libraries:
pip install -r requirements.txt
-
Create a
config.py
file and add your Twitter API keys and tokens:CONSUMER_KEY = 'your_consumer_key' CONSUMER_SECRET = 'your_consumer_secret' ACCESS_TOKEN = 'your_access_token' ACCESS_TOKEN_SECRET = 'your_access_token_secret' BEARER_TOKEN = 'your_bearer_token'
-
Run the script in Command Prompt:
python QuoterX.py
-
If you want to keep the Python Script running as a background process, then use the following command
start /B python QuoterX.py
-
If you want to stop the Python Script, then first find the Process ID of the Python Script that is runnning using the following command
tasklist | findstr "python"
This will show the python process with its PID (Process ID)
-
Kill the process by using the following command on cmd
taskkill /PID <process id> /F
Replace "Process id" with the PID displayed. A Demonstration of the same is given below -
-
The script fetches a random quote from the ZenQuotes API.
-
If the author of the quote is "Unknown", it fetches another random quote until a valid author is obtained.
-
The script creates a tweet with the quote and author.
-
The tweet is posted using the Tweepy library and your Twitter API credentials.
-
The script runs continuously and checks the current time every second.
-
If the current time is 9:00 AM, it tweets a new quote.
- Python - Python Programming Language
- Tweepy - Tweepy is a publicly available open-source Python library.
- ZenQuotes API - The ZenQuotes API is an incredibly easy to use data feed for your website or app.
- Twitter Developer Platform - Guides and reference materials to use Twitter Developer Platform
- Anujesh Bansal - anujeshify
Contributions to this project are welcome! If you have any suggestions, bug fixes, or improvements, please feel free to open an issue or submit a pull request. For any queries reach me at anujeshbansaltoo@gmail.com
Special thanks to the contributors and developers of the libraries and tools used in this project, including tweepy and ZenQuotes API.