Later: add @undo command. Closes GH-76.

This commit is contained in:
Valentin Lorentz 2011-07-16 13:59:49 +02:00
parent 4e6d08c7ce
commit 24aa0b6754
3 changed files with 30 additions and 1 deletions

View File

@ -207,6 +207,27 @@ class Later(callbacks.Plugin):
irc.error(_('There were no notes for %r') % nick) irc.error(_('There were no notes for %r') % nick)
remove = wrap(remove, [('checkCapability', 'admin'), 'something']) remove = wrap(remove, [('checkCapability', 'admin'), 'something'])
@internationalizeDocstring
def undo(self, irc, msg, args, nick):
"""<nick>
Removes the latest note you sent to <nick>.
"""
if nick not in self._notes:
irc.error(_('There are no note waiting for %s.') % nick)
return
self._notes[nick].reverse()
for note in self._notes[nick]:
if note[1] == msg.nick:
self._notes[nick].remove(note)
if len(self._notes[nick]) == 0:
del self._notes[nick]
self._flushNotes()
irc.replySuccess()
return
irc.error(_('There are no note from you waiting for %s.') % nick)
undo = wrap(undo, ['something'])
def doPrivmsg(self, irc, msg): def doPrivmsg(self, irc, msg):
if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg): if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg):
return return

View File

@ -44,6 +44,14 @@ class LaterTestCase(ChannelPluginTestCase):
self.assertNotRegexp('later notes', 'bar.*foo') self.assertNotRegexp('later notes', 'bar.*foo')
self.assertRegexp('later notes', 'foo') self.assertRegexp('later notes', 'foo')
def testLaterUndo(self):
self.assertNotError('later tell foo 1')
self.assertNotError('later tell bar 1')
self.assertRegexp('later notes', 'bar.*foo')
self.assertNotError('later undo foo')
self.assertNotRegexp('later notes', 'bar.*foo')
self.assertRegexp('later notes', 'bar')
def testNickValidation(self): def testNickValidation(self):
origconf = conf.supybot.protocols.irc.strictRfc() origconf = conf.supybot.protocols.irc.strictRfc()
conf.supybot.protocols.irc.strictRfc.setValue('True') conf.supybot.protocols.irc.strictRfc.setValue('True')

View File

@ -1,3 +1,3 @@
"""stick the various versioning attributes in here, so we only have to change """stick the various versioning attributes in here, so we only have to change
them once.""" them once."""
version = '0.83.4.1+limnoria (2011-07-16T13:45:43+0200)' version = '0.83.4.1+limnoria (2011-07-16T13:59:49+0200)'