~sircmpwn/reminderbot

8435806f5962e5479578d31d3b4e46a9858cf3d8 — Drew DeVault 1 year, 4 months ago f21e122
Revert "Snooze last reminder sent to user who's asking"

This reverts commit f1a8bbacca5cf4132904943955db36b5849103ea.
1 files changed, 5 insertions(+), 8 deletions(-)

M reminderbot/bot.py
M reminderbot/bot.py => reminderbot/bot.py +5 -8
@@ 23,6 23,7 @@ sh.setFormatter(fmt)
logger.addHandler(sh)

redis = Redis()
last_reminder = None

UTC = timezone("UTC")



@@ 128,16 129,11 @@ async def on_want_reminder(msg, what=None, when=None, where=None):

@cmds.command("snooze")
async def snooze(*when, message=None):
    who = message.sender.name
    last_reminder_sent = sorted(
        [r for r in reminders if r.when <= now and r.who == who],
        key=lambda item: item.when,
        reverse=True
    )[0]

    await on_want_reminder(message, when=" ".join(when), what=last_reminder_sent.what)
    global last_reminder
    await on_want_reminder(message, when=" ".join(when), what=last_reminder)

async def main():
    global last_reminder
    asyncio.ensure_future(bot.run())
    global reminders
    while True:


@@ 149,5 145,6 @@ async def main():
        reminders = [r for r in reminders if r.when > now]
        for r in due:
            await bot.message(r.where, r.who + ": Reminder " + r.what)
            last_reminder = r.what
        if any(due):
            save_reminders(reminders)