Add modular Roblox buyer bot and documentation
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
import os
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from pathlib import Path
|
||||
|
||||
from models.config import BotConfig
|
||||
from models.stats import BotStats
|
||||
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent
|
||||
|
||||
|
||||
def _resolve_path(value: str, default: str) -> Path:
|
||||
path = Path(os.getenv(value, default))
|
||||
if path.is_absolute():
|
||||
return path
|
||||
return BASE_DIR / path
|
||||
|
||||
|
||||
def _env_int(name: str, default: int) -> int:
|
||||
raw = os.getenv(name)
|
||||
if raw is None or raw == "":
|
||||
return default
|
||||
return int(raw)
|
||||
|
||||
|
||||
def _env_float(name: str, default: float) -> float:
|
||||
raw = os.getenv(name)
|
||||
if raw is None or raw == "":
|
||||
return default
|
||||
return float(raw)
|
||||
|
||||
|
||||
def _env_bool(name: str, default: bool) -> bool:
|
||||
raw = os.getenv(name)
|
||||
if raw is None or raw == "":
|
||||
return default
|
||||
return raw.strip().lower() in {"1", "true", "yes", "on"}
|
||||
|
||||
|
||||
BOT_TOKEN = os.getenv("BOT_TOKEN", "")
|
||||
LOG_BOT_TOKEN = os.getenv("LOG_BOT_TOKEN", "") or None
|
||||
ADMIN_ID = _env_int("ADMIN_ID", 0)
|
||||
CRYPTO_PAY_TOKEN = os.getenv("CRYPTO_PAY_TOKEN", "")
|
||||
SHOP_NAME = os.getenv("SHOP_NAME", "KILL UNONY MOM")
|
||||
SHOP_CHANNEL = os.getenv("SHOP_CHANNEL", "https://t.me/bot399_start_bot")
|
||||
BOT_USERNAME = os.getenv("BOT_USERNAME", "bot399_start_bot")
|
||||
|
||||
DATABASE_DIR = _resolve_path("DATABASE_DIR", "Users")
|
||||
COOKIE_FILES_DIR = _resolve_path("COOKIE_FILES_DIR", "filesforcookie")
|
||||
CONFIG_FILE = _resolve_path("BOT_CONFIG_FILE", "bot_config.json")
|
||||
STATS_FILE = _resolve_path("BOT_STATS_FILE", "bot_stats.json")
|
||||
PROXIES_FILE = _resolve_path("PROXIES_FILE", "proxies.txt")
|
||||
ROBSEC_FILE = _resolve_path("ROBSEC_FILE", "robsec.txt")
|
||||
|
||||
MAX_RETRIES = _env_int("MAX_RETRIES", 5)
|
||||
CONCURRENT_CHECKS = _env_int("CONCURRENT_CHECKS", 50)
|
||||
REQUEST_TIMEOUT = _env_int("REQUEST_TIMEOUT", 10)
|
||||
FRESHER_BATCH_SIZE = _env_int("FRESHER_BATCH_SIZE", 10)
|
||||
|
||||
DATABASE_DIR.mkdir(parents=True, exist_ok=True)
|
||||
COOKIE_FILES_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
FRESHER_POOL = ThreadPoolExecutor(max_workers=64, thread_name_prefix="fresher")
|
||||
|
||||
DEFAULT_CONFIG = BotConfig.default()
|
||||
DEFAULT_STATS = BotStats.default()
|
||||
|
||||
BOT_ENABLED_DEFAULT = _env_bool("BOT_ENABLED_DEFAULT", True)
|
||||
SHOP_ENABLED_DEFAULT = _env_bool("SHOP_ENABLED_DEFAULT", True)
|
||||
MIN_WITHDRAW_DEFAULT = _env_float("MIN_WITHDRAW_DEFAULT", 100.0)
|
||||
|
||||
# Apply deployment defaults before the first config file is created.
|
||||
DEFAULT_CONFIG.bot_enabled = BOT_ENABLED_DEFAULT
|
||||
DEFAULT_CONFIG.shop_enabled = SHOP_ENABLED_DEFAULT
|
||||
DEFAULT_CONFIG.min_withdraw = MIN_WITHDRAW_DEFAULT
|
||||
Reference in New Issue
Block a user