understanding commited on
Commit
0dca8ee
·
verified ·
1 Parent(s): bf069a4

Create config.py

Browse files
Files changed (1) hide show
  1. config.py +73 -0
config.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # config.py
2
+ import os
3
+ import logging
4
+ from dotenv import load_dotenv
5
+
6
+ # Load .env file if exists (for local testing)
7
+ load_dotenv()
8
+
9
+ logger = logging.getLogger(__name__)
10
+
11
+ class Config:
12
+ # --- Essential Secrets (Read from Environment/HF Secrets) ---
13
+ BOT_TOKEN = os.getenv('BOT_TOKEN')
14
+ API_ID = os.getenv('API_ID')
15
+ API_HASH = os.getenv('API_HASH')
16
+
17
+ # --- Admin Configuration ---
18
+ # !!! REPLACE 123456789 WITH YOUR ACTUAL ADMIN TELEGRAM USER ID(S) !!!
19
+ ADMIN_IDS = [123456789] # Example: [123456789, 987654321]
20
+
21
+ # --- Validate Secrets ---
22
+ if not BOT_TOKEN:
23
+ logger.critical("BOT_TOKEN missing!")
24
+ raise ValueError("BOT_TOKEN environment variable not set! Add it to Hugging Face Secrets.")
25
+ if not API_ID:
26
+ logger.critical("API_ID missing!")
27
+ raise ValueError("API_ID environment variable not set! Add it to Hugging Face Secrets.")
28
+ if not API_HASH:
29
+ logger.critical("API_HASH missing!")
30
+ raise ValueError("API_HASH environment variable not set! Add it to Hugging Face Secrets.")
31
+ try:
32
+ API_ID = int(API_ID)
33
+ except ValueError:
34
+ logger.critical("API_ID is not an integer!")
35
+ raise ValueError("API_ID environment variable must be an integer.")
36
+ if not ADMIN_IDS or not all(isinstance(admin_id, int) for admin_id in ADMIN_IDS):
37
+ logger.warning("ADMIN_IDS list is empty or contains non-integer values. Defaulting to empty. Check configuration.")
38
+ ADMIN_IDS = []
39
+ else:
40
+ logger.info(f"Admin IDs loaded: {ADMIN_IDS}")
41
+
42
+
43
+ # --- File Paths & Directories ---
44
+ PREDEFINED_TEMPLATES_DIR = "templates" # Relative to /app in Docker
45
+ OUTPUT_DIR = "generated_images" # Relative to /app in Docker
46
+ FONT_PATH = "Arial" # Relies on system font installed via Dockerfile
47
+ SESSION_NAME = "bot_hydro_session" # Hydrogram session file name (will be in /app)
48
+
49
+ # --- Image Processing Settings (YOU NEED TO SET THESE ACCURATELY FOR YOUR TEMPLATE) ---
50
+ TEMPLATE_SIZE = (1200, 900) # The EXACT width and height of your template PNG files.
51
+ PLACEHOLDER_SIZE = (1200, 600) # The EXACT width and height of the transparent "window"
52
+ # in your template where the user's image will go. (Example)
53
+ PLACEHOLDER_POSITION = (0, 0) # The EXACT top-left (x, y) coordinates where the
54
+ # transparent "window" starts on your template. (Example)
55
+
56
+ # Auto Template Settings (if you use them, otherwise can be ignored)
57
+ AUTO_TEMPLATES_COUNT = 3 # Reduced for quicker testing; was 5
58
+ AUTO_TEMPLATE_SIZE = (1200, 900)
59
+ AUTO_USER_IMAGE_SIZE = (600, 450)
60
+
61
+ # Text and General Image Settings
62
+ MIN_FONT_SIZE = 30
63
+ MAX_FONT_SIZE = 60
64
+ TEXT_STROKE_WIDTH = 2
65
+ NOISE_INTENSITY = 0.03
66
+ MAX_CAPTION_WIDTH = 35
67
+ JPEG_QUALITY = 85
68
+
69
+ # Example: Text placement for the caption (YOU MUST ADJUST THESE)
70
+ # These coordinates are relative to the top-left (0,0) of your TEMPLATE_SIZE canvas.
71
+ TEXT_AREA_Y_START = 700 # Example: Y-coordinate where your text background bar begins
72
+ TEXT_AREA_HEIGHT = 150 # Example: Height of your text background bar
73
+ # Horizontal centering for text is often done dynamically in processing.py