'Bans are stored in a serverconf db object as a list of
dictionaries:
[ (name, ip, ipregex, date, reason),
(name, ip, ipregex, date, reason),...  ]
where name and ip are set by the user and are shown in
lists. ipregex is a converted form of ip where the * is
replaced by an appropriate regex pattern for fast
matching. date is the time stamp the ban was instigated and
\'reason\' is any optional info given to the command. Unset
values in each tuple is set to the empty string.'

def func(self):

    banlist = ServerConfig.objects.conf('server_bans')
    if (not banlist):
        banlist = []
    if ((not self.args) or (self.switches and (not any(((switch in ('ip', 'name')) for switch in self.switches))))):
        self.caller.msg(list_bans(banlist))
        return
    now = time.ctime()
    reason = ''
    if (':' in self.args):
        (ban, reason) = self.args.rsplit(':', 1)
    else:
        ban = self.args
    ban = ban.lower()
    ipban = IPREGEX.findall(ban)
    if (not ipban):
        typ = 'Name'
        bantup = (ban, '', '', now, reason)
    else:
        typ = 'IP'
        ban = ipban[0]
        ipregex = ban.replace('.', '\\.')
        ipregex = ipregex.replace('*', '[0-9]{1,3}')
        ipregex = re.compile(('%s' % ipregex))
        bantup = ('', ban, ipregex, now, reason)
    banlist.append(bantup)
    ServerConfig.objects.conf('server_bans', banlist)
    self.caller.msg(('%s-Ban    |w%s|n    was    added.' % (typ, ban)))
