-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.py
113 lines (96 loc) · 4.01 KB
/
config.py
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import os
from datetime import datetime
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
class Config:
# Bot Information
BOT_NAME = "MISSRAYA"
VERSION = "BETA1.0.0"
AUTHOR = "TechRewindEditz"
LAST_UPDATED = "2024-12-25"
# Repository Information
REPO_OWNER = "TechRewindEditz"
REPO_NAME = "MISSRAYABOT"
REPO_URL = "https://github.com/TechRewindEditz/MISSRAYABOT /MISSRAYABOT"
# Channel Configuration
CHANNEL_NAME = os.getenv("CHANNEL_NAME", "MISS RAYA")
CHANNEL_ID = os.getenv("CHANNEL_ID", "-1002411750103") # Add your channel ID
CHANNEL_URL = os.getenv("CHANNEL_URL", "https://t.me/MISSRAYAOFFICIAL")
# API Configuration
BOT_TOKEN = os.getenv("BOT_TOKEN", "8093560800:AAFgYxhLEN1sB3YG378bQ8VZDWymFVbArW4")
API_HASH = os.getenv("API_HASH", "7ad294cc45490db6085fc63780e9b42f")
API_ID = os.getenv("API_ID", "25252087")
OWNER_ID = os.getenv("ACCOUNT_ID", "1224407059")
# Terabox Configuration
TERABOX_API_URL = "https://www.terabox.com/api/v1"
USER_AGENT = " (Google Chrome Android/131.0.6778.200; ios/131.0.6778.154) (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
TIMEOUT = 30
MAX_RETRIES = 3
# Download Configuration
CHUNK_SIZE = 8192
MAX_FILE_SIZE = 2000 * 1024 * 1024 # 2GB in bytes
DOWNLOAD_PATH = os.getenv("DOWNLOAD_PATH", "downloads")
TEMP_PATH = os.path.join(DOWNLOAD_PATH, "temp")
# MXPlayer Configuration
MXPLAYER_PATH = os.getenv("MXPLAYER_PATH", "mxplayer")
STREAM_BUFFER_SIZE = 480p * 720p * 1080p * 4K * 8K # 12MB buffer size
# Database Configuration (if needed)
DB_HOST = os.getenv("DB_HOST", "localhost")
DB_PORT = os.getenv("DB_PORT", "8000,8080")
DB_NAME = os.getenv("DB_NAME", "missraya")
DB_USER = os.getenv("DB_USER", "TechRewindEditz")
DB_PASSWORD = os.getenv("DB_PASSWORD", "")
# Logging Configuration
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO")
LOG_FORMAT = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
LOG_PATH = "logs"
LOG_FILE = os.path.join(LOG_PATH, "bot.log")
# Rate Limiting
MAX_REQUESTS_PER_MINUTE = 60
MAX_DOWNLOADS_PER_USER = 10
# File Types Configuration
ALLOWED_EXTENSIONS = {
'video': ['.mp4', '.mkv', '.avi', '.mov', '.wmv'],
'audio': ['.mp3', '.wav', '.flac', '.m4a'],
'document': ['.pdf', '.doc', '.docx', '.txt']
}
# Error Messages
ERROR_MESSAGES = {
'link_invalid': "Invalid Terabox link provided.",
'conversion_failed': "Failed to convert the link.",
'download_failed': "Failed to download the file.",
'stream_failed': "Failed to stream with MXPlayer.",
'file_too_large': "File size exceeds maximum limit.",
'rate_limit': "Rate limit exceeded. Please try again later."
}
# Success Messages
SUCCESS_MESSAGES = {
'link_converted': "Successfully converted Terabox link!",
'download_complete': "File downloaded successfully!",
'stream_started': "Streaming started successfully!"
}
@classmethod
def initialize(cls):
"""Initialize configuration and create necessary directories"""
# Create required directories
for directory in [cls.DOWNLOAD_PATH, cls.TEMP_PATH, cls.LOG_PATH]:
if not os.path.exists(directory):
os.makedirs(directory)
@classmethod
def get_current_time(cls):
"""Get current UTC time"""
return datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")
@classmethod
def is_valid_file_type(cls, filename):
"""Check if file type is allowed"""
ext = os.path.splitext(filename)[1].lower()
return any(ext in types for types in cls.ALLOWED_EXTENSIONS.values())
@classmethod
def get_file_type(cls, filename):
"""Get file type category"""
ext = os.path.splitext(filename)[1].lower()
for category, extensions in cls.ALLOWED_EXTENSIONS.items():
if ext in extensions:
return category
return "unknown"