예제 #1
0
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 :)")
예제 #2
0
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)
예제 #3
0
파일: bot.py 프로젝트: MeGaTG/pybot
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 :)")
예제 #4
0
파일: plugins.py 프로젝트: kanhan258/phbot
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)