Пример #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, ))
Пример #2
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 ""))
Пример #3
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))
Пример #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))
Пример #5
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 ""))
Пример #6
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))
Пример #7
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))
Пример #8
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
Пример #9
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,))
Пример #10
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
Пример #11
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())
Пример #12
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())
Пример #13
0
Файл: auth.py Проект: 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())