Ejemplo n.º 1
0
def unloadPlugin(name):
    global ircc
    package = "plugins.%s.main" % name
    plugname = "plugins.%s" % name
    if (name in loadedPlugins) == False:
        return "%s is not loaded" % name
    else:
        try:
            if hasattr(sys.modules[package], "priv_%s" % name):
                coha.priv_remove(name)
            if hasattr(sys.modules[package], "pub_%s" % name):
                coha.pub_remove(name)
            if hasattr(sys.modules[package], "pubhandler_%s" % name):
                func = getattr(sys.modules[package], "pubhandler_%s" % name)
                coha.pubhandler_remove(func)
            if hasattr(sys.modules[package], "pubadmin_%s" % name):
                ad.removePubAdmin(name)
            if hasattr(sys.modules[package], "privadmin_%s" % name):
                ad.removePrvAdmin(name)
            if hasattr(sys.modules[package], "privhandler_%s" % name):
                func = getattr(sys.modules[package], "privhandler_%s" % name)
                coha.privhandler_remove(func)
            if hasattr(sys.modules[package], "joinhandler_%s" % name):
                funcj = getattr(sys.modules[package], "joinhandler_%s" % name)
                ircc.remove_global_handler("join", funcj)
            if hasattr(sys.modules[package], "unloader_%s" % name):
                func = getattr(sys.modules[package], "unloader_%s" % name)
                func()
            loadedPlugins.remove(name)
            for n in sys.modules.keys():
                if n.startswith(plugname) == True:
                    del (sys.modules[n])
            return "Done!"
        except Exception:  # Catching exceptions to avoid crashes...
            exc_type, exc_value, exc_traceback = sys.exc_info()
            traceback.print_exception(
                exc_type, exc_value, exc_traceback, file=sys.stdout
            )  # printing the exceptions without exit the program
            return "An error occurred please check the errors.log in logs directory"
Ejemplo n.º 2
0
def remove_help(cmd, wh):
    if wh == "pm":
        coha.priv_remove(cmd)
    if wh == "pub":
        coha.pub_remove(cmd)