Handles quotes.
    Syntax: {command} <number|nick>, !quote --add <quote> --nick <nick> (--approve), !quote --list, !quote --delete <number>, !quote --edit <number> <quote> --nick <nick>
    !quote --search (--offset <num>) <number>

def cmd(send, msg, args):
    """Handles quotes.
    Syntax: {command} <number|nick>, !quote --add <quote> --nick <nick> (--approve), !quote --list, !quote --delete <number>, !quote --edit <number> <quote> --nick <nick>
    !quote --search (--offset <num>) <number>
    """
    session = args['db']
    parser = arguments.ArgParser(args['config'])
    parser.add_argument('--approve', action='store_true')
    parser.add_argument('--nick', nargs='?')
    parser.add_argument('--offset', nargs='?', type=int, default=0)
    parser.add_argument('quote', nargs='*')
    group = parser.add_mutually_exclusive_group()
    group.add_argument('--list', action='store_true')
    group.add_argument('--add', action='store_true')
    group.add_argument('--delete', '--remove', type=int)
    group.add_argument('--edit', type=int)
    group.add_argument('--search', nargs='*')

    if not msg:
        send(do_get_quote(session))
        return

    try:
        cmdargs = parser.parse_args(msg)
    except arguments.ArgumentException as e:
        send(str(e))
        return

    if cmdargs.add:
        if args['type'] == 'privmsg':
            send("You want everybody to know about your witty sayings, right?")
        else:
            if cmdargs.nick is None:
                send('You must specify a nick.')
            elif not cmdargs.quote:
                send('You must specify a quote.')
            else:
                isadmin = args['is_admin'](args['nick']) or not args['config']['feature']['quoteapprove']
                approved = cmdargs.approve or not args['config']['feature']['quoteapprove']
                do_add_quote(cmdargs.nick, " ".join(cmdargs.quote), session, isadmin, approved, send, args)
    elif cmdargs.list:
        send(do_list_quotes(session, args['config']['core']['url']))
    elif cmdargs.delete:
        send(do_delete_quote(args, session, cmdargs.delete))
    elif cmdargs.edit:
        if args['is_admin'](args['nick']):
            send(do_update_quote(session, cmdargs.edit, cmdargs.nick, cmdargs.quote))
        else:
            send("You aren't allowed to edit quotes. Please ask a bot admin to do it")
    elif cmdargs.search:
        if cmdargs.approve or cmdargs.nick:
            send("Invalid option for --search")
        else:
            send(search_quote(session, cmdargs.offset, cmdargs.search))
    else:
        if msg.isdigit():
            send(do_get_quote(session, int(msg)))
        else:
            if not re.match(args['config']['core']['nickregex'], msg):
                send('Invalid nick %s.' % msg)
            else:
                send(get_quotes_nick(session, msg))