Ejemplo n.º 1
0
def main(args):
    """The bot's main entry point.

    | Setup logging.
    | When troubleshooting startup, it may help to change the INFO to DEBUG.
    | Initialize the bot and start processing messages.
    """
    loglevel = logging.DEBUG if args.debug else logging.INFO
    logging.basicConfig(level=loglevel)
    botconfig = ConfigParser()
    configfile = join(dirname(__file__), 'config.cfg')
    if not exists(configfile):
        print("Setting up config file")
        config.do_setup(configfile)
        return
    with open(configfile) as conf:
        botconfig.read_file(conf)
    bot = IrcBot(botconfig)
    try:
        bot.start()
    except KeyboardInterrupt:
        # keyboard interrupt means someone tried to ^C, shut down the bot
        bot.kill()
        sys.exit(0)
    except Exception as e:
        bot.kill()
        logging.error("The bot died! %s" % (e))
        (typ3, value, tb) = sys.exc_info()
        errmsg = "".join(traceback.format_exception(typ3, value, tb))
        for line in errmsg.split('\n'):
            logging.error(errmsg)
        sys.exit(1)
Ejemplo n.º 2
0
def main():
    """The bot's main entry point.

    | Initialize the bot and start processing messages.
    """
    config_file = path.join(path.dirname(__file__), 'config.cfg')
    if not path.exists(config_file):
        logging.info("Setting up config file")
        config.do_setup(config_file)
        return
    botconfig = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
    with open(config_file) as f:
        botconfig.read_file(f)
    bot = IrcBot(botconfig)
    try:
        bot.start()
    except KeyboardInterrupt:
        # KeyboardInterrupt means someone tried to ^C, so shut down the bot
        bot.disconnect('Bot received a Ctrl-C')
        bot.shutdown_mp()
        sys.exit(0)
    except Exception as ex:
        bot.shutdown_mp(False)
        logging.error("The bot died! %s" % ex)
        output = "".join(traceback.format_exc())
        for line in output.split('\n'):
            logging.error(line)
        sys.exit(1)
Ejemplo n.º 3
0
def main():
    """The bot's main entry point.

    | Initialize the bot and start processing messages.
    """
    config_file = path.join(path.dirname(__file__), 'config.cfg')
    if not path.exists(config_file):
        logging.info("Setting up config file")
        config.do_setup(config_file)
        return
    botconfig = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
    with open(config_file) as f:
        botconfig.read_file(f)
    bot = IrcBot(botconfig)
    try:
        bot.start()
    except KeyboardInterrupt:
        # KeyboardInterrupt means someone tried to ^C, so shut down the bot
        bot.disconnect('Bot received a Ctrl-C')
        bot.shutdown_mp()
        sys.exit(0)
    except Exception as ex:
        bot.shutdown_mp(False)
        logging.error("The bot died! %s" % ex)
        output = "".join(traceback.format_exc())
        for line in output.split('\n'):
            logging.error(line)
        sys.exit(1)
Ejemplo n.º 4
0
def main(args):
    """The bot's main entry point.

    | Setup logging.
    | When troubleshooting startup, it may help to change the INFO to DEBUG.
    | Initialize the bot and start processing messages.
    """
    loglevel = logging.DEBUG if args.debug else logging.INFO
    logging.basicConfig(level=loglevel)
    botconfig = ConfigParser()
    configfile = join(dirname(__file__), 'config.cfg')
    if not exists(configfile):
        print("Setting up config file")
        config.do_setup(configfile)
        return
    with open(configfile) as conf:
        botconfig.read_file(conf)
    bot = IrcBot(botconfig)
    bot.start()