TGateway: the simplest way to work with a Telegram Gateway API
Project description
Telegram Gateway Python SDK
Telegram Gateway Python SDK is a lightweight and asynchronous client library designed to interface with the Telegram Gateway API.
✨ Features
- Send Verification Messages: Deliver verification codes to users' phone numbers.
- Check Delivery Status: Verify the status of sent messages and handle callbacks.
- Revoke Verification: Invalidate previously sent verification messages.
- Integrity Validation: Ensure authenticity of incoming reports using signature validation.
- Easy to Use: Designed with simplicity and usability in mind.
- Fully Asynchronous: Built on
asyncio
for high-performance integration.
🏗️ Installation
Install the SDK using pip:
pip install tgateway
📚 Usage
Here's a basic example to get started with the TelegramGateway
client:
Check a send verification message ability
import asyncio
from tgateway import TelegramGateway
async def main():
async with TelegramGateway(access_token="<access-token>") as gateway:
result = await gateway.check_send_ability(
phone_number="+1234567890",
)
print(f"Verification ability: {result}")
asyncio.run(main())
Send a verification message
import asyncio
from tgateway import TelegramGateway
async def main():
async with TelegramGateway(access_token="<access-token>") as gateway:
result = await gateway.send_verification_message(
phone_number="+1234567890",
code_length=6
)
print(f"Verification message sent: {result}")
asyncio.run(main())
Check the Status of a Verification Request
import asyncio
from tgateway import TelegramGateway
async def main():
async with TelegramGateway(access_token="<access-token>") as gateway:
result = await gateway.check_verification_status(request_id="<request-id>")
print(f"Verification status: {result}")
asyncio.run(main())
Revoke a Verification Message
import asyncio
from tgateway import TelegramGateway
async def main():
async with TelegramGateway(access_token="<access-token>") as gateway:
result = await gateway.revoke_verification_message(request_id="<request-id>")
print(f"Verification revoked: {result}")
asyncio.run(main())
Validate Incoming Delivery Reports
To confirm the origin and integrity of incoming reports, you can use the validate_report_integrity
method provided by the SDK:
import asyncio
from tgateway import TelegramGateway
async def main():
async with TelegramGateway(access_token="<access-token>") as gateway:
try:
gateway.validate_report_integrity(
timestamp=123456789, # Timestamp from header
signature="report_signature", # Signature from header
body=b'{}' # Body of the report as bytes
)
print("Report integrity validated successfully.")
except Exception as e:
print(f"Validation failed: {e}")
asyncio.run(main())
🏛️ Project Structure
The project is structured for ease of use and maintainability:
tgateway/
├── client.py # Main client class.
├── constants.py # Constants used throughout the SDK.
├── enums.py # Enum definitions for API statuses.
├── exceptions.py # Custom exception classes.
├── integrity.py # Integrity validation utilities.
├── methods.py # Implementation of Telegram Gateway API methods.
├── types.py # Type definitions for API responses.
🧪 Testing
Currently, the project does not have test cases but this is planned for future releases. Contributions to add tests are welcome!
🔗 Important Links
- Telegram Gateway Overview: Telegram Gateway Overview
- API Reference: Gateway API Reference
- Verification Tutorial: Verification Tutorial
- Manage Your Account: Gateway Account
- Terms of Service: Gateway Terms of Service
📃 License
This project is licensed under the Apache License.
🤝 Contributing
Contributions are welcome! If you'd like to contribute, please fork the repository and submit a pull request. For major changes, open an issue first to discuss what you would like to change.
- Fork the repository.
- Create your feature branch:
git checkout -b feature/my-new-feature
. - Commit your changes:
git commit -m 'Add some feature'
. - Push to the branch:
git push origin feature/my-new-feature
. - Open a pull request.
💬 Contact
For questions, support, or just to connect, please reach out to the project maintainers:
- Email: deusdeveloper@yandex.com
- Telegram: @DeusDeveloper
- Chat: @tgateway
- GitHub Issues: GitHub Repository
Enjoy using the Telegram Gateway Python SDK! 🎉
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
Built Distribution
File details
Details for the file tgateway-0.1.0.tar.gz
.
File metadata
- Download URL: tgateway-0.1.0.tar.gz
- Upload date:
- Size: 22.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | afa19a5d742c77bfa5351070b2f58901b94b966a8a4bd60a49a836c5aba828e1 |
|
MD5 | 0183ef5eb2542f1fe87489f0d24dd450 |
|
BLAKE2b-256 | a384d2f3249d0d7c820e61f67288c783a68a7ebaad350e6a1bbc017f16cbedac |
File details
Details for the file tgateway-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: tgateway-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8470816b0a13d0f18851008244ea343d751ca046b1d5682723de71a5c9152c03 |
|
MD5 | b3c388288ff360ab326ac667f53cee3d |
|
BLAKE2b-256 | be227e5742b7d0484e22fb99512014a747b192de69bef0ec2b4279790a2645b4 |