Quiets a user, then unquiets them after the specified period of time.

    Syntax: {command} <timespec> <nickname>
    timespec is in the format: <number><unit>, where unit is s, m, h, or d.

def cmd(send, msg, args):
    """Quiets a user, then unquiets them after the specified period of time.

    Syntax: {command} <timespec> <nickname>
    timespec is in the format: <number><unit>, where unit is s, m, h, or d.

    """
    nickregex = args['config']['core']['nickregex']
    setmode = args['handler'].connection.mode
    channel = args['target']
    with args['handler'].data_lock:
        ops = args['handler'].opers[channel].copy()
    if args['botnick'] not in ops:
        send("Bot must be an op.")
        return
    time, user = msg.split(maxsplit=1)
    if user == args['botnick']:
        send("I won't put myself in timeout!")
        return
    if not re.match(nickregex, user):
        send("%s is an invalid nick." % user)
        return

    time = parse_time(time)
    if time is None:
        send("Invalid unit.")
    else:
        if args['config']['feature']['networktype'] == 'unrealircd':
            setmode(channel, " +b ~q:%s!*@*" % user)
            defer_args = [channel, " -b ~q:%s!*@*" % user]
        elif args['config']['feature']['networktype'] == 'atheme':
            setmode(channel, " +q-v %s!*@* %s" % (user, user))
            defer_args = [channel, " -q %s!*@*" % user]
        else:
            raise Exception("networktype undefined or unknown in config.cfg")
        ident = args['handler'].workers.defer(time, True, setmode, *defer_args)
        send("%s has been put in timeout, ident: %d" % (user, ident))