def create_initial_cfg(): print("Creating new config file: data/config.json") global our_id oid = settings.OUR_ID if hasattr(settings, 'OUR_ID') else our_id cfg = { 'enabled_plugins': ['plugins', 'help', 'media'], 'sudo_users': [122774063], 'disabled_channels': [], 'talk_oneself': False, } if not os.path.isdir('data'): os.mkdir('data') utils.dump_cfg('data/config.json', cfg) print("Data created :)")
def generic_cfg(data, action, defaultt=list, field="enabled_plugins", fname="data/config.json", key=None): cfg = utils.load_cfg(fname) # load cfg plugs = cfg.get(field) or defaultt() if key is not None: if not plugs.get(key): plugs[key] = type(data)() if not hasattr(plugs[key], action): return getattr(plugs[key], action)(data) else: if not hasattr(plugs, action): return getattr(plugs, action)(data) cfg[field] = plugs utils.dump_cfg(fname, cfg)
def create_initial_cfg(): print("Creating new config file: data/config.json") global our_id oid = settings.OUR_ID if hasattr(settings, 'OUR_ID') else our_id cfg = { 'enabled_plugins': ['plugins', 'help', 'media'], 'sudo_users': [152321430], 'disabled_channels': [], 'talk_oneself': False, } if not os.path.isdir('data'): os.mkdir('data') utils.dump_cfg('data/config.json', cfg) print("Data created :)")
def generic_cfg(data, action, defaultt=list, field='enabled_plugins', fname="data/config.json", key=None): cfg = utils.load_cfg(fname) # load cfg plugs = cfg.get(field) or defaultt() if key is not None: if not plugs.get(key): plugs[key] = type(data)() if not hasattr(plugs[key], action): return getattr(plugs[key], action)(data) else: if not hasattr(plugs, action): return getattr(plugs, action)(data) cfg[field] = plugs utils.dump_cfg(fname, cfg)