diff --git a/countdown/ircplugin.py b/countdown/ircplugin.py index 8edd977..9780636 100644 --- a/countdown/ircplugin.py +++ b/countdown/ircplugin.py @@ -22,7 +22,8 @@ class Countdown(Plugin): new_reminder_regex = (r'remind\s+(?P[^\s]+)\s+(?Pat|in|on)\s+(?P.*?)\s+' r'(and\s+every\s+(?P.*?)\s+)?' r'(until\s+(?P.*?)\s+)?' - r'(to|that|about)\s+(?P.*)') + r'(to|that|about)\s+(?P.*?)' + r'(?=\s+\("(?P.*)"\)|$)') def __init__(self, bot, connection, event): """Initialize some stuff.""" @@ -42,7 +43,7 @@ class Countdown(Plugin): self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], r'^!countdown\s+list$', self.handle_item_list, -20) - self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], r'^!countdown\s+(\S+)$', + self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], r'^!countdown\s+(.+)$', self.handle_item_detail, -20) self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], self.new_reminder_regex, self.handle_new_reminder, -50) @@ -99,9 +100,16 @@ class Countdown(Plugin): recurring_period = match.group('recurring_period') recurring_until = match.group('recurring_until') text = match.group('text') + name = match.group('name') log.debug("%s / %s / %s", who, when, text) - item_name = '{0:s}-{1:s}'.format(event.sender_nick, timezone.now().strftime('%s')) + if not name: + item_name = '{0:s}-{1:s}'.format(event.sender_nick, timezone.now().strftime('%s')) + else: + if CountdownItem.objects.filter(name=name).count() > 0: + self.bot.reply(event, "item with name '{0:s}' already exists".format(name)) + return 'NO MORE' + item_name = name # parse when to send the notification if when_type == 'in':