Esempio n. 1
0
    def execute(self, message, user, params):

        channel = params.group(1)
        chan = Channel.load(channel)
        if chan is None:
            message.reply("Channel '%s' does not exist" % (channel, ))
            if user.is_admin():
                #                message.privmsg("remuser %s %s" %(channel, Config.get('Connection', 'nick')),Config.get("Services", "nick"))
                message.privmsg("set %s autoinvite off" % (channel),
                                Config.get("Services", "nick"))
                message.part(channel)
            return

        if chan.userlevel >= user.access and not user.is_admin():
            message.reply(
                "You may not remove %s, the channel's access (%s) exceeds your own (%s)"
                % (
                    chan.name,
                    chan.userlevel,
                    user.access,
                ))
            return

        session.delete(chan)
        session.commit()

        #        message.privmsg("remuser %s %s" %(chan.name, Config.get('Connection', 'nick')),Config.get("Services", "nick"))
        message.privmsg("set %s autoinvite off" % (channel),
                        Config.get("Services", "nick"))
        message.part(chan.name)
        message.reply("Removed channel %s" % (chan.name, ))
Esempio n. 2
0
 def execute(self, message, user, params):
     
     chan = params.group(1)
     access = params.group(2)
     if not access.isdigit():
         try:
             access = Config.getint("Access",access)
         except Exception:
             message.reply("Invalid access level '%s'" % (access,))
             return
     else:
         access = int(access)
     
     if access > user.access:
         message.reply("You may not add a user with higher access to your own")
         return
     
     try:
         session.add(Channel(name=chan, userlevel=access, maxlevel=user.access))
         session.commit()
         message.reply("Added chan %s at level %s" % (chan,access,))
         message.privmsg("set %s autoinvite on" %(chan,),Config.get("Services", "nick"));
         message.privmsg("invite %s" %(chan,),Config.get("Services", "nick"));
     except IntegrityError:
         session.rollback()
         message.reply("Channel %s already exists" % (chan,))
Esempio n. 3
0
    def execute(self, message, user, params):

        # Sort out parameters
        chan = params.group(1)
        access = params.group(2)
        maxaccess = params.group(3)

        # Load Channel
        c = Channel.load(chan)
        if c is None:
            message.reply("'%s'? Is that even a channel?" % (chan, ))
            return
        elif c.userlevel > user.access:
            message.reply(
                "You may not edit a channel with higher access than you")

        # Parse access
        if not access.isdigit():
            try:
                access = Config.getint("Access", access)
            except Exception:
                message.reply("Invalid access level '%s'" % (access, ))
                return
        else:
            access = int(access)

        if access > user.access:
            message.reply(
                "You may not give a channel a higher access level than your own"
            )
            return

        # Parse maxaccess
        if maxaccess:
            if not maxaccess.isdigit():
                try:
                    maxaccess = Config.getint("Access", maxaccess)
                except Exception:
                    message.reply("Invalid access level '%s'" % (maxaccess, ))
                    return
            else:
                maxaccess = int(maxaccess)

            if maxaccess > user.access:
                message.reply(
                    "You may not give a channel a higher access level than your own"
                )
                return

        c.userlevel = access
        if maxaccess:
            c.maxlevel = maxaccess
        session.commit()
        message.reply("Edited channel %s access to %s%s" %
                      (chan, access,
                       (" (max: %s)" % maxaccess) if maxaccess else ""))
Esempio n. 4
0
    def execute(self, message, user, params):
        
        chan = params.group(1)
        if chan[0] != "#":
            chan = "#" + chan

        c = Channel.load(chan)
        if c is None:
            message.reply("No such channel: '%s'" % (chan,))
            return
        
        message.reply("%s: %s (Max: %s)" % (c.name, c.userlevel, c.maxlevel))
Esempio n. 5
0
    def execute(self, message, user, params):

        chan = params.group(1)
        if chan[0] != "#":
            chan = "#" + chan

        c = Channel.load(chan)
        if c is None:
            message.reply("No such channel: '%s'" % (chan, ))
            return

        message.reply("%s: %s (Max: %s)" % (c.name, c.userlevel, c.maxlevel))
Esempio n. 6
0
 def check_access(self, message, access=None, user=None, channel=None):
     access = access or self.access
     if message.in_chan():
         channel = channel or Channel.load(message.get_chan()) or Channel(
             maxlevel=0, userlevel=0)
         if channel.maxlevel < access and message.reply_type(
         ) == PUBLIC_REPLY:
             raise UserError
     else:
         channel = Channel(userlevel=0)
     chan = message.get_chan() if message.in_chan() else None
     user = user or CUT.get_user(
         message.get_nick(), chan, pnickf=message.get_pnick)
     if self.is_user(user):
         if max(user.access, channel.userlevel) >= access:
             return user
         else:
             raise UserError
     else:
         if channel.userlevel >= access:
             return User()
         elif message.get_pnick():
             raise UserError
Esempio n. 7
0
    def execute(self, message, user, params):
        
        # Sort out parameters
        chan = params.group(1)
        access = params.group(2)
        maxaccess = params.group(3)

        # Load Channel
        c = Channel.load(chan)
        if c is None:
            message.reply("'%s'? Is that even a channel?" % (chan,))
            return
        elif c.userlevel > user.access:
            message.reply("You may not edit a channel with higher access than you")
            

        # Parse access
        if not access.isdigit():
            try:
                access = Config.getint("Access", access)
            except Exception:
                message.reply("Invalid access level '%s'" % (access,))
                return
        else:
            access = int(access)
        
        if access > user.access:
            message.reply("You may not give a channel a higher access level than your own")
            return

        # Parse maxaccess
        if maxaccess:
            if not maxaccess.isdigit():
                try:
                    maxaccess = Config.getint("Access", maxaccess)
                except Exception:
                    message.reply("Invalid access level '%s'" % (maxaccess,))
                    return
            else:
                maxaccess = int(maxaccess)
            
            if maxaccess > user.access:
                message.reply("You may not give a channel a higher access level than your own")
                return

        c.userlevel = access
        if maxaccess:
            c.maxlevel = maxaccess
        session.commit()
        message.reply("Edited channel %s access to %s%s" % (chan, access, (" (max: %s)" % maxaccess) if maxaccess else ""))
Esempio n. 8
0
 def execute(self, message, user, params):
     commands = []
     message.reply(self.doc+". For more information use: "+self.usage)
     if message.in_chan():
         channel = Channel.load(message.get_chan())
     else:
         channel = None
     for callback in Callbacks.callbacks["PRIVMSG"]:
         try:
             if callback.check_access(message, None, user, channel) is not None:
                 commands.append(callback.name)
         except PNickParseError:
             continue
         except UserError:
             continue
     message.reply("Loaded commands: " + ", ".join(commands))
Esempio n. 9
0
 def execute(self, message, user, params):
     commands = []
     message.reply(self.doc + ". For more information use: " + self.usage)
     if message.in_chan():
         channel = Channel.load(message.get_chan())
     else:
         channel = None
     for callback in Callbacks.callbacks["PRIVMSG"]:
         try:
             if callback.check_access(message, None, user,
                                      channel) is not None:
                 commands.append(callback.name)
         except PNickParseError:
             continue
         except UserError:
             continue
     message.reply("Loaded commands: " + ", ".join(commands))
Esempio n. 10
0
 def check_access(self, message, user=None, channel=None):
     if message.in_chan():
         channel = channel or Channel.load(message.get_chan()) or Channel(maxlevel=0, userlevel=0)
         if channel.maxlevel < self.access and message.reply_type() == PUBLIC_REPLY:
             raise UserError
     else:
         channel = Channel(userlevel=0)
     user = user or CUT.get_user(message.get_nick(), pnickf=message.get_pnick)
     if self.is_user(user):
         if max(user.access, channel.userlevel) >= self.access:
             return user
         else:
             raise UserError
     else:
         if channel.userlevel >= self.access:
             return True
         elif message.get_pnick():
             raise UserError
Esempio n. 11
0
    def execute(self, message, user, params):

        chan = params.group(1)
        if "galmate" in Config.options("Access"):
            access = Config.getint("Access", "galmate")
        else:
            access = 0

        try:
            session.add(Channel(name=chan, userlevel=access, maxlevel=access))
            session.commit()
            message.reply(
                "Added your galchannel as %s (if you didn't add me to the channel with at least access 24 first, I'm never going to bother joining)"
                % (chan, ))
            message.privmsg("set %s autoinvite on" % (chan, ),
                            Config.get("Services", "nick"))
            message.privmsg("invite %s" % (chan, ),
                            Config.get("Services", "nick"))
        except IntegrityError:
            session.rollback()
            message.reply("Channel %s already exists" % (chan, ))
Esempio n. 12
0
 def execute(self, message, user, params):
     
     channel = params.group(1)
     chan = Channel.load(channel)
     if chan is None:
         message.reply("Channel '%s' does not exist" % (channel,))
         if user.is_admin():
             message.privmsg("remuser %s %s" %(channel, Config.get('Connection', 'nick')),Config.get("Services", "nick"))
             message.part(channel)
         return
     
     if chan.userlevel >= user.access and not user.is_admin():
         message.reply("You may not remove %s, the channel's access (%s) exceeds your own (%s)" % (chan.name, chan.userlevel, user.access,))
         return
     
     session.delete(chan)
     session.commit()
     
     message.privmsg("remuser %s %s" %(chan.name, Config.get('Connection', 'nick')),Config.get("Services", "nick"))
     message.part(chan.name)
     message.reply("Removed channel %s" % (chan.name,))
Esempio n. 13
0
def pinvite(message):
    # P invites us to a channel
    if (message.get_hostmask().lower() == Config.get("Services", "host").lower() or message.get_pnick() in Config.options("Admins")) and Channel.load(message.get_msg()) is not None:
        message.join(message.get_msg())
Esempio n. 14
0
File: auth.py Progetto: JDD/DLR
def pinvite(message):
    # P invites us to a channel
    if message.get_hostmask() == "[email protected]" and Channel.load(message.get_msg()) is not None:
        message.join(message.get_msg())
Esempio n. 15
0
    print "A public schema already exists, but this is completely normal"
    session.rollback()
else:
    session.commit()
finally:
    session.close()

Base.metadata.create_all()

print "Setting up default channels"
userlevel = Config.get("Access", "member")
maxlevel = Config.get("Access", "admin")
gallevel = Config.get("Access", "galmate")
for chan, name in Config.items("Channels"):
    try:
        channel = Channel(name=name)
        if chan != "public":
            channel.userlevel = userlevel
            channel.maxlevel = maxlevel
        else:
            channel.userlevel = gallevel
            channel.maxlevel = gallevel
        session.add(channel)
        session.flush()
    except IntegrityError:
        print "Channel '%s' already exists" % (channel.name, )
        session.rollback()
    else:
        print "Created '%s' with access (%s|%s)" % (
            channel.name,
            channel.userlevel,
Esempio n. 16
0
    print "A public schema already exists, but this is completely normal"
    session.rollback()
else:
    session.commit()
finally:
    session.close()

Base.metadata.create_all()

print "Setting up default channels"
userlevel = Config.get("Access", "member")
maxlevel = Config.get("Access", "admin")
gallevel = Config.get("Access", "galmate")
for chan, name in Config.items("Channels"):
    try:
        channel = Channel(name=name)
        if chan != "public":
            channel.userlevel = userlevel
            channel.maxlevel = maxlevel
        else:
            channel.userlevel = gallevel
            channel.maxlevel = gallevel
        session.add(channel)
        session.flush()
    except IntegrityError:
        print "Channel '%s' already exists" % (channel.name,)
        session.rollback()
    else:
        print "Created '%s' with access (%s|%s)" % (channel.name, channel.userlevel, channel.maxlevel,)
        session.commit()
session.close()
Esempio n. 17
0
def pinvite(message):
    # P invites us to a channel
    if message.get_hostmask().lower() == Config.get("Services", "host").lower() and Channel.load(message.get_msg()) is not None:
        message.join(message.get_msg())