Пример #1
0
def func(irc, nick, host, message, pre=u''):
    if len(RELAPSE) > conf['count_limit']:
        RELAPSE.clear()

    for pattern in PATTERNS:
        for lin in message.split():
            if pattern.match(lin):
                if not host in RELAPSE:
                    RELAPSE[host] = 1
                else:
                    RELAPSE[host] += 1

                if RELAPSE[host] < RELAPSE_LIMIT:
                    irc.kick(conf['channel'], nick, pre + conf['badwords']['warning'])
                    irc.privmsg(nick, conf['warning'].format(nick=nick))
                    return True
                else:
                    irc.mode(conf['channel'], '+b *!*@' + host)

                    for tuple in to_kick:
                        _host, msg = tuple
                        if host == _host:
                            to_kick.remove(tuple)

                    to_kick.append((host.lower(), pre + conf['badwords']['warning']))
                    irc.who(conf['channel'])

                    mode(irc.base.name, conf['channel'], '-b *!*@' + host, 86400)
                    del RELAPSE[host]
                    return True
Пример #2
0
def func(irc, nick, host, message, pre=u''):
    last = []
    repeat = 0
    limit = conf['norepeat']['limit']
    for letter in message:
        if not letter in last:
            if len(last) == 0:
                last.append(letter)
            else:
                last.pop()
                last.append(letter)
        else:
            repeat += 1
            if repeat >= limit:
                if not host in RELAPSE:
                    RELAPSE[host] = 1
                else:
                    RELAPSE[host] += 1

                if RELAPSE[host] < RELAPSE_LIMIT:
                    msg = conf['warn'] + pre + conf['norepeat']['warning']
                    msg = msg.format(nick=nick, relapse_num=RELAPSE[host])
                    irc.notice(conf['channel'], msg)
                    if (RELAPSE_LIMIT - RELAPSE[host]) == 1:
                        irc.privmsg(nick, conf['warning'].format(nick=nick))
                    return True
                else:
                    irc.mode(conf['channel'], '+b *!*@' + host)

                    for tuple in to_kick:
                        _host, msg = tuple
                        if host == _host:
                            to_kick.remove(tuple)

                    to_kick.append((host.lower(), pre + conf['norepeat']['warning']))
                    irc.who(conf['channel'])

                    mode(irc.base.name, conf['channel'], '-b *!*@' + host, 86400)
                    del RELAPSE[host]
                    return True
Пример #3
0
def func(irc, nick, host, message):
    if len(RELAPSE) > conf['count_limit']:
        RELAPSE.clear()

    for pattern, level in PATTERNS:
        if pattern.match(message):
            if not host in RELAPSE:
                RELAPSE[host] = 1
            else:
                RELAPSE[host] += 1

            if RELAPSE[host] < RELAPSE_LIMIT:
                if level == 0:
                    msg = conf['warn'] + conf['nodata']['warning']
                    msg = msg.format(nick=nick, relapse_num=RELAPSE[host])
                    irc.notice(conf['channel'], msg)
                if level == 1:
                    msg = conf['nodata']['warning']
                    irc.kick(conf['channel'], nick, msg)
                    RELAPSE[host] = RELAPSE_LIMIT + 1
                if (RELAPSE_LIMIT - RELAPSE[host]) == 1:
                    irc.privmsg(nick, conf['warning'].format(nick=nick))
                return True
            else:
                irc.mode(conf['channel'], '+b *!*@' + host)

                for tuple in to_kick:
                    _host, msg = tuple
                    if host == _host:
                        to_kick.remove(tuple)

                to_kick.append((host.lower(), conf['nodata']['warning']))
                irc.who(conf['channel'])

                mode(irc.base.name, conf['channel'], '-b *!*@' + host, 86400)
                del RELAPSE[host]
                return True
Пример #4
0
def func(irc, nick, host, message):
    if len(NOFLOOD) > conf["count_limit"]:
        NOFLOOD.clear()

    LIMIT_T = conf["noflood"]["limit_t"]
    LIMIT_L = conf["noflood"]["limit_l"]
    LIMIT_M = conf["noflood"]["limit_m"]
    LIMIT_R = conf["noflood"]["limit_r"]

    if len(NOFLOOD) >= 100:
        NOFLOOD.clear()

    if not host in NOFLOOD:
        NOFLOOD[host] = [1, time.time(), message, 0]
    else:
        NOFLOOD[host][0] += 1

    ok = False
    if (time.time() - NOFLOOD[host][1]) <= LIMIT_T:
        if NOFLOOD[host][0] >= LIMIT_M:
            ok = True
            me = "No envies mensajes tan rapido! Es flood!"
    else:
        NOFLOOD[host][0] = 1
        NOFLOOD[host][1] = time.time()

    if not ok:
        if (time.time() - NOFLOOD[host][1]) <= LIMIT_L:
            if NOFLOOD[host][2] == message.lower():
                NOFLOOD[host][3] += 1
            else:
                NOFLOOD[host][3] = 0
                NOFLOOD[host][2] = message.lower()

            if NOFLOOD[host][3] >= LIMIT_R:
                ok = True
                me = "¡No repitas! ¡No repitas! ¡No repitas! ¡Ya te leimos!"

    if ok:
        if len(RELAPSE) > conf["count_limit"]:
            NOFLOOD.clear()

        if not host in RELAPSE:
            RELAPSE[host] = 1
        else:
            RELAPSE[host] += 1

        if (RELAPSE_LIMIT - RELAPSE[host]) == 1:
            irc.privmsg(nick, conf["warning"].format(nick=nick))

        if RELAPSE[host] < RELAPSE_LIMIT:
            msg = conf["warn"] + me
            msg = msg.format(nick=nick, relapse_num=RELAPSE[host])
            irc.notice(conf["channel"], msg)
        else:
            irc.mode(conf["channel"], "+b *!*@" + host)

            for tuple in to_kick:
                _host, msg = tuple
                if host == _host:
                    to_kick.remove(tuple)

            to_kick.append((host.lower(), me))
            irc.who(conf["channel"])

            mode(irc.base.name, conf["channel"], "-b *!*@" + host, 86400)

            del RELAPSE[host]
            del NOFLOOD[host]
            return True