Refactor cookie handling and service structure

- Removed the old CookieResult model from pyfragment.core.models and created a new one in pyfragment.services.cookies.models.
- Implemented get_cookies_from_browser function in pyfragment.services.cookies.service to extract cookies directly from supported browsers.
- Updated imports across various modules to reflect the new structure and removed unused imports.
- Cleaned up models in ads, anonymous_numbers, giveaways, marketplace, and purchases domains by removing unnecessary __all__ declarations.
- Added new example scripts for cookie extraction and various purchase functionalities.
- Consolidated constants into a new pyfragment.core.constants module for better organization.
This commit is contained in:
bohd4nx
2026-06-16 01:19:33 +03:00
parent 9f11ccb3ee
commit dc9661134d
51 changed files with 178 additions and 234 deletions
+4 -9
View File
@@ -38,8 +38,10 @@ pip install git+https://github.com/bohd4nx/pyfragment.git@dev
```python
import asyncio
from pyfragment import FragmentClient
from pyfragment.models.enums import PaymentMethod
from pyfragment.enums import PaymentMethod
async def main() -> None:
async with FragmentClient(
@@ -58,14 +60,7 @@ async def main() -> None:
recipient = "https://t.me/username" # also: @username, username
stars = await client.purchase_stars(recipient, amount=500, payment_method=PaymentMethod.USDT_GRAM)
if stars.auto_paid:
print(f"Sent {stars.amount} Stars to {stars.username} | tx: {stars.transaction_id}")
else:
print(f"Manual payment required for {stars.username}")
print(f"Address: {stars.payment_address}")
print(f"Amount: {stars.payment_amount}")
print(f"Expires: {stars.payment_expires_at}")
print(f"QR link: {stars.payment_qr_link}")
print(f"Sent {stars.amount} Stars to {stars.username} | tx: {stars.transaction_id}")
premium = await client.purchase_premium(recipient, months=6, payment_method=PaymentMethod.GRAM)
print(f"Sent Premium {premium.amount}m to {premium.username} | tx: {premium.transaction_id}")