From 76b70ec784c43c834bea5c307f0eece0c17a08c9 Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Thu, 23 Feb 2017 18:45:06 -0600 Subject: [PATCH] countdown: use match labels in new reminder regex this thing is going to get hairy soon, so might as well do this now --- countdown/ircplugin.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/countdown/ircplugin.py b/countdown/ircplugin.py index f15c65c..c135234 100644 --- a/countdown/ircplugin.py +++ b/countdown/ircplugin.py @@ -20,7 +20,8 @@ log = logging.getLogger('countdown.ircplugin') class Countdown(Plugin): """Report on countdown items.""" - new_reminder_regex = r'remind\s+([^\s]+)\s+(at|in|on)\s+(.*?)\s+(to|that|about)\s+(.*)' + new_reminder_regex = (r'remind\s+(?P[^\s]+)\s+(?Pat|in|on)\s+(?P.*?)\s+' + r'(to|that|about)\s+(?P.*)') def __init__(self, bot, connection, event): """Initialize some stuff.""" @@ -96,10 +97,10 @@ class Countdown(Plugin): match = re.match(self.new_reminder_regex, trimmed_what, re.IGNORECASE) if match: log.debug("%s is a new reminder request", trimmed_what) - who = match.group(1) - when_type = match.group(2) - when = match.group(3) - text = match.group(5) + who = match.group('who') + when_type = match.group('when_type') + when = match.group('when') + text = match.group('text') log.debug("%s / %s / %s", who, when, text) item_name = '{0:s}-{1:s}'.format(sender_nick, timezone.now().strftime('%s'))