|
import re |
|
from os import getenv |
|
from dotenv import load_dotenv |
|
from pyrogram import filters |
|
|
|
load_dotenv() |
|
|
|
def get_env_var(var_name, default=None, required=False): |
|
value = getenv(var_name, default) |
|
if required and value is None: |
|
raise ValueError(f"Environment variable {var_name} is required but not set.") |
|
return value |
|
|
|
API_ID = int(get_env_var("API_ID", required=True)) |
|
API_HASH = get_env_var("API_HASH", required=True) |
|
BOT_TOKEN = get_env_var("BOT_TOKEN", required=True) |
|
BOT_ID = int(get_env_var("BOT_ID", "0")) |
|
BOT_USERNAME = get_env_var("BOT_USERNAME", "") |
|
OWNER = int(get_env_var("OWNER", "0")) |
|
DEVINE_BOT = int(get_env_var("DEVINE_BOT", "0")) |
|
MONGO_DB_URI = get_env_var("MONGO_DB_URI", required=True) |
|
DURATION_LIMIT_MIN = int(get_env_var("DURATION_LIMIT", 60)) |
|
LOGGER_ID = int(get_env_var("LOGGER_ID", "0")) |
|
LOG_CHANNEL_ID = int(get_env_var("LOG_CHANNEL_ID", "0")) |
|
OWNER_ID = int(get_env_var("OWNER_ID", "0")) |
|
SPECIAL_USER_ID = int(get_env_var("SPECIAL_USER_ID", "0")) |
|
HEROKU_APP_NAME = get_env_var("HEROKU_APP_NAME", "") |
|
HEROKU_API_KEY = get_env_var("HEROKU_API_KEY", "") |
|
UPSTREAM_REPO = get_env_var("UPSTREAM_REPO", "") |
|
UPSTREAM_BRANCH = get_env_var("UPSTREAM_BRANCH", "main") |
|
GIT_TOKEN = get_env_var("GIT_TOKEN", "") |
|
SUPPORT_CHANNEL = get_env_var("SUPPORT_CHANNEL", "https://t.me/dragbots") |
|
SUPPORT_CHAT = get_env_var("SUPPORT_CHAT", "https://t.me/dragbotsupport") |
|
AUTO_LEAVING_ASSISTANT = bool(get_env_var("AUTO_LEAVING_ASSISTANT", False)) |
|
SPOTIFY_CLIENT_ID = get_env_var("SPOTIFY_CLIENT_ID", "") |
|
SPOTIFY_CLIENT_SECRET = get_env_var("SPOTIFY_CLIENT_SECRET", "") |
|
PLAYLIST_FETCH_LIMIT = int(get_env_var("PLAYLIST_FETCH_LIMIT", 50)) |
|
TG_AUDIO_FILESIZE_LIMIT = int(get_env_var("TG_AUDIO_FILESIZE_LIMIT", 1073741824)) |
|
TG_VIDEO_FILESIZE_LIMIT = int(get_env_var("TG_VIDEO_FILESIZE_LIMIT", 1073741824)) |
|
STRING1 = get_env_var("STRING_SESSION", required=True) |
|
STRING2 = get_env_var("STRING_SESSION2", None) |
|
STRING3 = get_env_var("STRING_SESSION3", None) |
|
STRING4 = get_env_var("STRING_SESSION4", None) |
|
STRING5 = get_env_var("STRING_SESSION5", None) |
|
|
|
BANNED_USERS = filters.user() |
|
adminlist = {} |
|
lyrical = {} |
|
votemode = {} |
|
autoclean = [] |
|
confirmer = {} |
|
|
|
START_IMG_URL = getenv( |
|
"START_IMG_URL", "https://telegra.ph//file/db4ac98cf05117a23561c.jpg" |
|
) |
|
PING_IMG_URL = getenv( |
|
"PING_IMG_URL", "https://telegra.ph//file/8006562b937927f7f5d44.jpg" |
|
) |
|
PLAYLIST_IMG_URL = getenv("PLAYLIST_IMG_URL", "https://telegra.ph//file/38590cc5ed3f3c20c0bb2.jpg") |
|
STATS_IMG_URL = getenv("STATS_IMG_URL", "https://telegra.ph//file/3673959668f6d4a9b0a7f.jpg") |
|
TELEGRAM_AUDIO_URL = getenv("TELEGRAM_AUDIO_URL", "https://telegra.ph//file/ada746f1818a0df27dd07.jpg") |
|
TELEGRAM_VIDEO_URL = getenv("TELEGRAM_VIDEO_URL", "https://telegra.ph//file/ef6fd57813e0436a49fd9.jpg") |
|
STREAM_IMG_URL = getenv("STREAM_IMG_URL", "https://telegra.ph//file/db4ac98cf05117a23561c.jpg") |
|
SOUNCLOUD_IMG_URL = getenv("SOUNCLOUD_IMG_URL", "https://telegra.ph//file/bf1f5fced5f679079a6f4.jpg") |
|
YOUTUBE_IMG_URL = getenv("YOUTUBE_IMG_URL", "https://telegra.ph//file/bf1f5fced5f679079a6f4.jpg") |
|
SPOTIFY_ARTIST_IMG_URL = getenv("SPOTIFY_ARTIST_IMG_URL", "https://telegra.ph//file/f5dba4886f4b88ef0bc7f.jpg") |
|
SPOTIFY_ALBUM_IMG_URL = getenv("SPOTIFY_ALBUM_IMG_URL", "https://telegra.ph//file/010673cfe1de7a3950cca.jpg") |
|
SPOTIFY_PLAYLIST_IMG_URL = getenv("SPOTIFY_PLAYLIST_IMG_URL", "https://telegra.ph//file/b4cb569d48c71674080ef.jpg") |
|
STATUS_IMG_URL = getenv("STATUS_IMG_URL", "https://telegra.ph//file/1cc1cda34e5127dfb6466.jpg") |
|
|
|
def time_to_seconds(time): |
|
stringt = str(time) |
|
return sum(int(x) * 60**i for i, x in enumerate(reversed(stringt.split(":")))) |
|
|
|
DURATION_LIMIT = int(time_to_seconds(f"{DURATION_LIMIT_MIN}:00")) |
|
|
|
|
|
if SUPPORT_CHAT and not SUPPORT_CHAT.startswith(("http://", "https://")): |
|
SUPPORT_CHAT = "https://" + SUPPORT_CHAT |
|
|
|
if SUPPORT_CHANNEL and not SUPPORT_CHANNEL.startswith(("http://", "https://")): |
|
SUPPORT_CHANNEL = "https://" + SUPPORT_CHANNEL |
|
|
|
if SUPPORT_CHANNEL: |
|
if not re.match("(?:http|https)://", SUPPORT_CHANNEL): |
|
raise SystemExit("[ERROR] - Your SUPPORT_CHANNEL url is wrong. Please ensure that it starts with https://") |
|
|
|
if SUPPORT_CHAT: |
|
if not re.match("(?:http|https)://", SUPPORT_CHAT): |
|
raise SystemExit("[ERROR] - Your SUPPORT_CHAT url is wrong. Please ensure that it starts with https://") |
|
|