mirror of
https://github.com/bohd4nx/FragmentAPI.git
synced 2026-07-25 06:14:29 +00:00
760c853acd
- Implemented Fragment API with methods for TON topups, Premium gifts, and Stars purchases. - Created configuration management using environment variables. - Added detailed README documentation for installation, configuration, and usage. - Developed utility classes for API client, wallet linking, and transaction processing. - Included example usage in main.py for easy demonstration of API functionalities. - Updated requirements.txt with necessary dependencies.
38 lines
984 B
Python
38 lines
984 B
Python
import logging
|
|
import os
|
|
import sys
|
|
from typing import Dict
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv(encoding='utf-8')
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class Config:
|
|
def __init__(self):
|
|
required_keys = ['COOKIES', 'SEED', 'HASH', 'API_KEY']
|
|
missing_keys = []
|
|
|
|
self._config = {}
|
|
|
|
for key in required_keys:
|
|
value = os.getenv(key, '').strip()
|
|
if not value:
|
|
missing_keys.append(key)
|
|
self._config[key.lower()] = value
|
|
|
|
if missing_keys:
|
|
logger.error(f"Missing required environment variables: {', '.join(missing_keys)}")
|
|
logger.error("Create .env file based on .env.example and fill all fields")
|
|
sys.exit(1)
|
|
|
|
logger.info("Configuration loaded successfully")
|
|
|
|
def get_config(self) -> Dict[str, str]:
|
|
return self._config.copy()
|
|
|
|
def get(self, key: str, default: str = '') -> str:
|
|
return self._config.get(key, default)
|