This repository contains the code for building a Quote Telegram Bot using Python. The bot fetches quotes from the They Said So® API and sends them to a specified Telegram chat.
Before you begin, make sure you have the following:
-
Telegram Bot: Create a Telegram bot by following the instructions here.
-
Telegram Chat ID: Obtain the chat ID from your bot. Refer to this guide for more information. Also you can GET it from https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates, and see more recent chats.
-
Quotes API from They Said So®: Sign up for the They Said So® API to get access to the quotes. You can make 10 free calls per hour. Visit here to get your API key.
-
Dependencies: Check the
requirements.txtfile for the required libraries: requests, urllib, and python-dotenv. Install these libraries before running the code. -
Configuration: Configure your environment by creating a
.envfile and adding the following environment variables:
API_KEY_THEYSAIDSO=YOUR_API_KEY_FROM_THEYSAIDSO
TELEGRAM_BOT_TOKEN=YOUR_BOT_TOKEN
TELEGRAM_CHAT_ID=YOUR_CHAT_IDTo use the Quote Telegram Bot, follow these steps:
- Clone the repository:
git clone [email protected]:ferclager/python-quotes-telegrambot.git- Navigate to the project directory:
cd python-quotes-telegrambot - Run the quotes.py script
python3 quotes.pyIf you have an issue like this one:
Traceback (most recent call last):
File "/Users/ferclager/Developer/python-quotes-telegrambot/quotes.py", line 2, in <module>
import requests
ModuleNotFoundError: No module named 'requests'It means that you need to run this command first, to get all requirements from requirements.txt
pip install -r requirements.txtNote: make sure that you have pip installed first.
That's it! The bot will fetch quotes from the They Said So® API and send them to the specified Telegram chat.
Feel free to modify the code according to your requirements and enhance the functionality of the bot.
This project is licensed under the MIT License.