Spaces:
Sleeping
Sleeping
iamgojoof6eyes
commited on
Commit
·
1b4a9e6
0
Parent(s):
Initial commit
Browse files- Powers/__init.py +139 -0
- Powers/core/decorators/errors.py +0 -0
- Powers/core/filters.py +0 -0
- Powers/core/types/__init__.py +0 -0
- Powers/modules/__init__.py +0 -0
- Powers/utils/__init__.py +0 -0
Powers/__init.py
ADDED
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datetime import datetime
|
2 |
+
from importlib import import_module as imp_mod
|
3 |
+
from logging import INFO, WARNING, FileHandler, StreamHandler, basicConfig, getLogger
|
4 |
+
from os import environ, mkdir, path
|
5 |
+
from sys import exit as sysexit
|
6 |
+
from sys import stdout, version_info
|
7 |
+
from time import time
|
8 |
+
from traceback import format_exc
|
9 |
+
|
10 |
+
LOG_DATETIME = datetime.now().strftime("%d_%m_%Y-%H_%M_%S")
|
11 |
+
LOGDIR = f"{__name__}/logs"
|
12 |
+
|
13 |
+
# Make Logs directory if it does not exixts
|
14 |
+
if not path.isdir(LOGDIR):
|
15 |
+
mkdir(LOGDIR)
|
16 |
+
|
17 |
+
LOGFILE = f"{LOGDIR}/{__name__}_{LOG_DATETIME}_log.txt"
|
18 |
+
|
19 |
+
file_handler = FileHandler(filename=LOGFILE)
|
20 |
+
stdout_handler = StreamHandler(stdout)
|
21 |
+
|
22 |
+
basicConfig(
|
23 |
+
format="%(asctime)s - [Gojo_Satarou] - %(levelname)s - %(message)s",
|
24 |
+
level=INFO,
|
25 |
+
handlers=[file_handler, stdout_handler],
|
26 |
+
)
|
27 |
+
|
28 |
+
getLogger("pyrogram").setLevel(WARNING)
|
29 |
+
LOGGER = getLogger(__name__)
|
30 |
+
|
31 |
+
# if version < 3.9, stop bot.
|
32 |
+
if version_info[0] < 3 or version_info[1] < 7:
|
33 |
+
LOGGER.error(
|
34 |
+
(
|
35 |
+
"You MUST have a Python Version of at least 3.7!\n"
|
36 |
+
"Multiple features depend on this. Bot quitting."
|
37 |
+
),
|
38 |
+
)
|
39 |
+
sysexit(1) # Quit the Script
|
40 |
+
|
41 |
+
# the secret configuration specific things
|
42 |
+
try:
|
43 |
+
if environ.get("ENV"):
|
44 |
+
from Powers.vars import Config
|
45 |
+
else:
|
46 |
+
from Powers.vars import Development as Config
|
47 |
+
except Exception as ef:
|
48 |
+
LOGGER.error(ef) # Print Error
|
49 |
+
LOGGER.error(format_exc())
|
50 |
+
sysexit(1)
|
51 |
+
|
52 |
+
LOGGER.info("------------------------")
|
53 |
+
LOGGER.info("| Gojo_Satarou |")
|
54 |
+
LOGGER.info("------------------------")
|
55 |
+
LOGGER.info(f"Version: {Config.VERSION}")
|
56 |
+
LOGGER.info(f"Owner: {str(Config.OWNER_ID)}")
|
57 |
+
LOGGER.info("Source Code: https://github.com/iamgojoof6eyes/Gojo_Satarou\n")
|
58 |
+
|
59 |
+
# Account Related
|
60 |
+
BOT_TOKEN = Config.BOT_TOKEN
|
61 |
+
APP_ID = Config.APP_ID
|
62 |
+
API_HASH = Config.API_HASH
|
63 |
+
|
64 |
+
# General Config
|
65 |
+
MESSAGE_DUMP = Config.MESSAGE_DUMP
|
66 |
+
SUPPORT_GROUP = Config.SUPPORT_GROUP
|
67 |
+
SUPPORT_CHANNEL = Config.SUPPORT_CHANNEL
|
68 |
+
|
69 |
+
# Users Config
|
70 |
+
OWNER_ID = Config.OWNER_ID
|
71 |
+
DEV_USERS = Config.DEV_USERS
|
72 |
+
SUDO_USERS = Config.SUDO_USERS
|
73 |
+
WHITELIST_USERS = Config.WHITELIST_USERS
|
74 |
+
SUPPORT_STAFF = list(
|
75 |
+
set([int(OWNER_ID)] + SUDO_USERS + DEV_USERS + WHITELIST_USERS),
|
76 |
+
) # Remove duplicates by using a set
|
77 |
+
|
78 |
+
# Plugins, DB and Workers
|
79 |
+
DB_URI = Config.DB_URI
|
80 |
+
DB_NAME = Config.DB_NAME
|
81 |
+
NO_LOAD = Config.NO_LOAD
|
82 |
+
WORKERS = Config.WORKERS
|
83 |
+
|
84 |
+
# Prefixes
|
85 |
+
ENABLED_LOCALES = Config.ENABLED_LOCALES
|
86 |
+
VERSION = Config.VERSION
|
87 |
+
|
88 |
+
HELP_COMMANDS = {} # For help menu
|
89 |
+
UPTIME = time() # Check bot uptime
|
90 |
+
|
91 |
+
|
92 |
+
async def load_cmds(all_plugins):
|
93 |
+
"""Loads all the plugins in bot."""
|
94 |
+
for single in all_plugins:
|
95 |
+
# If plugin in NO_LOAD, skip the plugin
|
96 |
+
if single.lower() in [i.lower() for i in Config.NO_LOAD]:
|
97 |
+
LOGGER.warning(f"Not loading '{single}' s it's added in NO_LOAD list")
|
98 |
+
continue
|
99 |
+
|
100 |
+
imported_module = imp_mod("Powers.plugins." + single)
|
101 |
+
if not hasattr(imported_module, "__PLUGIN__"):
|
102 |
+
continue
|
103 |
+
|
104 |
+
plugin_name = imported_module.__PLUGIN__.lower()
|
105 |
+
plugin_dict_name = f"plugins.{plugin_name}.main"
|
106 |
+
|
107 |
+
if plugin_dict_name in HELP_COMMANDS:
|
108 |
+
raise Exception(
|
109 |
+
(
|
110 |
+
"Can't have two plugins with the same name! Please change one\n"
|
111 |
+
f"Error while importing '{imported_module.__name__}'"
|
112 |
+
),
|
113 |
+
)
|
114 |
+
|
115 |
+
HELP_COMMANDS[plugin_dict_name] = {
|
116 |
+
"buttons": [],
|
117 |
+
"disablable": [],
|
118 |
+
"alt_cmds": [],
|
119 |
+
"help_msg": f"plugins.{plugin_name}.help",
|
120 |
+
}
|
121 |
+
|
122 |
+
if hasattr(imported_module, "__buttons__"):
|
123 |
+
HELP_COMMANDS[plugin_dict_name]["buttons"] = imported_module.__buttons__
|
124 |
+
if hasattr(imported_module, "_DISABLE_CMDS_"):
|
125 |
+
HELP_COMMANDS[plugin_dict_name][
|
126 |
+
"disablable"
|
127 |
+
] = imported_module._DISABLE_CMDS_
|
128 |
+
if hasattr(imported_module, "__alt_name__"):
|
129 |
+
HELP_COMMANDS[plugin_dict_name]["alt_cmds"] = imported_module.__alt_name__
|
130 |
+
|
131 |
+
# Add the plugin name to cmd list
|
132 |
+
(HELP_COMMANDS[plugin_dict_name]["alt_cmds"]).append(plugin_name)
|
133 |
+
if NO_LOAD:
|
134 |
+
LOGGER.warning(f"Not loading Plugins - {NO_LOAD}")
|
135 |
+
|
136 |
+
return (
|
137 |
+
", ".join((i.split(".")[1]).capitalize() for i in list(HELP_COMMANDS.keys()))
|
138 |
+
+ "\n"
|
139 |
+
)
|
Powers/core/decorators/errors.py
ADDED
File without changes
|
Powers/core/filters.py
ADDED
File without changes
|
Powers/core/types/__init__.py
ADDED
File without changes
|
Powers/modules/__init__.py
ADDED
File without changes
|
Powers/utils/__init__.py
ADDED
File without changes
|