1- import os
2- import importlib
31import asyncio
4-
52from 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
158loop = 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
5112async 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
6323async 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