def at_reminder(client, channel, nick, args):
global _scheduled<EOL>now = datetime.datetime.utcnow().replace(tzinfo=pytz.UTC)<EOL>hh, mm = map(int, args[<NUM_LIT:0>].split('<STR_LIT::>'))<EOL>args = args[<NUM_LIT:1>:]<EOL>timezone = pytz.timezone(getattr(settings, '<STR_LIT>', '<STR_LIT>'))<EOL>try:<EOL><INDENT>timezone = pytz.timezone(args[<NUM_LIT:0>])<EOL><DEDENT>except pytz.UnknownTimeZoneError:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>args = args[<NUM_LIT:1>:]<EOL><DEDENT>local_now = now.astimezone(timezone)<EOL>local_next = local_now.replace(hour=hh, minute=mm)<EOL>if local_next <= local_now:<EOL><INDENT>local_next += datetime.timedelta(days=<NUM_LIT:1>)<EOL><DEDENT>reminder = {<EOL>'<STR_LIT>': local_next.astimezone(pytz.UTC),<EOL>'<STR_LIT>': channel,<EOL>'<STR_LIT:message>': '<STR_LIT:U+0020>'.join(args),<EOL>'<STR_LIT>': nick,<EOL>}<EOL>try:<EOL><INDENT>repeat = args[-<NUM_LIT:2>] == '<STR_LIT>'<EOL><DEDENT>except IndexError:<EOL><INDENT>repeat = False<EOL><DEDENT>if repeat:<EOL><INDENT>sched = args[-<NUM_LIT:1>]<EOL>reminder['<STR_LIT:message>'] = '<STR_LIT:U+0020>'.join(args[:-<NUM_LIT:2>])<EOL>repeat_days = sorted([v for k, v in days_of_week.iteritems() if k in sched])<EOL>if not repeat_days:<EOL><INDENT>return u"<STR_LIT>".format(sched)<EOL><DEDENT>reminder['<STR_LIT>'] = repeat_days<EOL>for attempt in xrange(<NUM_LIT:7>):<EOL><INDENT>if reminder['<STR_LIT>'].weekday() in repeat_days:<EOL><INDENT>break<EOL><DEDENT>reminder['<STR_LIT>'] += datetime.timedelta(days=<NUM_LIT:1>)<EOL><DEDENT><DEDENT>if reminder['<STR_LIT:message>'].startswith('<STR_LIT>'):<EOL><INDENT>parts = reminder['<STR_LIT:message>'].split('<STR_LIT:U+0020>')<EOL>chan = parts[<NUM_LIT:1>]<EOL>reminder['<STR_LIT:message>'] = '<STR_LIT:U+0020>'.join(parts[<NUM_LIT:2>:])<EOL>if not chan.startswith('<STR_LIT:#>'):<EOL><INDENT>chan = '<STR_LIT>'.format(chan)<EOL><DEDENT>reminder['<STR_LIT>'] = chan<EOL><DEDENT>id = db.reminders.insert(reminder)<EOL>diff = reminder['<STR_LIT>'] - now<EOL>delay = (diff.days * <NUM_LIT> * <NUM_LIT>) + diff.seconds<EOL>_scheduled.add(id)<EOL>reactor.callLater(delay, _do_reminder, id, client)<EOL>return u'<STR_LIT>'.format(readable_time_delta(delay))<EOL>
Schedule a reminder to occur at a specific time. The given time can optionally
be specified to occur at a specific timezone, but will default to the value
of settings.TIMEZONE if none is specified. Times should be on a 24-hour clock.

These types of reminders are repeatable, should the last two words of the message
be of the form "repeat <days_of_week>" where days_of_week is a single string consisting
of any of the following days: M, Tu, W, Th, F, Sa, Su. For example, 'repeat MWF'
will repeat a reminder at the same time every Monday, Wednesday, and Friday.

A full example of how one would use this:

    <sduncan> helga at 13:00 EST standup time repeat MTuWThF

This will create a reminder "standup time" to occur at 1:00PM Eastern every weekday.

Optionally, a specific channel can be specified to receive the reminder message. This
is useful if creating several reminders via a private message. To use this, specify
"on <channel>" between the time amount and the message:

    <sduncan> helga at 13:00 EST on #bots standup time repeat MTuWThF
    <sduncan> helga at 13:00 EST on bots standup time repeat MTuWThF

Note that the '#' char for specifying the channel is entirely optional.