This is a Python script that creates and publishes daily quote images to a Telegram channel. The script fetches a random quote from an API and overlays it on a customizable background image along with a logo.
Before running the script, make sure you have the following:
- Python 3.x installed
telebot
library installed (pip install pytelegrambotapi
)requests
library installed (pip install requests
)Pillow
library installed (pip install pillow
)
-
Clone this repository or download the script file to your local machine.
-
Obtain a Telegram Bot token by creating a new bot using the BotFather and note it down.
-
Replace the
'YOUR_BOT_TOKEN'
placeholder with your Telegram Bot token in the code. -
Set your channel ID by replacing
'@YOUR_CHANNEL_USERNAME'
with the username of your Telegram channel. -
Customize the script according to your preferences:
- Adjust the
image_width
andimage_height
variables to set the size of the background image. - Modify the
background_color
andtext_color
variables to change the colors. - Replace
'path_to_your_font_file.ttf'
with the path to your desired font file. - Customize the logo text, font size, and color using the
logo_text
,logo_font_size
, andlogo_text_color
variables.
- Adjust the
-
Save the changes.
-
Open a terminal or command prompt and navigate to the directory where the script is located.
-
Run the script using the following command:
python main.py
-
The script will continuously fetch a daily quote and publish it to the specified Telegram channel. Each quote will be accompanied by a generated image.
-
To stop the script, press
Ctrl + C
in the terminal or command prompt.
-
Make sure your bot has permission to send messages and photos in the specified channel.
-
Adjust the
time.sleep()
duration to control the frequency of quote publication. The provided script delays for 60 seconds between each iteration. -
Make sure the font file specified in
font_path
exists at the provided path. -
The script uses the
api.quotable.io
API to fetch random quotes. Ensure you have an internet connection for successful quote retrieval.
This project is licensed under the MIT License.