This is a Python application designed for Open Source Intelligence (OSINT) that leverages Telegram channels to collect, process, and analyze data. The application uses the PyNest framework for modularity and dependency injection, and integrates with the OpenAI API for advanced processing.
- Features
- Prerequisites
- Installation
- Environment Variables
- Running the Application
- Project Structure
- Usage
- Connects to specified Telegram channels to read messages.
- Processes messages using OpenAI's GPT models.
- Modular architecture using the PyNest framework.
- Configurable through environment variables.
- Background job for continuous data fetching and processing.
- Python 3.10 or higher
- Poetry for dependency management
- Telegram API credentials:
- API ID
- API Hash
- OpenAI API key
-
Clone the repository
git clone https://github.com/yourusername/telegram-osint-app.git cd telegram-osint-app
-
Install dependencies
Ensure you have Poetry installed. If not, install it using:
pip install poetry
Then, install the project dependencies:
poetry install
The application requires certain environment variables to be set for configuration. You can create a .env
file in the root directory of the project to set these variables.
- OPENAI_API_KEY: Your OpenAI API key.
- API_ID: Your Telegram API ID.
- API_HASH: Your Telegram API Hash.
- TARGET_CHANNEL: The Telegram channel where processed messages will be sent.
- MODEL_NAME: The name of the OpenAI model to use (e.g.,
gpt-4
).
Create a file named .env
in the root directory and add the following:
OPENAI_API_KEY=your-openai-api-key
API_ID=your-telegram-api-id
API_HASH=your-telegram-api-hash
TARGET_CHANNEL=@yourtargetchannel
MODEL_NAME=gpt-4
Note: Replace the placeholder values (your-openai-api-key, your-telegram-api-id, etc.) with your actual credentials.
You can run the application locally using the following command:
poetry run python main.py
This will start the application on http://0.0.0.0:8000.
Alternatively, you can run the application inside a Docker container.
docker build -t telegram-osint-app:latest .
docker run -p 8000:8000 --env-file .env telegram-osint-app:latest
Note: Make sure your .env file is in the root directory and contains all the necessary environment variables.
The project follows a modular architecture provided by the PyNest framework. Here's an overview of the main components:
main.py
: Entry point of the application.src/
: Contains the application source code.app_module.py
: Defines the main application module.app_controller.py
: Handles HTTP routes.app_service.py
: Contains business logic.providers/
: Contains all the service providers.config/
: Configuration services.logger/
: Logging services.telegram/
: Telegram integration services.openai/
: OpenAI integration services.cost_calculator/
: Services for calculating costs.
jobs/
: Background jobs (e.g.,osint_job.py
).
The application continuously fetches messages from specified Telegram channels, processes them (e.g., translates or filters important messages), and sends the processed messages to a target Telegram channel.