def cmd(send, msg, _):
    """Finds a random quote from tjbash.org given search criteria.

    Syntax: {command} [searchstring]

    """
    if not msg:
        url = 'http://tjbash.org/random1.html'
        params = {}
    else:
        targs = msg.split()
        if len(targs) == 1 and targs[0].isnumeric():
            url = 'http://tjbash.org/%s' % targs[0]
            params = {}
        else:
            url = 'http://tjbash.org/search.html'
            params = {'query': 'tag:%s' % '+'.join(targs)}
    req = get(url, params=params)
    doc = fromstring(req.text)
    quotes = doc.find_class('quote-body')
    if not quotes:
        send("There were no results.")
        return
    quote = choice(quotes)
    lines = [x.strip() for x in map(operator.methodcaller('strip'), quote.itertext())]
    # Only send up to three lines.
    for line in lines[:4]:
        send(line)
    tags = quote.getparent().find_class('quote-tags')
    postid = quote.getparent().getparent().get('id').replace('quote-', '')
    if tags:
        tags = [x.text for x in tags[0].findall('.//a')]
        send(" -- {} -- {}http://tjbash.org/{}".format(', '.join(tags), "continued: " if (len(lines) > 3) else "", postid))
    else:
        send(" -- http://tjbash.org/{}".format(postid))