mirror of
https://github.com/bohd4nx/FragmentAPI.git
synced 2026-07-25 06:14:29 +00:00
902b692dcb
- Added new methods for handling giveaways: `giveaway_premium` and `giveaway_stars`. - Refactored existing purchase methods into separate files: `purchase_premium.py` and `purchase_stars.py`. - Removed old premium and stars methods from the codebase. - Updated `__init__.py` to include new giveaway methods in the public API. - Introduced new result types for giveaways: `PremiumGiveawayResult` and `StarsGiveawayResult`. - Updated constants for new giveaway pages. - Enhanced error handling for configuration and user validation in giveaway methods. - Updated tests to cover new functionality and refactored existing tests to match new method locations.
84 lines
2.1 KiB
Python
84 lines
2.1 KiB
Python
from dataclasses import dataclass
|
|
|
|
__all__ = ["AdsTopupResult", "PremiumGiveawayResult", "PremiumResult", "StarsGiveawayResult", "StarsResult", "WalletInfo"]
|
|
|
|
|
|
@dataclass
|
|
class WalletInfo:
|
|
"""Wallet state returned by :meth:`FragmentClient.get_wallet`."""
|
|
|
|
address: str
|
|
state: str
|
|
balance: float
|
|
|
|
def __repr__(self) -> str:
|
|
return f"WalletInfo(address='{self.address}', state='{self.state}', balance={self.balance} TON)"
|
|
|
|
|
|
@dataclass
|
|
class PremiumResult:
|
|
"""Result of a successful Telegram Premium gift."""
|
|
|
|
transaction_id: str
|
|
username: str
|
|
amount: int
|
|
|
|
def __repr__(self) -> str:
|
|
return f"PremiumResult(username='{self.username}', amount={self.amount} months, tx='{self.transaction_id}')"
|
|
|
|
|
|
@dataclass
|
|
class StarsResult:
|
|
"""Result of a successful Telegram Stars purchase."""
|
|
|
|
transaction_id: str
|
|
username: str
|
|
amount: int
|
|
|
|
def __repr__(self) -> str:
|
|
return f"StarsResult(username='{self.username}', amount={self.amount} stars, tx='{self.transaction_id}')"
|
|
|
|
|
|
@dataclass
|
|
class AdsTopupResult:
|
|
"""Result of a successful Telegram Ads balance top-up."""
|
|
|
|
transaction_id: str
|
|
username: str
|
|
amount: int
|
|
|
|
def __repr__(self) -> str:
|
|
return f"AdsTopupResult(username='{self.username}', amount={self.amount} TON, tx='{self.transaction_id}')"
|
|
|
|
|
|
@dataclass
|
|
class StarsGiveawayResult:
|
|
"""Result of a successful Telegram Stars giveaway."""
|
|
|
|
transaction_id: str
|
|
channel: str
|
|
winners: int
|
|
amount: int
|
|
|
|
def __repr__(self) -> str:
|
|
return (
|
|
f"StarsGiveawayResult(channel='{self.channel}', winners={self.winners}, "
|
|
f"amount={self.amount} stars per winner, tx='{self.transaction_id}')"
|
|
)
|
|
|
|
|
|
@dataclass
|
|
class PremiumGiveawayResult:
|
|
"""Result of a successful Telegram Premium giveaway."""
|
|
|
|
transaction_id: str
|
|
channel: str
|
|
winners: int
|
|
amount: int
|
|
|
|
def __repr__(self) -> str:
|
|
return (
|
|
f"PremiumGiveawayResult(channel='{self.channel}', winners={self.winners}, "
|
|
f"amount={self.amount} months per winner, tx='{self.transaction_id}')"
|
|
)
|