feat: update terminology from "gift" to "purchase" for Telegram Premium and Stars; enhance README and example scripts

This commit is contained in:
bohd4nx
2026-03-16 01:14:12 +02:00
parent 67f8a882c2
commit 520153dfb1
5 changed files with 22 additions and 16 deletions
+10 -8
View File
@@ -1,10 +1,10 @@
<div align="center"> <div align="center">
<img src="fragment.svg" alt="Fragment Logo" width="120" height="120" style="border-radius: 24px;"> <img src="fragment.svg" alt="Fragment Logo" width="120" height="120" style="border-radius: 24px;">
<h1 style="margin-top: 24px;">💎 Fragment API</h1> <h1 style="margin-top: 24px;">Fragment API</h1>
<p style="font-size: 18px; margin-bottom: 24px;"> <p style="font-size: 18px; margin-bottom: 24px;">
<b>Python library for the Fragment.com API — gift Telegram Stars, Premium, and top up TON Ads balance.</b> <b>Python library for the Fragment.com API — purchase Telegram Stars, Premium, and top up TON Ads balance.</b>
</p> </p>
[![PyPI version](https://img.shields.io/pypi/v/pyfragment?style=flat&color=blue)](https://pypi.org/project/pyfragment/) [![PyPI version](https://img.shields.io/pypi/v/pyfragment?style=flat&color=blue)](https://pypi.org/project/pyfragment/)
@@ -18,13 +18,15 @@
</div> </div>
> **Disclaimer:** This project is not affiliated with, endorsed by, or in any way officially connected with [Fragment](https://fragment.com) or [Telegram](https://telegram.org).
--- ---
## ✨ Features ## ✨ Features
- 💰 **TON Advertisement Topups** — Top up Telegram Ads balance (11,000,000,000 TON) - 💰 **TON Advertisement Topups** — Top up Telegram Ads balance (11,000,000,000 TON)
- 👑 **Telegram Premium Gifts**Gift Premium to any user (3, 6, or 12 months) - 👑 **Telegram Premium**Purchase Premium for any user (3, 6, or 12 months)
-**Telegram Stars Purchases**Gift Stars to any Telegram user (501,000,000 Stars) -**Telegram Stars Purchases**Purchase Stars for any Telegram user (501,000,000 Stars)
- 🔐 **Multi-wallet support** — V4R2 and V5R1 wallet contract versions - 🔐 **Multi-wallet support** — V4R2 and V5R1 wallet contract versions
-**Async-first** — Built on `httpx` and `asyncio` -**Async-first** — Built on `httpx` and `asyncio`
@@ -58,11 +60,11 @@ client = FragmentClient(
) )
async def main(): async def main():
# Gift 6 months of Telegram Premium # Purchase 6 months of Telegram Premium
result = await client.gift_premium("@username", months=6) result = await client.gift_premium("@username", months=6)
print(result.transaction_id) print(result.transaction_id)
# Gift 500 Stars # Purchase 500 Stars
result = await client.gift_stars("@username", amount=500) result = await client.gift_stars("@username", amount=500)
print(result.transaction_id) print(result.transaction_id)
@@ -94,8 +96,8 @@ See the [`examples/`](examples/) folder for ready-to-run scripts.
| Method | Returns | Description | Limits | | Method | Returns | Description | Limits |
| -------------------------------------------------- | ---------------- | ---------------------------------- | ------------------------- | | -------------------------------------------------- | ---------------- | ---------------------------------- | ------------------------- |
| `gift_premium(username, months, show_sender=True)` | `PremiumResult` | Gift Telegram Premium subscription | `months`: 3, 6, or 12 | | `gift_premium(username, months, show_sender=True)` | `PremiumResult` | Purchase Telegram Premium | `months`: 3, 6, or 12 |
| `gift_stars(username, amount, show_sender=True)` | `StarsResult` | Gift Telegram Stars | `amount`: 501,000,000 | | `gift_stars(username, amount, show_sender=True)` | `StarsResult` | Purchase Telegram Stars | `amount`: 501,000,000 |
| `topup_ton(username, amount, show_sender=True)` | `AdsTopupResult` | Top up Telegram Ads balance | `amount`: 11,000,000,000 | | `topup_ton(username, amount, show_sender=True)` | `AdsTopupResult` | Top up Telegram Ads balance | `amount`: 11,000,000,000 |
| `get_wallet()` | `WalletInfo` | Get wallet address, state, balance | — | | `get_wallet()` | `WalletInfo` | Get wallet address, state, balance | — |
+2 -2
View File
@@ -1,5 +1,5 @@
""" """
Example: gift Telegram Premium to a user. Example: purchase Telegram Premium for a user.
Supported durations: 3, 6, or 12 months. Supported durations: 3, 6, or 12 months.
Set show_sender=False to send anonymously. Set show_sender=False to send anonymously.
@@ -34,7 +34,7 @@ async def main() -> None:
print(f"Invalid parameters: {e}") print(f"Invalid parameters: {e}")
return return
print("Premium gifted") print("Premium purchased")
print(" %-14s %s" % ("Username:", result.username)) print(" %-14s %s" % ("Username:", result.username))
print(" %-14s %s months" % ("Duration:", result.months)) print(" %-14s %s months" % ("Duration:", result.months))
print(" %-14s %s" % ("Transaction:", result.transaction_id)) print(" %-14s %s" % ("Transaction:", result.transaction_id))
+2 -2
View File
@@ -1,5 +1,5 @@
""" """
Example: gift Telegram Stars to a user. Example: purchase Telegram Stars for a user.
Amount must be an integer between 50 and 1 000 000. Amount must be an integer between 50 and 1 000 000.
Set show_sender=False to send anonymously. Set show_sender=False to send anonymously.
@@ -34,7 +34,7 @@ async def main() -> None:
print(f"Invalid parameters: {e}") print(f"Invalid parameters: {e}")
return return
print("Stars gifted") print("Stars purchased")
print(" %-14s %s" % ("Username:", result.username)) print(" %-14s %s" % ("Username:", result.username))
print(" %-14s %s" % ("Stars:", result.stars)) print(" %-14s %s" % ("Stars:", result.stars))
print(" %-14s %s" % ("Transaction:", result.transaction_id)) print(" %-14s %s" % ("Transaction:", result.transaction_id))
+7 -3
View File
@@ -21,6 +21,10 @@ class FragmentClient:
""" """
Client for the Fragment.com API. Client for the Fragment.com API.
.. note::
This library is not affiliated with, endorsed by, or in any way officially
connected with Fragment or Telegram.
Args: Args:
seed: 24-word mnemonic phrase for the TON wallet. seed: 24-word mnemonic phrase for the TON wallet.
api_key: Tonapi API key — get one at https://tonconsole.com. api_key: Tonapi API key — get one at https://tonconsole.com.
@@ -85,12 +89,12 @@ class FragmentClient:
self.wallet_version: WalletVersion = version # type: ignore[assignment] self.wallet_version: WalletVersion = version # type: ignore[assignment]
async def gift_premium(self, username: str, months: int, show_sender: bool = True) -> PremiumResult: async def gift_premium(self, username: str, months: int, show_sender: bool = True) -> PremiumResult:
"""Gift Telegram Premium to a user. """Purchase Telegram Premium for a user.
Args: Args:
username: Recipient's Telegram username (with or without ``@``). username: Recipient's Telegram username (with or without ``@``).
months: Duration — ``3``, ``6``, or ``12``. months: Duration — ``3``, ``6``, or ``12``.
show_sender: Show your name as the gift sender. Defaults to ``True``. show_sender: Show your name as the sender. Defaults to ``True``.
Returns: Returns:
:class:`PremiumResult` with ``transaction_id``, ``username``, ``months``, ``timestamp``. :class:`PremiumResult` with ``transaction_id``, ``username``, ``months``, ``timestamp``.
@@ -98,7 +102,7 @@ class FragmentClient:
return await gift_premium(self, username, months, show_sender) return await gift_premium(self, username, months, show_sender)
async def gift_stars(self, username: str, amount: int, show_sender: bool = True) -> StarsResult: async def gift_stars(self, username: str, amount: int, show_sender: bool = True) -> StarsResult:
"""Gift Telegram Stars to a user. """Purchase Telegram Stars for a user.
Args: Args:
username: Recipient's Telegram username (with or without ``@``). username: Recipient's Telegram username (with or without ``@``).
+1 -1
View File
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
[project] [project]
name = "pyfragment" name = "pyfragment"
version = "2026.1.0" version = "2026.1.0"
description = "Python library for the Fragment.com API — gift Telegram Stars, Premium, and top up TON Ads balance." description = "Python library for the Fragment.com API — purchase Telegram Stars, Premium, and top up TON Ads balance."
readme = "README.md" readme = "README.md"
license = { text = "MIT" } license = { text = "MIT" }
requires-python = ">=3.12" requires-python = ">=3.12"