Thank you for considering contributing to Telegram-Archive!
-
Fork the repository
-
Clone your fork:
git clone https://github.com/YOUR_USERNAME/Telegram-Archive.git cd Telegram-Archive -
Install dependencies:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt pip install -e ".[dev]"
-
Set up pre-commit hooks:
pre-commit install
-
Copy the environment file:
cp .env.example .env # Edit .env with your Telegram API credentials (for backup testing only) -
Run tests:
python -m pytest tests/ -v
feat/— New featuresfix/— Bug fixesdocs/— Documentation updatesrefactor/— Code refactoringtest/— Test additions/updates
We follow Conventional Commits:
type(scope): description
Types: feat, fix, docs, style, refactor, test, chore, ci
Examples:
feat(viewer): add message searchfix(backup): handle timezone-aware datetimes in updatesdocs(readme): update Docker configuration section
- Create a feature branch from
master - Make your changes
- Run tests:
python -m pytest tests/ -v - Run linting:
ruff check . - Run formatting:
ruff format --check . - Submit a PR with a clear description using the PR template
- Follow PEP 8 guidelines (enforced by Ruff)
- Use type hints for function signatures
- Prefer f-strings for string formatting
- Write self-documenting code; add comments only for complex logic
- Keep functions focused and testable
We use Ruff for both linting and formatting:
# Check for lint issues
ruff check .
# Auto-fix lint issues
ruff check --fix .
# Check formatting
ruff format --check .
# Auto-format
ruff format .When modifying database code, verify:
- All
chat_idvalues use marked format (via_get_marked_id()) - All datetime values pass through
_strip_tz()before DB operations - INSERT and UPDATE operations handle the same fields identically
- Tests exist in
tests/test_db_adapter.pyfor data type handling
See the AGENTS.md for detailed consistency rules.
# Run all tests
python -m pytest tests/ -v
# Run with coverage
python -m pytest tests/ --cov=src --cov-report=term-missing
# Run a specific test file
python -m pytest tests/test_db_adapter.py -v- Fixing a bug — write a test that would have caught it
- Adding DB operations — test data type handling
- Modifying config parsing — test edge cases
- Adding new features — test happy path and error cases
src/
├── __main__.py # Entry point
├── config.py # Environment variable handling
├── telegram_backup.py # Core backup logic
├── realtime.py # WebSocket real-time updates
├── db/
│ ├── adapter.py # Database operations (SQLAlchemy async)
│ ├── models.py # SQLAlchemy models
│ └── session.py # Database session management
└── web/
├── main.py # FastAPI application
├── static/ # CSS, JS, images
└── templates/ # Jinja2 templates
Please use the GitHub issue tracker with the bug report template. Include:
- Clear description
- Steps to reproduce
- Expected vs actual behavior
- Docker logs if applicable
Open an issue with the feature request template. Include:
- Clear use case
- Proposed solution
- Alternatives considered
By contributing, you agree that your contributions will be licensed under the GPL-3.0 License.