Spaces:
Runtime error
Runtime error
Update Hellbot/core/initializer.py
Browse files- Hellbot/core/initializer.py +94 -94
Hellbot/core/initializer.py
CHANGED
@@ -1,94 +1,94 @@
|
|
1 |
-
import sys
|
2 |
-
from .clients import hellbot
|
3 |
-
from .config import Config, Symbols
|
4 |
-
from .database import db
|
5 |
-
from .logger import LOGS
|
6 |
-
|
7 |
-
|
8 |
-
async def _AuthUsers() -> None:
|
9 |
-
temp_list = []
|
10 |
-
temp_list.append(Config.OWNER_ID)
|
11 |
-
temp_list.extend([(await client.get_me()).id for client in hellbot.users])
|
12 |
-
|
13 |
-
stan_users = await db.get_all_stans()
|
14 |
-
for user in stan_users:
|
15 |
-
temp_list.append(user["user_id"])
|
16 |
-
|
17 |
-
users = list(set(temp_list))
|
18 |
-
for user in users:
|
19 |
-
Config.AUTH_USERS.add(user)
|
20 |
-
|
21 |
-
temp_list = None
|
22 |
-
LOGS.info(
|
23 |
-
f"{Symbols.arrow_right * 2} Added Authorized Users {Symbols.arrow_left * 2}"
|
24 |
-
)
|
25 |
-
|
26 |
-
|
27 |
-
async def _StanUsers() -> None:
|
28 |
-
users = await db.get_all_stans()
|
29 |
-
for user in users:
|
30 |
-
Config.STAN_USERS.add(user["user_id"])
|
31 |
-
|
32 |
-
LOGS.info(f"{Symbols.arrow_right * 2} Added Stan Users {Symbols.arrow_left * 2}")
|
33 |
-
|
34 |
-
|
35 |
-
async def _GbanUsers() -> None:
|
36 |
-
users = await db.get_gban()
|
37 |
-
for user in users:
|
38 |
-
Config.BANNED_USERS.add(user["user_id"])
|
39 |
-
|
40 |
-
LOGS.info(
|
41 |
-
f"{Symbols.arrow_right * 2} Added {len(users)} Gbanned Users {Symbols.arrow_left * 2}"
|
42 |
-
)
|
43 |
-
|
44 |
-
musers = await db.get_gmute()
|
45 |
-
for user in musers:
|
46 |
-
Config.MUTED_USERS.add(user["user_id"])
|
47 |
-
|
48 |
-
LOGS.info(
|
49 |
-
f"{Symbols.arrow_right * 2} Added {len(musers)} Gmuted Users {Symbols.arrow_left * 2}"
|
50 |
-
)
|
51 |
-
|
52 |
-
|
53 |
-
async def UserSetup() -> None:
|
54 |
-
"""Initialize Users Config"""
|
55 |
-
LOGS.info(f"{Symbols.bullet * 3} Setting Up Users {Symbols.bullet * 3}")
|
56 |
-
await _AuthUsers()
|
57 |
-
await _StanUsers()
|
58 |
-
await _GbanUsers()
|
59 |
-
|
60 |
-
|
61 |
-
async def ForcesubSetup() -> None:
|
62 |
-
"""Initialize Forcesub Config"""
|
63 |
-
chats = await db.get_all_forcesubs()
|
64 |
-
for chat in chats:
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
async def GachaBotsSetup() -> None:
|
70 |
-
"""Initialize GachaBots Config"""
|
71 |
-
bots = await db.get_all_gachabots_id()
|
72 |
-
for bot in bots:
|
73 |
-
Config.GACHA_BOTS.add(bot)
|
74 |
-
|
75 |
-
|
76 |
-
async def TemplateSetup() -> None:
|
77 |
-
"""Initialize Templates Config"""
|
78 |
-
module_name = "temp_module"
|
79 |
-
module = sys.modules.get(module_name)
|
80 |
-
if module is None:
|
81 |
-
module = type(sys)(module_name)
|
82 |
-
|
83 |
-
with open("Hellbot/functions/templates.py", "r", encoding="utf-8") as file:
|
84 |
-
exec(file.read(), module.__dict__)
|
85 |
-
|
86 |
-
global_vars = module.__dict__
|
87 |
-
|
88 |
-
var_n_value: dict[str, str] = {
|
89 |
-
var_name: global_vars[var_name][0]
|
90 |
-
for var_name in global_vars
|
91 |
-
if var_name.isupper() and not callable(global_vars[var_name])
|
92 |
-
}
|
93 |
-
|
94 |
-
Config.TEMPLATES = var_n_value
|
|
|
1 |
+
import sys
|
2 |
+
from .clients import hellbot
|
3 |
+
from .config import Config, Symbols
|
4 |
+
from .database import db
|
5 |
+
from .logger import LOGS
|
6 |
+
|
7 |
+
|
8 |
+
async def _AuthUsers() -> None:
|
9 |
+
temp_list = []
|
10 |
+
temp_list.append(Config.OWNER_ID)
|
11 |
+
temp_list.extend([(await client.get_me()).id for client in hellbot.users])
|
12 |
+
|
13 |
+
stan_users = await db.get_all_stans()
|
14 |
+
for user in stan_users:
|
15 |
+
temp_list.append(user["user_id"])
|
16 |
+
|
17 |
+
users = list(set(temp_list))
|
18 |
+
for user in users:
|
19 |
+
Config.AUTH_USERS.add(user)
|
20 |
+
|
21 |
+
temp_list = None
|
22 |
+
LOGS.info(
|
23 |
+
f"{Symbols.arrow_right * 2} Added Authorized Users {Symbols.arrow_left * 2}"
|
24 |
+
)
|
25 |
+
|
26 |
+
|
27 |
+
async def _StanUsers() -> None:
|
28 |
+
users = await db.get_all_stans()
|
29 |
+
for user in users:
|
30 |
+
Config.STAN_USERS.add(user["user_id"])
|
31 |
+
|
32 |
+
LOGS.info(f"{Symbols.arrow_right * 2} Added Stan Users {Symbols.arrow_left * 2}")
|
33 |
+
|
34 |
+
|
35 |
+
async def _GbanUsers() -> None:
|
36 |
+
users = await db.get_gban()
|
37 |
+
for user in users:
|
38 |
+
Config.BANNED_USERS.add(user["user_id"])
|
39 |
+
|
40 |
+
LOGS.info(
|
41 |
+
f"{Symbols.arrow_right * 2} Added {len(users)} Gbanned Users {Symbols.arrow_left * 2}"
|
42 |
+
)
|
43 |
+
|
44 |
+
musers = await db.get_gmute()
|
45 |
+
for user in musers:
|
46 |
+
Config.MUTED_USERS.add(user["user_id"])
|
47 |
+
|
48 |
+
LOGS.info(
|
49 |
+
f"{Symbols.arrow_right * 2} Added {len(musers)} Gmuted Users {Symbols.arrow_left * 2}"
|
50 |
+
)
|
51 |
+
|
52 |
+
|
53 |
+
async def UserSetup() -> None:
|
54 |
+
"""Initialize Users Config"""
|
55 |
+
LOGS.info(f"{Symbols.bullet * 3} Setting Up Users {Symbols.bullet * 3}")
|
56 |
+
await _AuthUsers()
|
57 |
+
await _StanUsers()
|
58 |
+
await _GbanUsers()
|
59 |
+
|
60 |
+
|
61 |
+
async def ForcesubSetup() -> None:
|
62 |
+
"""Initialize Forcesub Config"""
|
63 |
+
chats = await db.get_all_forcesubs()
|
64 |
+
for chat in chats:
|
65 |
+
chat_key = chat["chat"]
|
66 |
+
if chat_key not in Config.FORCESUBS:
|
67 |
+
Config.FORCESUBS.add(chat_key)
|
68 |
+
|
69 |
+
async def GachaBotsSetup() -> None:
|
70 |
+
"""Initialize GachaBots Config"""
|
71 |
+
bots = await db.get_all_gachabots_id()
|
72 |
+
for bot in bots:
|
73 |
+
Config.GACHA_BOTS.add(bot)
|
74 |
+
|
75 |
+
|
76 |
+
async def TemplateSetup() -> None:
|
77 |
+
"""Initialize Templates Config"""
|
78 |
+
module_name = "temp_module"
|
79 |
+
module = sys.modules.get(module_name)
|
80 |
+
if module is None:
|
81 |
+
module = type(sys)(module_name)
|
82 |
+
|
83 |
+
with open("Hellbot/functions/templates.py", "r", encoding="utf-8") as file:
|
84 |
+
exec(file.read(), module.__dict__)
|
85 |
+
|
86 |
+
global_vars = module.__dict__
|
87 |
+
|
88 |
+
var_n_value: dict[str, str] = {
|
89 |
+
var_name: global_vars[var_name][0]
|
90 |
+
for var_name in global_vars
|
91 |
+
if var_name.isupper() and not callable(global_vars[var_name])
|
92 |
+
}
|
93 |
+
|
94 |
+
Config.TEMPLATES = var_n_value
|