Beispiel #1
0
def generate_config(url, username, token, config_loc):
    config = MatrixConfig(hs_url=url,
                          user_id=username,
                          access_token=token,
                          admins=[])
    save_config(config_loc, config)
    return config
Beispiel #2
0
def load_config(loc):
    try:
        with open(loc, 'r') as f:
            return MatrixConfig.from_file(f)
    except Exception as e:
        log.warning(e)
        return None
Beispiel #3
0
def generate_config(url, username, token, admin, c_is, config_loc):
    if not admin:  # This bot has no admin if unspecified.
        admin = []
    config = MatrixConfig(hs_url=url,
                          user_id=username,
                          access_token=token,
                          admins=admin,
                          case_insensitive=c_is)

    save_config(config_loc, config)
    return config
Beispiel #4
0
def save_config(loc, config):
    with open(loc, 'w') as f:
        MatrixConfig.to_file(config, f)
Beispiel #5
0
def load_config(loc):
    try:
        with open(loc, 'r') as f:
            return MatrixConfig.from_file(f)
    except:
        pass
Beispiel #6
0
def load_config(loc):
    try:
        with open(loc, 'r') as f:
            return MatrixConfig.from_file(f)
    except:
        pass
Beispiel #7
0
def save_config(loc, config):
    with open(loc, 'w') as f:
        MatrixConfig.to_file(config, f)