Beispiel #1
0
def ignoresieve(bot, input, func, type, args):
    """ blocks input from ignored channels/nicks/hosts """
    globalignorelist = bot.config["ignored"]

    db = bot.get_db_connection(input.conn)
    mask = input.mask.lower()
    chan = input.chan.lower()
    ignorelist = database.get(db,'channels','ignored','chan',chan)

    # don't block input to event hooks
    # if type == "event": return input

    if user.is_admin(mask,chan,db,bot): return input

    if ignorelist and user.format_hostmask(mask) in ignorelist: return None
    if globalignorelist and user.format_hostmask(mask) in globalignorelist: return None
        #print "[{}]: {} is ignored.".format(input.chan,mask)
        



    # if input.chan.lower() in ignorelist \
    #    or input.nick.lower().replace('~','') in ignorelist \
    #    or input.mask.lower().replace('~','').lower() in ignorelist:
    #     if input.command == "PRIVMSG" and input.lastparam[1:] == "unignore":
    #         return input
    #     else:
    #         return None
    return input
Beispiel #2
0
def highlight_sieve(bot, input, func, kind, args):
    fn = re.match(r'^plugins.(.+).py$', func._filename)
    if fn.group(1) == 'seen' or \
       fn.group(1) == 'tell' or\
       fn.group(1) == 'ai' or \
       fn.group(1) == 'core_ctcp':
        return input

    global userlist
    try:
        users = userlist[input.chan.lower().replace('#', '')]
    except:
        return input
    inp = set(re.sub('[#~&@+%,\.]', '', input.msg.lower()).split(' '))
    if len(users & inp) > 3:
        globaladmin = user.is_globaladmin(input.mask, input.chan, bot)
        db = bot.get_db_connection(input.conn)
        channeladmin = user.is_channeladmin(input.mask, input.chan, db)
        if not globaladmin and not channeladmin:
            if len(users & inp) > 5:
                s = u"MODE {} +b *!*{}"
                input.conn.send(s.format(input.chan,
                                         user.format_hostmask(input.mask)))
            s = u"KICK {} {} :MASSHIGHLIGHTING F****T GET #REKT"
            input.conn.send(s.format(input.chan, input.nick))
    return input
Beispiel #3
0
def onjoined(inp,input=None, conn=None, chan=None,raw=None, db=None):
    database.set(db,'users','mask',input.mask.lower().replace('~',''),'nick',input.nick.lower())
    mask = user.format_hostmask(input.mask)
    disabled_commands = database.get(db,'channels','disabled','chan',chan)
    if not disabled_commands: disabled_commands = ""

    if not 'banlist' in disabled_commands:
        #check if bans
        banlist = database.get(db,'channels','bans','chan',chan)
        if banlist and mask in banlist:
            conn.send("MODE {} {} *{}".format(input.chan, '+b', mask))
            conn.send("KICK {} {} :{}".format(input.chan, input.nick, 'I dont think so Tim.'))

    if not 'autoop' in disabled_commands:
        #check if ops
        autoop = database.get(db,'channels','autoop','chan',chan)
        if autoop: autoops = database.get(db,'channels','admins','chan',chan)
        else: autoops = database.get(db,'channels','autoops','chan',chan)

        if autoops and mask in autoops:
            conn.send("MODE {} {} {}".format(input.chan, '+o', input.nick))

    if not 'greeting' in disabled_commands:
        # send greeting
        greeting = database.get(db,'users','greeting','nick',input.nick)

        if greeting: return greeting
Beispiel #4
0
def onjoined(inp, input=None, conn=None, chan=None, raw=None, db=None):
    mask = user.format_hostmask(input.mask)
    disabled_commands = database.get(db, "channels", "disabled", "chan", chan)
    if not disabled_commands:
        disabled_commands = ""

    if not "banlist" in disabled_commands:
        # check if bans
        banlist = database.get(db, "channels", "bans", "chan", chan)
        if banlist and mask in banlist:
            conn.send(u"MODE {} {} *{}".format(input.chan, "+b", mask))
            conn.send(u"KICK {} {} :{}".format(input.chan, input.nick, "I dont think so Tim."))

    if not "autoop" in disabled_commands:
        # check if ops
        autoop = database.get(db, "channels", "autoop", "chan", chan)
        if autoop:
            autoops = database.get(db, "channels", "admins", "chan", chan)
        else:
            autoops = database.get(db, "channels", "autoops", "chan", chan)

        if autoops and mask in autoops:
            conn.send(u"MODE {} {} {}".format(input.chan, "+o", input.nick))

    if not "greeting" in disabled_commands:
        # send greeting
        greeting = database.get(db, "users", "greeting", "nick", input.nick)
        if greeting:
            return greeting
Beispiel #5
0
def highlight_sieve(bot, input, func, kind, args):
    fn = re.match(r'^plugins.(.+).py$', func._filename)
    if fn.group(1) == 'seen' or \
       fn.group(1) == 'tell' or\
       fn.group(1) == 'ai' or \
       fn.group(1) == 'core_ctcp':
        return input

    global userlist
    try:
        users = userlist[input.chan.lower().replace('#', '')]
    except:
        return input
    inp = set(re.sub('[#~&@+%,\.]', '', input.msg.lower()).split(' '))
    if len(users & inp) > 3:
        globaladmin = user.is_globaladmin(input.mask, input.chan, bot)
        db = bot.get_db_connection(input.conn)
        channeladmin = user.is_channeladmin(input.mask, input.chan, db)
        if not globaladmin and not channeladmin:
            if len(users & inp) > 5:
                input.conn.send(u"MODE {} +b *!*{}".format(
                    input.chan, user.format_hostmask(input.mask)))
            input.conn.send(
                u"KICK {} {} :MASSHIGHLIGHTING F****T GET #REKT".format(
                    input.chan, input.nick))
    return input
Beispiel #6
0
def onjoined(inp,input=None, conn=None, chan=None,raw=None, db=None):
    database.set(db,'users','mask',input.mask.lower().replace('~',''),'nick',input.nick.lower())
    mask = user.format_hostmask(input.mask)
    disabled_commands = database.get(db,'channels','disabled','chan',chan)
    if not disabled_commands: disabled_commands = ""
    
    if not 'banlist' in disabled_commands:
        #check if bans
        banlist = database.get(db,'channels','bans','chan',chan)
        if banlist and mask in banlist:
            conn.send(u"MODE {} {} *{}".format(input.chan, '+b', mask))
            conn.send(u"KICK {} {} :{}".format(input.chan, input.nick, 'I dont think so Tim.'))

    if not 'autoop' in disabled_commands:
        #check if ops
        autoop = database.get(db,'channels','autoop','chan',chan)
        if autoop: autoops = database.get(db,'channels','admins','chan',chan)
        else: autoops = database.get(db,'channels','autoops','chan',chan)
        
        if autoops and mask in autoops:
            conn.send(u"MODE {} {} {}".format(input.chan, '+o', input.nick))

    if not 'greeting' in disabled_commands:
        # send greeting
        greeting = database.get(db,'users','greeting','nick',input.nick)

        if greeting: conn.msg(chan, greeting.decode('UTF-8'))
    if input.nick == "kimi":
        conn.send('PRIVMSG {} :\x02[QUALITY OF CHANNEL SIGNIFICANTLY DECREASED]\x02'.format(input.chan))
Beispiel #7
0
def onjoined(inp, input=None, conn=None, chan=None, raw=None, db=None):
    database.set(db, 'users', 'mask',
                 input.mask.lower().replace('~', ''), 'nick',
                 input.nick.lower())
    mask = user.format_hostmask(input.mask)
    disabled_commands = database.get(db, 'channels', 'disabled', 'chan', chan)
    if not disabled_commands: disabled_commands = ""

    if not 'banlist' in disabled_commands:
        #check if bans
        banlist = database.get(db, 'channels', 'bans', 'chan', chan)
        if banlist and mask in banlist:
            conn.send(u"MODE {} {} *{}".format(input.chan, '+b', mask))
            conn.send(u"KICK {} {} :{}".format(input.chan, input.nick,
                                               'I dont think so Tim.'))

    if not 'autoop' in disabled_commands:
        #check if ops
        autoop = database.get(db, 'channels', 'autoop', 'chan', chan)
        if autoop:
            autoops = database.get(db, 'channels', 'admins', 'chan', chan)
        else:
            autoops = database.get(db, 'channels', 'autoops', 'chan', chan)

        if autoops and mask in autoops:
            conn.send(u"MODE {} {} {}".format(input.chan, '+o', input.nick))

    if not 'greeting' in disabled_commands:
        # send greeting
        greeting = database.get(db, 'users', 'greeting', 'nick', input.nick)

        if greeting: return greeting
Beispiel #8
0
def process_vote(target,action,chan,mask,db,notice,conn):
    if ' ' in target: 
        notice('Invalid nick')
        return

    try: votes2kick = database.get(db,'channels','votekick','chan',chan)
    except: votes2kick = 10
    try: votes2ban = database.get(db,'channels','voteban','chan',chan)
    except: votes2ban = 10

    if len(target) is 0:
        if action is 'kick': notice('Votes required to kick: {}'.format(votes2kick))
        elif action is 'ban': notice('Votes required to ban: {}'.format(votes2ban))
        return

    votefinished = False
    global db_ready
    if not db_ready: db_init(db)
    chan = chan.lower()
    target = target.lower()
    voter = user.format_hostmask(mask)
    oters = db.execute("SELECT voters FROM votes where chan='{}' and action='{}' and target like '{}'".format(chan,action,target)).fetchone()

    if conn.nick.lower() in target: return "I dont think so Tim."

    if voters: 
        voters = voters[0]
        if voter in voters: 
            notice("You have already voted.")
            return
        else:
            voters = '{} {}'.format(voters,voter).strip()
            notice("Thank you for your vote!")
    else: 
        voters = voter

    votecount = len(voters.split(' '))

    if 'kick' in action: 
        votemax = int(votes2kick)
        if votecount >= votemax:
            votefinished = True
            conn.send("KICK {} {} :{}".format(chan, target, "You have been voted off the island."))
    if 'ban' in action:
        votemax = int(votes2ban)
        if votecount >= votemax:
            votefinished = True
            conn.send("MODE {} +b {}".format(chan, user.get_hostmask(target,db)))
            conn.send("KICK {} {} :".format(chan, target, "You have been voted off the island."))
    
    if votefinished: db.execute("DELETE FROM votes where chan='{}' and action='{}' and target like '{}'".format(chan,action,target))
    else: db.execute("insert or replace into votes(chan, action, target, voters, time) values(?,?,?,?,?)", (chan, action, target, voters, time.time()))
        
    db.commit()
    return ("Votes to {} {}: {}/{}".format(action, target, votecount,votemax))
Beispiel #9
0
def highlight_sieve(bot, input, func, kind, args):
    fn = re.match(r"^plugins.(.+).py$", func._filename)
    if fn.group(1) == "seen" or fn.group(1) == "tell" or fn.group(1) == "ai" or fn.group(1) == "core_ctcp":
        return input

    global userlist
    try:
        users = userlist[input.chan.lower().replace("#", "")]
    except:
        return input
    inp = set(re.sub("[#~&@+%,\.]", "", input.msg.lower()).split(" "))
    if len(users & inp) > 3:
        globaladmin = user.is_globaladmin(input.mask, input.chan, bot)
        db = bot.get_db_connection(input.conn)
        channeladmin = user.is_channeladmin(input.mask, input.chan, db)
        if not globaladmin and not channeladmin:
            if len(users & inp) > 5:
                input.conn.send("MODE {} +b *!*{}".format(input.chan, user.format_hostmask(input.mask)))
            input.conn.send("KICK {} {} :MASSHIGHLIGHTING F****T GET #REKT".format(input.chan, input.nick))
    return input
Beispiel #10
0
def process_vote(target, action, chan, mask, db, notice, conn):
    if ' ' in target:
        notice('Invalid nick')
        return

    try:
        votes2kick = database.get(db, 'channels', 'votekick', 'chan', chan)
    except:
        votes2kick = 10
    try:
        votes2ban = database.get(db, 'channels', 'voteban', 'chan', chan)
    except:
        votes2ban = 10

    if len(target) is 0:
        if action is 'kick':
            notice('Votes required to kick: {}'.format(votes2kick))
        elif action is 'ban':
            notice('Votes required to ban: {}'.format(votes2ban))
        return

    votefinished = False
    global db_ready
    if not db_ready: db_init(db)
    chan = chan.lower()
    target = target.lower()
    voter = user.format_hostmask(mask)
    oters = db.execute(
        "SELECT voters FROM votes where chan='{}' and action='{}' and target like '{}'"
        .format(chan, action, target)).fetchone()

    if conn.nick.lower() in target: return "I dont think so Tim."

    if voters:
        voters = voters[0]
        if voter in voters:
            notice("You have already voted.")
            return
        else:
            voters = '{} {}'.format(voters, voter).strip()
            notice("Thank you for your vote!")
    else:
        voters = voter

    votecount = len(voters.split(' '))

    if 'kick' in action:
        votemax = int(votes2kick)
        if votecount >= votemax:
            votefinished = True
            conn.send("KICK {} {} :{}".format(
                chan, target, "You have been voted off the island."))
    if 'ban' in action:
        votemax = int(votes2ban)
        if votecount >= votemax:
            votefinished = True
            conn.send("MODE {} +b {}".format(chan,
                                             user.get_hostmask(target, db)))
            conn.send("KICK {} {} :".format(
                chan, target, "You have been voted off the island."))

    if votefinished:
        db.execute(
            "DELETE FROM votes where chan='{}' and action='{}' and target like '{}'"
            .format(chan, action, target))
    else:
        db.execute(
            "insert or replace into votes(chan, action, target, voters, time) values(?,?,?,?,?)",
            (chan, action, target, voters, time.time()))

    db.commit()
    return ("Votes to {} {}: {}/{}".format(action, target, votecount, votemax))