Пример #1
0
def sieve_suite(bot, input, func, kind, args):
    inuserhost = input.user+'@'+input.host
    
    if perm.isignored(input) and not (perm.isvoiced(input)):
        if not (input.paraml[0].startswith("\x01ACTION ")):
            return None
        else:
            return input
    
    if perm.isbot(input):
        if not (input.paraml[0].startswith("\x01ACTION ")):
            return None
        else:
            return input

    if (input.chan in input.conn.conf["ignore"]) and not (perm.isvoiced(input)):
        if not (input.paraml[0].startswith("\x01ACTION ")):
            return None
        else:
            return input
            
    ignored = input.conn.conf['ignore']
    if kind == "command":
        if "^" in input.paraml[1]:
            input.inp = input.inp.replace("^",bot.chanseen[input.conn.name][input.chan][0])
            input.paraml[1] = input.paraml[1].replace("^",bot.chanseen[input.conn.name][input.chan][0])
        if input.trigger in bot.config["disabled_commands"]:
            return None
    
    connitem = input.conn
    for xconn in bot.conns:
        if connitem==bot.conns[xconn]:
            server=bot.conns[xconn].name
    if input.nick in bot.cooldown[str(server)]:
        bot.cooldown[str(server)][input.nick]+=1
        return None
    
    if input.paraml[0].startswith("\x01PING "):
		input.conn.send("NOTICE "+input.nick+" :"+input.inp[1])

    fn = re.match(r'^plugins.(.+).py$', func._filename)
    disabled = bot.config.get('disabled_plugins', [])
    if fn and fn.group(1).lower() in disabled:
        return None
    acl = bot.config.get('acls', {}).get(func.__name__)
    if acl:
        if 'deny-except' in acl:
            allowed_channels = map(unicode.lower, acl['deny-except'])
            if input.chan.lower() not in allowed_channels:
                return None
        if 'allow-except' in acl:
            denied_channels = map(unicode.lower, acl['allow-except'])
            if input.chan.lower() in denied_channels:
                return None

#the extended permissions were moved here.
    if args.get('adminonly', False):
        if not perm.isadmin(input):
            return None
    if args.get('superadminonly', False):
        if not perm.issuperadmin(input):
            return None
    if args.get('owneronly', False):
        if not perm.isowner(input):
            return None
#extended permissions end here.
    return input 
Пример #2
0
def permissions(inp, input=None, bot=None):
    "adds or removes permissions... use ,permissions help"
    check = input.inp.split(" ")
    cmdlist = ["add","remove","list","help"]
    if len(check)>=1:
        check[0]=check[0].lower()
    if len(check)>=2:
        check[1]=check[1].lower()
    if len(check)==0:
        return("Try using ',perm help' before stuffing around with"
        " this command.")
    if check[0] in cmdlist:
        if check[0]=="list" and len(check)==2:
            listlist=["bots","voice","admins","superadmins","owner"]
            if check[1]=="bots":
                return listbots(bot,input)
            if check[1]=="voiced":
                return listvoiced(bot,input)
            if check[1]=="admins":
                return listadmins(bot,input)
            if check[1]=="superadmins":
                return listsuperadmins(bot,input)
            if check[1]=="owner":
                return listowner(bot,input)
            elif not (check[1] in listlist):
                return("error. unknown error or not a permissions group.")
        if len(check)==3:
            check[1]=check[1].lower()
            if perm.isadmin(input):
                if check[0]=="add" and check[1]=="bot" and input.conn.conf["bots"].count(check[2])==0:
                    return addperm(check[2],bot,input,"bot")
                if check[0]=="remove" and check[1]=="bot" and input.conn.conf["bots"].count(check[2])==1:
                    return removeperm(check[2],bot,input,"bots")
                if check[0]=="add" and check[1]=="voice" and input.conn.conf["voiced"].count(check[2])==0:
                    return addperm(check[2],bot,input,"voice")
                if check[0]=="remove" and check[1]=="voice" and input.conn.conf["voiced"].count(check[2])==1:
                    return removeperm(check[2],bot,input,"voiced")
                else:
                    if check[1]=="bot" and check[0]=="add":
                        return("error. unknown error or already a "+check[1])
                    if check[1]=="bot" and check[0]=="remove":
                        return("error. unknown error or not a "+check[1])
            if perm.issuperadmin(input):
                if check[0]=="add":
                    if check[1]=="admin" and input.conn.conf["admins"].count(check[2])==0:
                        return addperm(check[2],bot,input,"admin")
                    if check[1]=="voice" and input.conn.conf["voiced"].count(check[2])==0:
                        return addperm(check[2],bot,input,"voice")
                    if check[1]=="bot" and input.conn.conf["bots"].count(check[2])==0:
                        return addperm(check[2],bot,input,"bot")
                    elif (check[1]=="bot" or check[1]=="admin" or check[1]=="voiced"):
                        return("error. unknown error or already a "+check[1])
                if check[0]=="remove":
                    if check[1]=="admin" and input.conn.conf["admins"].count(check[2])==1:
                        return removeperm(check[2],bot,input,"admins")
                    if check[1]=="voice" and input.conn.conf["voiced"].count(check[2])==1:
                        return removeperm(check[2],bot,input,"voiced")
                    if check[1]=="bot" and input.conn.conf["bots"].count(check[2])==1:
                        return removeperm(check[2],bot,input,"bots")
                    elif (check[1]=="bot" or check[1]=="admin"):
                        return("error. unknown error or not a "+check[1])
            if perm.isowner(input):
                if check[0]=="add":
                    if check[1]=="admin" and input.conn.conf["admins"].count(check[2])==0:
                        return addperm(check[2], bot, input,"admin")
                    if check[1]=="voice" and input.conn.conf["voiced"].count(check[2])==0:
                        return addperm(check[2], bot, input,"voice")
                    if check[1]=="superadmin" and input.conn.conf["superadmins"].count(check[2])==0:
                        return addperm(check[2], bot, input,"superadmin")
                    if check[1]=="bot" and input.conn.conf["bots"].count(check[2])==0:
                        return addperm(check[2],bot,input,"bot")
                    elif (check[1]=="bot" or check[1]=="admin" or check[1]=="superadmin"):
                        return("error. unknown error or already a "+check[1])
                if check[0]=="remove" and perm.isowner(input):
                    if check[1]=="admin" and input.conn.conf["admins"].count(check[2])==1:
                        return removeperm(check[2],bot,input,"admins")
                    if check[1]=="voice" and input.conn.conf["voiced"].count(check[2])==1:
                        return removeperm(check[2],bot,input,"voiced")
                    if check[1]=="superadmin" and input.conn.conf["superadmins"].count(check[2])==1:
                        return removeperm(check[2],bot,input,"superadmins")
                    if check[1]=="bot" and input.conn.conf["bots"].count(check[2])==1:
                        return removeperm(check[2],bot,input,"bots")
                    elif (check[1]=="bot" or check[1]=="admin" or check[1]=="superadmin"):
                        return ("error. unknown error or not a "+check[1])
            elif not perm.isadmin(input):
                return("You are not an admin or not high enough in "
                "this bot's permission's system to do this.")
        if check[0]=="help":
            return errorMsg
        elif not ((check[0]=="list" and len(check)==2) or (len(check)==3)):
            return errorMsg
    elif not check[0] in cmdlist:
        return errorMsg