countdown: simpler reminders when in privmsg

This commit is contained in:
Brian S. Stephan 2017-02-22 23:10:01 -06:00
parent 48beddb580
commit 75f5985d71
1 changed files with 9 additions and 3 deletions

View File

@ -85,7 +85,9 @@ class Countdown(Plugin):
sender_nick = irc.client.NickMask(event.source).nick
sent_location = reply_destination_for_event(event)
if re.search(addressed_my_nick, what, re.IGNORECASE) is not None:
in_privmsg = sender_nick == sent_location
if re.search(addressed_my_nick, what, re.IGNORECASE) is not None or in_privmsg:
# we were addressed, were we told to add a reminder?
trimmed_what = re.sub(addressed_my_nick, '', what)
log.debug(trimmed_what)
@ -112,7 +114,7 @@ class Countdown(Plugin):
when_t = timezone.make_aware(parse(when))
# parse the person to address, if anyone, when sending the notification
if who == 'us' or who == sent_location:
if who == 'us' or who == sent_location or in_privmsg:
message = text
elif who == 'me':
message = '{0:s}: {1:s}'.format(sender_nick, text)
@ -123,7 +125,11 @@ class Countdown(Plugin):
countdown_item = CountdownItem.objects.create(name=item_name, at_time=when_t, is_reminder=True,
reminder_message=message, reminder_target=sent_location)
log.info("created countdown item %s", str(countdown_item))
self.bot.reply(event, "ok, i'll message {0:s} at {1:s}".format(sent_location, str(when_t)))
if in_privmsg:
self.bot.reply(event, "ok, i'll message you at {0:s}".format(str(when_t)))
else:
self.bot.reply(event, "ok, i'll message {0:s} at {1:s}".format(sent_location, str(when_t)))
return 'NO MORE'