Later: Allow multiple targets. Closes GH-1169.

This commit is contained in:
Valentin Lorentz 2015-09-23 11:23:21 +02:00
parent 82332ff87c
commit 1002ec5d30
2 changed files with 33 additions and 16 deletions

View File

@ -147,27 +147,38 @@ class Later(callbacks.Plugin):
## adding new ones.
@internationalizeDocstring
def tell(self, irc, msg, args, nick, text):
"""<nick> <text>
def tell(self, irc, msg, args, nicks, text):
"""<nick1[,nick2[,...]]> <text>
Tells <nick> <text> the next time <nick> is seen. <nick> can
Tells each <nickX> <text> the next time <nickX> is seen. <nickX> can
contain wildcard characters, and the first matching nick will be
given the note.
"""
self._deleteExpired()
if ircutils.strEqual(nick, irc.nick):
irc.error(_('I can\'t send notes to myself.'))
return
validnick = self._validateNick(irc, nick)
if validnick is False:
irc.error('That is an invalid IRC nick. Please check your input.')
return
try:
self._addNote(validnick, msg.nick, text)
validnicks = []
for nick in nicks:
if ircutils.strEqual(nick, irc.nick):
irc.error(_('I can\'t send notes to myself.'))
return
validnick = self._validateNick(irc, nick)
if validnick is False:
irc.error(_('%s is an invalid IRC nick. Please check your '
'input.' % nick))
return
validnicks.append(validnick)
full_queues = []
for validnick in validnicks:
try:
self._addNote(validnick, msg.nick, text)
except ValueError:
full_queues.append(validnick)
if full_queues:
irc.error(format(
_('These recipients\' message queue are already full: %L'),
full_queues))
else:
irc.replySuccess()
except ValueError:
irc.error(_('That person\'s message queue is already full.'))
tell = wrap(tell, ['something', 'text'])
tell = wrap(tell, [commalist('somethingWithoutSpaces'), 'text'])
@internationalizeDocstring
def notes(self, irc, msg, args, nick):

View File

@ -72,7 +72,7 @@ class LaterTestCase(ChannelPluginTestCase):
def testNoteSend(self):
self.assertNotError('later tell foo stuff')
self.assertNotError('later tell bar more stuff')
self.assertNotError('later tell bar,baz more stuff')
self.assertRegexp('later notes', 'bar.*foo')
testPrefix = 'foo!bar@baz'
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'something',
@ -83,6 +83,12 @@ class LaterTestCase(ChannelPluginTestCase):
self.assertNotRegexp('later notes', 'foo')
self.assertRegexp('later notes', 'bar')
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'something',
prefix='baz!baz@qux'))
m = self.getMsg(' ')
self.assertEqual(str(m).strip(),
'PRIVMSG #test :baz: Sent just now: <test> more stuff')
real_time = time.time
def fake_time():
return real_time() + 62