27 lines
888 B
Python
27 lines
888 B
Python
from os import listdir
|
|
from importlib import reload
|
|
from sys import modules
|
|
|
|
from utils.logging.log import *
|
|
import commands
|
|
|
|
from main import CommandMap
|
|
|
|
def loadSingle(commandName):
|
|
if commandName+".py" in listdir("commands"):
|
|
className = commandName.capitalize()
|
|
try:
|
|
if commandName in CommandMap.keys():
|
|
reload(modules["commands."+commandName])
|
|
CommandMap[commandName] = getattr(modules["commands."+commandName], className)
|
|
debug("Reloaded command: %s" % commandName)
|
|
return "RELOAD"
|
|
module = __import__('commands.%s' % commandName)
|
|
CommandMap[commandName] = getattr(getattr(module, commandName), className)
|
|
debug("Registered command: %s" % commandName)
|
|
return True
|
|
|
|
except Exception as err:
|
|
return err
|
|
return False
|