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,))
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
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, ))
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,