Пример #1
0
def ignore(context):
    '''.ignore nick!user@host'''
    bot.config.setdefault('IGNORE', [])

    if context.args:
        to_ignore = glob(context.args)
        supersets = list(ifilter(lambda ignored: to_ignore.issub(glob(ignored)), bot.config['IGNORE']))
        if len(supersets) > 0:
            return 'Not ignoring \x02%s\x02 because it is already matched by \x02%s\x02' % (context.args, supersets[0])

        filter = lambda ignored: to_ignore.issuper(glob(ignored))
        removed = list(ifilter(filter, bot.config['IGNORE']))

        bot.config['IGNORE'] = list(ifilterfalse(filter, bot.config['IGNORE']))
        bot.config['IGNORE'].append(context.args)

        save_ignores()

        bot.log(context, ('IGNORE'), '+{0}{1}'.format(context.args, (' -' + ' -'.join(removed)) if removed else ''))

        if removed:
            return 'Ignored and removed \x02%d\x02 redundant ignores: \x02%s\x02' % (len(removed), '\x02, \x02'.join(removed))
        else:
            return 'Ignored.'
    else:
        return eval.__doc__
Пример #2
0
def ignore(context):
    """.ignore nick!user@host"""
    bot.config.setdefault("IGNORE", [])
    if not utils.isadmin(context.line["prefix"], bot):
        return
    if context.args:
        to_ignore = glob(context.args)
        supersets = list(ifilter(lambda ignored: to_ignore.issub(glob(ignored)), bot.config["IGNORE"]))
        if len(supersets) > 0:
            return "Not ignoring \x02%s\x02 because it is already matched by \x02%s\x02" % (context.args, supersets[0])

        filter = lambda ignored: to_ignore.issuper(glob(ignored))
        removed = list(ifilter(filter, bot.config["IGNORE"]))

        bot.config["IGNORE"] = list(ifilterfalse(filter, bot.config["IGNORE"]))
        bot.config["IGNORE"].append(context.args)

        save_ignores()

        if len(removed) > 0:
            return "Ignored and removed \x02%d\x02 redundant ignores: \x02%s\x02" % (
                len(removed),
                "\x02, \x02".join(removed),
            )
        else:
            return "Ignored."
    else:
        return eval.__doc__
Пример #3
0
def unignore(context):
    '''.unignore nick!user@host'''
    bot.config.setdefault('IGNORE', [])
    if not utils.isadmin(context.line['prefix'], bot):
        return
    if context.args:
        to_unignore = glob(context.args)

        filter = lambda ignored: to_unignore.issuper(glob(ignored))
        subsets = list(ifilter(filter, bot.config['IGNORE']))
        if len(subsets) == 0:
            return 'Nothing to unignore.'

        bot.config['IGNORE'] = list(ifilterfalse(filter, bot.config['IGNORE']))

        save_ignores()

        return 'Removed \x02%d\x02 ignores: \x02%s\x02' % (len(subsets), '\x02, \x02'.join(subsets))
    else:
        return eval.__doc__
Пример #4
0
def unignore(context):
    """.unignore nick!user@host"""
    bot.config.setdefault("IGNORE", [])
    if not utils.isadmin(context.line["prefix"], bot):
        return
    if context.args:
        to_unignore = glob(context.args)

        filter = lambda ignored: to_unignore.issuper(glob(ignored))
        subsets = list(ifilter(filter, bot.config["IGNORE"]))
        if len(subsets) == 0:
            return "Nothing to unignore."

        bot.config["IGNORE"] = list(ifilterfalse(filter, bot.config["IGNORE"]))

        save_ignores()

        return "Removed \x02%d\x02 ignores: \x02%s\x02" % (len(subsets), "\x02, \x02".join(subsets))
    else:
        return eval.__doc__
Пример #5
0
def isignored(prefix, bot):
    ignore = bot.config.get('IGNORE', [])
    return any(imap(lambda x: glob(x).matches(prefix), ignore))
Пример #6
0
def isadmin(prefix, bot):
    admins = bot.config.get('ADMINS', [])
    return any(imap(lambda x: glob(x).matches(prefix), admins))