countdown: simpler reminders when in privmsg
This commit is contained in:
parent
48beddb580
commit
75f5985d71
|
@ -85,7 +85,9 @@ class Countdown(Plugin):
|
||||||
sender_nick = irc.client.NickMask(event.source).nick
|
sender_nick = irc.client.NickMask(event.source).nick
|
||||||
sent_location = reply_destination_for_event(event)
|
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?
|
# we were addressed, were we told to add a reminder?
|
||||||
trimmed_what = re.sub(addressed_my_nick, '', what)
|
trimmed_what = re.sub(addressed_my_nick, '', what)
|
||||||
log.debug(trimmed_what)
|
log.debug(trimmed_what)
|
||||||
|
@ -112,7 +114,7 @@ class Countdown(Plugin):
|
||||||
when_t = timezone.make_aware(parse(when))
|
when_t = timezone.make_aware(parse(when))
|
||||||
|
|
||||||
# parse the person to address, if anyone, when sending the notification
|
# 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
|
message = text
|
||||||
elif who == 'me':
|
elif who == 'me':
|
||||||
message = '{0:s}: {1:s}'.format(sender_nick, text)
|
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,
|
countdown_item = CountdownItem.objects.create(name=item_name, at_time=when_t, is_reminder=True,
|
||||||
reminder_message=message, reminder_target=sent_location)
|
reminder_message=message, reminder_target=sent_location)
|
||||||
log.info("created countdown item %s", str(countdown_item))
|
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'
|
return 'NO MORE'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue