Example #1
0
def test_add_plugins():
    added = []

    app = Kutana()
    assert app.get_plugins() == []

    app.add_plugin = lambda pl: added.append(pl)
    app.add_plugins(["a", "b", "c"])
    assert added == ["a", "b", "c"]
Example #2
0
def main():
    app = Kutana()
    # set_logger_level(logging.DEBUG)

    backend = Vkontakte(SHUF_SETTINGS['TOKEN'])
    app.add_backend(backend)
    app.config['settings'] = SHUF_SETTINGS
    app.config['prefixes'] = ('еш ', 'есб ', 'esb ', 'ешаф ', 'eshuf '
                              )  # ('шаф ', 'sb ', 'шб ', 'shuf ', 'shufbot ')
    app.config['inform_time'] = time(20, 50)  # 12:00
    app.config['votekick_time'] = 5 * 60
    init_db(app)

    app.add_plugins(load_plugins(os.path.join(os.curdir, 'bot', 'plugins')))

    return app
Example #3
0
File: cli.py Project: ekonda/kutana
def run():
    """
    This function runs kutana application using provided
    configuration and CLI options.

    Refer to its source to create more specific starter for
    your application.
    """

    # Parse provided arguments
    args = parser.parse_args()

    # Setup logger
    if args.debug:
        logger.set_logger_level(logging.DEBUG)

    # Import configuration
    if not os.path.isfile(args.config):
        logger.logger.error(f"Couldn't open confiuration file: {args.config}")
        exit(1)

    with open(args.config) as fh:
        config = yaml.safe_load(fh)

    # Create application
    app = Kutana()

    # Update configuration
    app.config.update(config)

    # Setup i18n
    set_default_language(config.get("language", "en"))
    load_translations(args.translations)

    # Add each backend from config
    add_backends(app, config.get("backends"))

    # Add each storage from config
    add_storages(app, config.get("storages"))

    # Load and register plugins from provided path
    app.add_plugins(load_plugins(args.plugins))

    # Run application
    app.run()
Example #4
0
import json
from kutana import Kutana, load_plugins
from kutana.backends import Vkontakte

# Import configuration
with open("config.json") as fh:
    config = json.load(fh)

# Create application
app = Kutana()

# Add manager to application
app.add_backend(Vkontakte(token=config["vk_token"]))

# Load and register plugins
app.add_plugins(load_plugins("plugins/"))

if __name__ == "__main__":
    # Run application
    app.run()