Features: - Create and manage sticker packs - Add existing sticker sets to database - Automatic image optimization (512px, WebP conversion) - GIF to animated video sticker conversion (WebM, VP9) - Background removal (local rembg + optional Remove.bg API) - Hybrid API with retry logic and usage tracking - Premium status detection - SQLite database for persistence - Docker containerization - Complete OPENCODE.md documentation Technical Stack: - python-telegram-bot 22.7 - Pillow for image processing - FFmpeg for video conversion - rembg for local background removal - aiosqlite for async database operations
38 lines
985 B
Python
38 lines
985 B
Python
"""Configuration module for sticker bot."""
|
|
import os
|
|
import logging
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
# Logging setup
|
|
logging.basicConfig(
|
|
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
|
level=logging.INFO
|
|
)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
# Bot Configuration
|
|
BOT_TOKEN = os.getenv("BOT_TOKEN")
|
|
OWNER_ID = os.getenv("OWNER_ID")
|
|
|
|
if not BOT_TOKEN:
|
|
raise ValueError("BOT_TOKEN must be set in .env file")
|
|
|
|
if not OWNER_ID:
|
|
raise ValueError("OWNER_ID must be set in .env file")
|
|
|
|
try:
|
|
OWNER_ID = int(OWNER_ID)
|
|
except ValueError:
|
|
raise ValueError("OWNER_ID must be a valid integer")
|
|
|
|
# Database Configuration
|
|
DATABASE_PATH = os.getenv("DATABASE_PATH", "sticker_bot.db")
|
|
|
|
# Premium Check Interval (in hours)
|
|
PREMIUM_CHECK_INTERVAL = int(os.getenv("PREMIUM_CHECK_INTERVAL", "24"))
|
|
|
|
# Optional: Remove.bg API Key for background removal
|
|
# If not set, only local processing is available
|
|
REMOVE_BG_API_KEY = os.getenv("REMOVE_BG_API_KEY") |