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,
signature="report_signature",
body=b'{}'
)
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
📃 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:
Enjoy using the Telegram Gateway Python SDK! 🎉