def load_module(self, module):
        """Loads module via modules.

        Keyword arguments:
            module -- module name to load.

        """

        modules.load_module(module, self.msg_parser)
Пример #2
0
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)
Пример #3
0
def main():
    import locale
    locale.setlocale(locale.LC_NUMERIC, '')
    
    for module in config.modules:
        modules.load_module(module)
    
    for name in config.networks:
        network = config.networks[name]
        networks.connect(network)
    
    logging.info("Ready.")
Пример #4
0
Файл: irc.py Проект: hcit/HxIRC
 def startFactory(self):
     print config.parse_modules(self.config_dict)
     for mod in config.parse_modules(self.config_dict):
         modules.load_module(mod)
Пример #5
0
        "module": args.module,
        "config": conf,
        "log": logging,
        "db_file": conf['sqlite3']['database'],
        "db": sql3.connection.Connection(conf['sqlite3']['database']),
        "args": app_modules.parse_custom_arguments(args.carg)
        if len(args.carg) > 0 else {},
    }

    sql3.create_tables(conf['sqlite3']['database'])

    if not app_modules.module_exists("%s/modules/%s" % (app_dir, args.module)):
        l.error("Module %s does not exists" % args.module)
        quit()

    mod = app_modules.load_module(args.module)

    if hasattr(mod, args.action):
        method = getattr(mod, args.action)
        v = method(**options)

        if v is None:
            v = 0

        sys.exit(int(v))
        try:
            options['db'].close()
        except:
            l.warning("Unable to close database %s")
    else:
        l.warning("Module does not have %s action" % args.action)
Пример #6
0
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()