Helper functions for Telegram Mini Apps.
Project description
Telegram Mini App Helpers
A Python package with helper functions for Telegram Mini Apps.
Features
- Validates
initDatafrom Telegram Mini Apps. - Modern Python packaging using
pyproject.toml - Type hints and static type checking with mypy
- Code formatting and linting with Ruff
- Comprehensive testing setup
- GitHub Actions for CI/CD
Installation
pip install tma-functions
Usage
from tma_functions.auth import validate_auth_data
# Example usage for auth data validation
bot_token = "YOUR_BOT_TOKEN"
auth_data = "auth_date=1678886400\nhash=YOUR_HASH\nquery_id=YOUR_QUERY_ID\nuser={\"id\":123,\"first_name\":\"John\",\"last_name\":\"Doe\",\"username\":\"john_doe\",\"language_code\":\"en\",\"allows_write_to_pm\":true,\"photo_url\":\"https://example.com/photo.jpg\"}"
user_data = validate_auth_data(bot_token, auth_data)
if user_data is not None:
print(f"User ID: {user_data['id']}")
print(f"Username: {user_data['username']}")
print(f"Full name: {user_data['first_name']} {user_data['last_name']}")
print(f"Language: {user_data['language_code']}")
else:
print("Invalid auth data")
Development
This project uses modern Python development tools:
- Hatch for project management
- Ruff for linting and formatting
- mypy for static type checking
- pytest for testing
Setup Development Environment
- Install development dependencies:
pip install -e ".[dev]"
- Run tests:
pytest
- Run type checking:
mypy .
- Run linting:
ruff check .
Deploy
rm -rf ./dist
hatch build
twine upload ./dist/*
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tma_functions-0.1.2.tar.gz
(5.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tma_functions-0.1.2.tar.gz.
File metadata
- Download URL: tma_functions-0.1.2.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81383555bb061e17112e5223ea9b2335f729a9f37d1d53e17339e354c22c2aa7
|
|
| MD5 |
a6cc7dd14d22619ac2847183e0cc22ec
|
|
| BLAKE2b-256 |
71010531ef51a6ebd55cbca3ba5fa42b5d1b8f6219aafa2c4650ebdb355c3921
|
File details
Details for the file tma_functions-0.1.2-py3-none-any.whl.
File metadata
- Download URL: tma_functions-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce9d1471f32d49772c51bf2d472421c7d6fd1da874069ad78ff5ce90c2acb940
|
|
| MD5 |
9bbe395a9952c7c358559b9f9e3ac364
|
|
| BLAKE2b-256 |
7bf14dd84bf228692f233c3f39d9bcfa0e717337a24de3edded55d6b75fa05e0
|