-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.py
113 lines (98 loc) · 3.46 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
import time
import re
import os
from os import environ
from dotenv import load_dotenv
from pyrogram import Client, __version__
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from pyrogram import Client, enums
import string
from pyrogram.raw.all import layer
import random
import re
import os
from os import environ
from dotenv import load_dotenv
import time, requests
from pyrogram import __version__
from platform import python_version
from helper_func.dbhelper import Database as Db
db = Db().setup()
from pyrogram import Client, __version__
botStartTime = time.time()
import pyrogram
from pyrogram import Client, enums
import logging
import logging.config
import logging
logging.basicConfig(
format='%(name)s - %(levelname)s - %(message)s',
handlers=[logging.FileHandler('log.txt'),
logging.StreamHandler()],
level=logging.INFO
)
LOGGER = logging
botStartTime2 = time.time()
if os.path.exists('config.env'):
load_dotenv('config.env')
id_pattern = re.compile(r'^.\d+$')
def is_enabled(value:str):
return bool(str(value).lower() in ["true", "1", "e", "d"])
def get_config_from_url():
CONFIG_FILE_URL = os.environ.get('CONFIG_FILE_URL', None)
try:
if len(CONFIG_FILE_URL) == 0: raise TypeError
try:
res = requests.get(CONFIG_FILE_URL)
if res.status_code == 200:
LOGGER.info("Config uzaktan alındı. Status 200.")
with open('config.env', 'wb+') as f:
f.write(res.content)
f.close()
else:
LOGGER.error(f"Failed to download config.env {res.status_code}")
except Exception as e:
LOGGER.error(f"CONFIG_FILE_URL: {e}")
except TypeError:
pass
get_config_from_url()
if os.path.exists('config.env'): load_dotenv('config.env')
id_pattern = re.compile(r'^.\d+$')
LOGGER.info("--- CONFIGS STARTS HERE ---")
class Config:
DEF_WATER_MARK_FILE = ""
ENCODE_DIR = 'encodes'
MOLY_LINKLERI = list(set(x for x in environ.get("MOLY_LINKLERI", ".cloud").split()))
APP_ID = os.environ.get("APP_ID", None)
API_HASH = os.environ.get("API_HASH", None)
BOT_TOKEN = os.environ.get("BOT_TOKEN", None)
CHUNK_SIZE = int(os.environ.get("CHUNK_SIZE", 128))
DOWNLOAD_LOCATION = 'downloads'
DOWNLOAD_DIR = 'downloads'
OWNER_ID = os.environ.get("OWNER_ID", '1276627253')
DEPO = os.environ.get("DEPO", None)
SESSION_NAME = os.environ.get("SESSION_NAME", "")
STREAMTAPE_API_PASS = os.environ.get("STREAMTAPE_API_PASS")
STREAMTAPE_API_USERNAME = os.environ.get("STREAMTAPE_API_USERNAME")
# database uri (mongodb)
DATABASE_URL = os.environ.get("DATABASE_URL", "")
PRE_LOG = os.environ.get("PRE_LOG", "")
STRING_SESSION = os.environ.get('STRING_SESSION', '')
HTTP_PROXY = os.environ.get("HTTP_PROXY", "")
MAX_FILE_SIZE = 50000000
TG_MAX_FILE_SIZE = 4200000000
DEF_THUMB_NAIL_VID_S = os.environ.get("DEF_THUMB_NAIL_VID_S", "")
if len(STRING_SESSION) != 0:
try:
userbot = Client(
name='Userbot',
api_id=APP_ID,
api_hash=API_HASH,
session_string=STRING_SESSION,
)
userbot.start()
me = userbot.get_me()
userbot.send_message(OWNER_ID, f"Userbot Bașlatıldı..\n\n**Premium Durumu**: {me.is_premium}\n**Ad**: {me.first_name}\n**id**: {me.id}")
except Exception as e:
LOGGER.info(e)