This Python script fetches hot posts from random subreddits and sends them to a Telegram chat. It uses asyncio for asynchronous operations and environment variables for configuration.
- Randomly selects subreddits from a predefined list
- Fetches hot posts from selected subreddits
- Sends post titles and preview images to a Telegram chat
- Runs continuously with a 15-minute interval between updates
- Python 3.7+
- pip
-
Clone the repository:
git clone https://github.com/zerone0x/reddit-telegram-bot.git cd reddit-telegram-bot
-
Set up a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS and Linux:
source venv/bin/activate
- On Windows:
-
Install the required packages:
pip3 install -r requirements.txt
This project uses environment variables for configuration. Create a .env
file in the project root with the following variables:
Replace the placeholder values with your actual credentials and preferences.
TOKEN
: Your Telegram Bot API tokenCHAT_ID
: The ID of the Telegram chat where messages will be sentREDDIT_CLIENT_ID
: Your Reddit application client IDREDDIT_CLIENT_SECRET
: Your Reddit application client secretREDDIT_USER_AGENT
: A unique identifier for your Reddit applicationSUBREDDITS
: A comma-separated list of subreddit names to fetch posts fromSUBREDDITS_COUNT
: The number of subreddits to fetch posts from
After setting up the environment and configuring the variables, run the script:
python main.py
or
nohup python3 main.py &
The bot will start fetching hot posts from random subreddits and sending them to the specified Telegram chat every 15 minutes.
- write env variables to github secrets
Contributions, issues, and feature requests are welcome. Feel free to check issues page if you want to contribute.
zerone0x - GitHub