2018-02-23 23:26:21 +00:00
|
|
|
from os import listdir
|
2019-01-26 18:58:21 +00:00
|
|
|
from importlib import reload
|
|
|
|
from sys import modules
|
|
|
|
|
2019-08-25 22:12:51 +00:00
|
|
|
from utils.logging.debug import debug
|
2018-02-23 23:26:21 +00:00
|
|
|
from utils.logging.log import *
|
|
|
|
import commands
|
|
|
|
|
2019-01-26 18:58:21 +00:00
|
|
|
from main import CommandMap
|
|
|
|
|
|
|
|
def loadSingle(commandName):
|
|
|
|
if commandName+".py" in listdir("commands"):
|
2019-08-25 22:12:51 +00:00
|
|
|
className = commandName.capitalize()+"Command"
|
2018-02-23 23:26:21 +00:00
|
|
|
try:
|
2019-01-26 18:58:21 +00:00
|
|
|
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
|
|
|
|
|
2018-02-23 23:26:21 +00:00
|
|
|
except Exception as err:
|
|
|
|
return err
|
2019-01-26 18:58:21 +00:00
|
|
|
return False
|