-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
57 lines (45 loc) · 1.88 KB
/
config.py
File metadata and controls
57 lines (45 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import logging
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
# Bot configuration
BOT_TOKEN = os.getenv("BOT_TOKEN")
ADMIN_IDS = [int(id) for id in os.getenv("ADMIN_ID").split(",")]
CHANNEL_ID = int(os.getenv("CHANNEL_ID"))
AUTH_GROUPS = [int(id) for id in os.getenv("AUTH_GRP").split(",")]
DATABASE_URL = os.getenv("DATABASE_URL", "movies.db")
# Dynamic channel configuration
def get_required_channels():
"""Dynamically build the list of required channels from environment variables."""
channels = []
i = 1
while True:
channel_id_key = f"REQUIRED_CHANNEL{i}_ID"
channel_id = os.getenv(channel_id_key)
if not channel_id:
break # No more channels defined
channels.append({
'channel_id': int(channel_id),
'channel_name': os.getenv(f"REQUIRED_CHANNEL{i}_NAME", f"Channel {i}"),
'invite_link': os.getenv(f"REQUIRED_CHANNEL{i}_LINK", f"https://t.me/channel{i}")
})
i += 1
# If no channels were defined, use the main channel as a fallback
if not channels:
channels.append({
'channel_id': CHANNEL_ID,
'channel_name': "FlickFusion Movies",
'invite_link': os.getenv("REQUIRED_CHANNEL1_LINK", "https://t.me/your_channel")
})
return channels
# Force join configuration
REQUIRED_CHANNELS = get_required_channels()
# Log the channels that will be required
logger = logging.getLogger(__name__)
logger.info(f"Requiring membership in {len(REQUIRED_CHANNELS)} channels:")
for i, channel in enumerate(REQUIRED_CHANNELS):
logger.info(f" {i+1}. {channel['channel_name']} (ID: {channel['channel_id']})")
# Validate configuration
if not all([BOT_TOKEN, ADMIN_IDS, CHANNEL_ID, AUTH_GROUPS]):
raise ValueError("Missing required environment variables. Check your .env file.")