def cmd(send, msg, args):
    """When a nick was last seen.

    Syntax: {command} <nick>

    """
    if not msg:
        send("Seen who?")
        return
    cmdchar, ctrlchan = args['config']['core']['cmdchar'], args['config']['core']['ctrlchan']
    last = get_last(args['db'], cmdchar, ctrlchan, msg)
    if last is None:
        send("%s has never shown their face." % msg)
        return
    delta = datetime.now() - last.time
    # We only need second-level precision.
    delta -= delta % timedelta(seconds=1)
    output = "%s was last seen %s ago " % (msg, delta)
    if last.type == 'pubmsg' or last.type == 'privmsg':
        output += 'saying "%s"' % last.msg
    elif last.type == 'action':
        output += 'doing "%s"' % last.msg
    elif last.type == 'part':
        output += 'leaving and saying "%s"' % last.msg
    elif last.type == 'nick':
        output += 'nicking to %s' % last.msg
    elif last.type == 'quit':
        output += 'quiting and saying "%s"' % last.msg
    elif last.type == 'kick':
        output += 'kicking %s for "%s"' % last.msg.split(',')
    elif last.type == 'topic':
        output += 'changing topic to %s' % last.msg
    elif last.type in ['pubnotice', 'privnotice']:
        output += 'sending notice %s' % last.msg
    elif last.type == 'mode':
        output += 'setting mode %s' % last.msg
    else:
        raise Exception("Invalid type.")
    send(output)
When a nick was last seen.

    Syntax: {command} <nick>