Commit 8c427f7a authored by Pranav's avatar Pranav
Browse files
parents 089b3a22 70c8e8b5
...@@ -71,9 +71,70 @@ pip install -r requirements.txt ...@@ -71,9 +71,70 @@ pip install -r requirements.txt
Ensure the virtual environment is activated Ensure the virtual environment is activated
Confirm .env is present with correct values Confirm .env is present with correct values
Run the program script Run the program script
python services/telegram_listener.py python services/telegram_listener.py
Verify the Bot Is Running Verify the Bot Is Running
Check console output for post messages (new and historical) Check console output for post messages (new and historical)
Confirm CSV file is created/updated with captured post data Confirm CSV file is created/updated with captured post data.
**🐳 Running the Telegram Listener in Docker**
1. Prerequisites
Make sure you have:
Docker and Docker Compose installed
A valid Telegram API ID and API Hash
A session_name.session file generated by running the script locally once
2. Project Setup
Create a .env file in the project root (Skip if already created) :
API_ID=your_api_id
API_HASH=your_api_hash
SESSION=session_name
Ensure your project contains:
Dockerfile
docker-compose.yaml
session_name.session file (from your local run)
3. Build the Docker Image
docker-compose build
4. Start the Container
5.
docker-compose up
The container will:
Load environment variables from .env
Use the existing session_name.session file for authentication
Start fetching data from Telegram immediately
5. Stop the Container
To stop gracefully (Telethon disconnects cleanly):
docker-compose down
or:
docker stop telegram_bot
6. Logs
View logs in real-time:
docker logs -f telegram_bot
7. Notes
Don’t add session_name.session to .dockerignore
Keep session_name.session in .gitignore (never commit it)
The container will auto-restart if it crashes (restart: always)
The Telethon-based Telegram listener is now fully Dockerized and production-ready.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment