countdown: use match labels in new reminder regex
this thing is going to get hairy soon, so might as well do this now
This commit is contained in:
parent
5b79cea3c6
commit
76b70ec784
|
@ -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<who>[^\s]+)\s+(?P<when_type>at|in|on)\s+(?P<when>.*?)\s+'
|
||||
r'(to|that|about)\s+(?P<text>.*)')
|
||||
|
||||
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'))
|
||||
|
|
Loading…
Reference in New Issue