예제 #1
0
 def test_disable(self):
     registry.enable('#foo', 'foo', self.snowman)
     assert 'foo' in registry.enabled_plugins['#foo']
     assert self.snowman in registry.enabled_plugins['#foo']
     registry.disable('#foo', 'foo', self.snowman)
     assert 'foo' not in registry.enabled_plugins['#foo']
     assert self.snowman not in registry.enabled_plugins['#foo']
예제 #2
0
 def test_disable(self):
     registry.enable('#foo', 'foo', self.snowman)
     assert 'foo' in registry.enabled_plugins['#foo']
     assert self.snowman in registry.enabled_plugins['#foo']
     registry.disable('#foo', 'foo', self.snowman)
     assert 'foo' not in registry.enabled_plugins['#foo']
     assert self.snowman not in registry.enabled_plugins['#foo']
예제 #3
0
def auto_enable_plugins(*args):
    pred = lambda rec: rec['plugin'] in registry.all_plugins

    for rec in ifilter(pred, db.auto_enabled_plugins.find()):
        for channel in rec['channels']:
            logger.info('Auto-enabling plugin %s on channel %s', rec['plugin'], channel)
            registry.enable(channel, rec['plugin'])
예제 #4
0
def auto_enable_plugins(*args):
    if db is None:  # pragma: no cover
        logger.warning('Cannot auto enable plugins. No database connection')
        return

    pred = lambda rec: rec['plugin'] in registry.all_plugins

    for rec in ifilter(pred, db.auto_enabled_plugins.find()):
        for channel in rec['channels']:
            logger.info('Auto-enabling plugin %s on channel %s', rec['plugin'], channel)
            registry.enable(channel, rec['plugin'])
예제 #5
0
def auto_enable_plugins(*args):
    if db is None:  # pragma: no cover
        logger.warning('Cannot auto enable plugins. No database connection')
        return

    pred = lambda rec: rec['plugin'] in registry.all_plugins

    for rec in ifilter(pred, db.auto_enabled_plugins.find()):
        for channel in rec['channels']:
            logger.info('Auto-enabling plugin %s on channel %s', rec['plugin'],
                        channel)
            registry.enable(channel, rec['plugin'])
예제 #6
0
def enable_plugins(client, channel, *plugins):
    valid_plugins = _filter_valid(channel, *plugins)
    if not valid_plugins:
        return u"Sorry, but I don't know about these plugins: {0}".format(', '.join(plugins))

    registry.enable(channel, *valid_plugins)

    for p in valid_plugins:
        rec = db.auto_enabled_plugins.find_one({'plugin': p})
        if rec is None:
            db.auto_enabled_plugins.insert({'plugin': p, 'channels': [channel]})
        elif channel not in rec['channels']:
            rec['channels'].append(channel)
            db.auto_enabled_plugins.save(rec)

    return random.choice(ACKS)
예제 #7
0
def enable_plugins(client, channel, *plugins):
    valid_plugins = _filter_valid(channel, *plugins)
    if not valid_plugins:
        return u"Sorry, but I don't know about these plugins: {0}".format(
            ', '.join(plugins))

    registry.enable(channel, *valid_plugins)

    for p in valid_plugins:
        rec = db.auto_enabled_plugins.find_one({'plugin': p})
        if rec is None:
            db.auto_enabled_plugins.insert({
                'plugin': p,
                'channels': [channel]
            })
        elif channel not in rec['channels']:
            rec['channels'].append(channel)
            db.auto_enabled_plugins.save(rec)

    return random.choice(ACKS)