forked from Metaboy583/SofiaMusicBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc.py
81 lines (66 loc) · 1.82 KB
/
misc.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
import socket
import time
import heroku3
from pyrogram import filters
import config
from AnonX.core.mongo import pymongodb
from .logging import LOGGER
SUDOERS = filters.user()
HAPP = None
_boot_ = time.time()
def is_heroku():
return "heroku" in socket.getfqdn()
XCB = [
"/",
"@",
".",
"com",
":",
"git",
"heroku",
"push",
str(config.HEROKU_API_KEY),
"https",
str(config.HEROKU_APP_NAME),
"HEAD",
"main",
]
def dbb():
global db
db = {}
LOGGER(__name__).info(f"Database Initialized.")
def sudo():
global SUDOERS
OWNER = config.OWNER_ID
if config.MONGO_DB_URI is None:
for user_id in OWNER:
SUDOERS.add(user_id)
else:
sudoersdb = pymongodb.sudoers
sudoers = sudoersdb.find_one({"sudo": "sudo"})
sudoers = [] if not sudoers else sudoers["sudoers"]
for user_id in OWNER:
SUDOERS.add(user_id)
if user_id not in sudoers:
sudoers.append(user_id)
sudoersdb.update_one(
{"sudo": "sudo"},
{"$set": {"sudoers": sudoers}},
upsert=True,
)
if sudoers:
for x in sudoers:
SUDOERS.add(x)
LOGGER(__name__).info(f"Sudoers Loaded.")
def heroku():
global HAPP
if is_heroku:
if config.HEROKU_API_KEY and config.HEROKU_APP_NAME:
try:
Heroku = heroku3.from_key(config.HEROKU_API_KEY)
HAPP = Heroku.app(config.HEROKU_APP_NAME)
LOGGER(__name__).info(f"Heroku App Configured")
except BaseException:
LOGGER(__name__).warning(
f"Please make sure your Heroku API Key and Your App name are configured correctly in the heroku."
)