Esempio n. 1
0
def main() -> None:
    options = parse_args()
    global bots_config
    try:
        bots_config = read_config_file(options.config_file, options.bot_name)
    except MissingSectionHeaderError:
        sys.exit(
            "Error: Your Botserver config file `{0}` contains an empty section header!\n"
            "You need to write the names of the bots you want to run in the "
            "section headers of `{0}`.".format(options.config_file))
    except NoOptionError as e:
        sys.exit(
            "Error: Your Botserver config file `{0}` has a missing option `{1}` in section `{2}`!\n"
            "You need to add option `{1}` with appropriate value in section `{2}` of `{0}`"
            .format(options.config_file, e.option, e.section))

    available_bots = list(bots_config.keys())
    bots_lib_modules = load_lib_modules(available_bots)
    third_party_bot_conf = parse_config_file(
        options.bot_config_file
    ) if options.bot_config_file is not None else None
    bot_handlers = load_bot_handlers(available_bots, bots_config,
                                     third_party_bot_conf)
    message_handlers = init_message_handlers(available_bots, bots_lib_modules,
                                             bot_handlers)
    app.config["BOTS_LIB_MODULES"] = bots_lib_modules
    app.config["BOT_HANDLERS"] = bot_handlers
    app.config["MESSAGE_HANDLERS"] = message_handlers
    app.run(host=options.hostname, port=int(options.port), debug=True)
Esempio n. 2
0
 def test_argument_parsing_defaults(self) -> None:
     opts = parse_args()
     assert opts.config_file == '/foo/bar/baz.conf'
     assert opts.bot_name is None
     assert opts.bot_config_file is None
     assert opts.hostname == '127.0.0.1'
     assert opts.port == 5002
Esempio n. 3
0
 def test_argument_parsing_defaults(self) -> None:
     opts = parse_args()
     assert opts.config_file == '/foo/bar/baz.conf'
     assert opts.bot_name is None
     assert opts.bot_config_file is None
     assert opts.hostname == '127.0.0.1'
     assert opts.port == 5002
Esempio n. 4
0
def main() -> None:
    options = parse_args()
    bots_config = read_config_file(options.config_file, options.bot_name)
    available_bots = list(bots_config.keys())
    bots_lib_modules = load_lib_modules(available_bots)
    third_party_bot_conf = parse_config_file(
        options.bot_config_file
    ) if options.bot_config_file is not None else None
    bot_handlers = load_bot_handlers(available_bots, bots_config,
                                     third_party_bot_conf)
    message_handlers = init_message_handlers(available_bots, bots_lib_modules,
                                             bot_handlers)
    app.config["BOTS_LIB_MODULES"] = bots_lib_modules
    app.config["BOT_HANDLERS"] = bot_handlers
    app.config["MESSAGE_HANDLERS"] = message_handlers
    app.run(host=options.hostname, port=int(options.port), debug=True)
Esempio n. 5
0
def main() -> None:
    options = parse_args()
    global bots_config
    try:
        bots_config = read_config_file(options.config_file, options.bot_name)
    except MissingSectionHeaderError:
        sys.exit("Error: Your Botserver config file `{0}` contains an empty section header!\n"
                 "You need to write the names of the bots you want to run in the "
                 "section headers of `{0}`.".format(options.config_file))
    available_bots = list(bots_config.keys())
    bots_lib_modules = load_lib_modules(available_bots)
    third_party_bot_conf = parse_config_file(options.bot_config_file) if options.bot_config_file is not None else None
    bot_handlers = load_bot_handlers(available_bots, bots_config, third_party_bot_conf)
    message_handlers = init_message_handlers(available_bots, bots_lib_modules, bot_handlers)
    app.config["BOTS_LIB_MODULES"] = bots_lib_modules
    app.config["BOT_HANDLERS"] = bot_handlers
    app.config["MESSAGE_HANDLERS"] = message_handlers
    app.run(host=options.hostname, port=int(options.port), debug=True)