Implement loading new modules at runtime
parent
cb7142ef88
commit
378c4d9bba
@ -0,0 +1,23 @@
|
||||
from core.main import *
|
||||
from utils.loaders.single_loader import loadSingle
|
||||
|
||||
class Loadmod:
|
||||
def __init__(self, register):
|
||||
register("loadmod", self.loadmod)
|
||||
|
||||
def loadmod(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||
if authed:
|
||||
if length == 2:
|
||||
rtrn = loadSingle(spl[1], register)
|
||||
if rtrn == True:
|
||||
success("Loaded module %s" % spl[1])
|
||||
return
|
||||
else:
|
||||
failure("Error loading module %s: %s" % (spl[1], rtrn))
|
||||
return
|
||||
else:
|
||||
incUsage("loadmod")
|
||||
return
|
||||
else:
|
||||
incUsage(None)
|
||||
return
|
@ -0,0 +1,17 @@
|
||||
from os import listdir
|
||||
from core.main import *
|
||||
from utils.logging.log import *
|
||||
import commands
|
||||
|
||||
def loadSingle(command, func):
|
||||
if command+".py" in listdir("commands"):
|
||||
try:
|
||||
if command in CommandMap.keys():
|
||||
return "Cannot reload modules"
|
||||
else:
|
||||
className = command.capitalize()
|
||||
__import__("commands.%s" % command)
|
||||
eval("commands.%s.%s(func)" % (command, className))
|
||||
return True
|
||||
except Exception as err:
|
||||
return err
|
Loading…
Reference in New Issue