def unload_module(self, module): """Unloads module via modules. Keyword arguments: module -- module name to unload. """ modules.unload_module(module, self.msg_parser)
def privmsg(irc, origin, args): try: irc_helpers = m("irc_helpers") except: logger.warn("Couldn't load irc_helpers.") target = args[0] args = args[1].split(" ") if args[0] == "KB3" and len(args) >= 2: command = args[1].lower() try: if not m("security").check_action_permissible(origin, "kb3:%s" % command): irc_helpers.message(irc, target, "You do not have the required access level to do this.") return except ModuleNotLoaded: pass args = args[2:] if command == "ping": irc_helpers.message(irc, target, "PONG!") elif command == "unload": for module in args: try: modules.unload_module(module) irc_helpers.message(irc, target, "Unloaded %s" % module) except ModuleNotLoaded: irc_helpers.message(irc, target, "Couldn't unload %s; it's not loaded." % module) elif command == "load" or command == "reload": for module in args: try: if module in modules.mods: modules.unload_module(module) modules.load_module(module) except Exception, msg: irc_helpers.message(irc, target, "Couldn't load %s: %s" % (module, msg)) else: irc_helpers.message(irc, target, "Loaded %s" % module) elif command == "raw": irc.raw(" ".join(args)) irc_helpers.message(irc, target, "Sent message.") elif command == "threads": threads = u" · ".join( sorted(["~B%s~B: %s" % (x.__class__.__name__, x.getName()) for x in threading.enumerate()]) ) irc_helpers.message(irc, target, "~B[Threading]~B %s" % threads) elif command == "modules": mod = u" · ".join(sorted(modules.mods.keys())) irc_helpers.message(irc, target, "~B[Modules]~B %s" % mod) elif command == "terminate": reason = "" if len(args) > 0: reason = " ".join(args) module_list = modules.mods.keys() for module in module_list: modules.unload_module(module) for network in networks.networks: networks.networks[network].disconnect(reason=reason)
def main(backdoor=True): # Open the back door, if we want it. if backdoor: eventlet.spawn(eventlet.backdoor.backdoor_server, eventlet.listen(('localhost', 6666)), { 'load_module': lambda x: modules.load_module(x), 'unload_module': lambda x: modules.unload_module(x), 'm': lambda x: modules.get_module(x), }) # Create our server. listener = core.listener.Listener() modules.set_server(listener) # Load modules as appropriate (manually for now) modules.load_module('user_manager') modules.load_module('channel_manager') modules.load_module('motd') modules.load_module('ping') modules.load_module('whois') modules.load_module('idle') modules.load_module('privmsg') # Go go go! listener.run()
def stopFactory(self): for mod in config.parse_modules(self.config_dict): modules.unload_module(mod)
def command_unload(interface,command,args): """~unload modname - Unload a module.""" if modules.unload_module(args): interface.reply("Unloaded %s"%args) else: interface.reply("No module called "+args)