Skip to content

Commit e4382c4

Browse files
Merge pull request #73 from beastzx18/beta-modify-modules
beta
2 parents 92207b8 + 350092c commit e4382c4

78 files changed

Lines changed: 3216 additions & 4599 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ class Config(object):
7373
TOKEN = os.getenv("TOKEN")
7474
# ---------------------
7575
THUMB_PIC = os.getenv("THUMB_PIC", "material/images/tron.png")
76+
# ---------------------
77+
TL_NAME = os.getenv("TL_NAME")
7678

7779

7880

tronx/__init__.py

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1 @@
1-
from tronx.client import (
2-
app,
3-
bot,
4-
log,
5-
6-
#user info
7-
USER_ID,
8-
USER_NAME,
9-
USER_USERNAME,
10-
USER_DC,
11-
USER_BIO,
12-
13-
# bot info
14-
BOT_NAME,
15-
BOT_ID,
16-
BOT_USERNAME,
17-
BOT_DC,
18-
19-
# configurations
20-
PREFIX,
21-
LOG_CHAT,
22-
DB_URI,
23-
WORKERS,
24-
25-
# owner details
26-
OWNER_ID,
27-
OWNER_NAME,
28-
OWNER_USERNAME,
29-
30-
# versions
31-
userbot_version,
32-
assistant_version,
33-
python_version,
34-
pyrogram_version,
35-
36-
# database
37-
db_status,
38-
39-
# functions
40-
clear,
41-
get_readable_time,
42-
add_user,
43-
exists,
44-
check_bot_in_log_chat,
45-
uptime,
46-
47-
# other
48-
StartTime,
49-
REPO,
50-
Config,
51-
telegraph,
52-
53-
# containers
54-
CMD_HELP,
55-
HELP,
56-
)
1+
from tronx.clients import app

tronx/__main__.py

Lines changed: 11 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,32 @@
1-
import os
2-
import importlib
31
import asyncio
4-
52
from pyrogram import idle
6-
from tronx.client import (
7-
app,
8-
bot,
9-
log,
10-
)
3+
from tronx.clients import app
114

125

136

147

158
loop = asyncio.get_event_loop()
169

1710

18-
def import_module(path, exclude=[], display_module=True):
19-
"""Modified version of pyrogram smart plugins"""
20-
bin = []
21-
bin.clear()
22-
23-
if not os.path.exists(path):
24-
return print(f"No path found: {path}")
25-
26-
plugins = []
27-
for x in os.listdir(path):
28-
if x.endswith(".py"):
29-
if not x in ["__pycache__", "__init__.py"]:
30-
plugins.append(x.replace(".py", ""))
31-
32-
py_path_raw = ".".join(path.split("/"))
33-
py_path = py_path_raw[0:len(py_path_raw)-1]
34-
35-
count = 0
36-
for x in plugins:
37-
if not x in exclude:
38-
importlib.import_module(py_path + "." + x)
39-
count += 1
40-
bin.append(x)
41-
42-
if display_module:
43-
data = sorted(bin)
44-
for x in data:
45-
print(x + " Loaded !")
46-
return count
47-
48-
49-
5011

5112
async def start_assistant():
5213
""" Start assistant """
53-
if bot:
54-
await bot.start()
55-
log.info("Assistant activated, startup in progress . . .\n")
14+
if app.bot:
15+
app.log.info("Assistant activated, startup in progress . . .\n")
5616
else:
57-
log.info("Assistant start unsuccessful, please check that you have given the bot token.\n")
58-
log.info("skipping assistant start !")
17+
app.log.info("Assistant start unsuccessful, please check that you have given the bot token.\n")
18+
app.log.info("skipping assistant start !")
5919

6020

6121

6222

6323
async def start_userbot():
6424
""" Start userbot """
6525
if app:
66-
await app.start()
67-
log.info("Userbot activated, startup in progress . . .\n")
26+
app.log.info("Userbot activated, startup in progress . . .\n")
6827
else:
69-
log.info("Userbot startup unsuccessful, please check everything again ...")
70-
log.info("Couldn't load modules of userbot")
28+
app.log.info("Userbot startup unsuccessful, please check everything again ...")
29+
app.log.info("Couldn't load modules of userbot")
7130

7231

7332

@@ -77,14 +36,14 @@ async def start_bot():
7736
print("___________________________________. Welcome to Tron corporation .___________________________________\n\n\n")
7837
print("initialising . . .\n\n")
7938
print("Loading plugins:\n\n")
80-
_plugs = import_module("tronx/plugins/")
39+
_plugs = app.import_module("tronx/plugins/")
8140
print(f"\n\n{_plugs} plugins Loaded\n\n")
8241
print("Loading modules:\n\n")
83-
_mods = import_module("tronx/modules/")
42+
_mods = app.import_module("tronx/modules/")
8443
print(f"\n\n{_mods} modules Loaded")
8544
await start_assistant()
8645
await start_userbot()
87-
await idle()
46+
idle()
8847

8948

9049

0 commit comments

Comments
 (0)