From 24aa0b6754b6dda35fe63b70e0a2bc72913c5b0c Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 16 Jul 2011 13:59:49 +0200 Subject: [PATCH] Later: add @undo command. Closes GH-76. --- plugins/Later/plugin.py | 21 +++++++++++++++++++++ plugins/Later/test.py | 8 ++++++++ src/version.py | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/plugins/Later/plugin.py b/plugins/Later/plugin.py index 56731da46..bd118043c 100644 --- a/plugins/Later/plugin.py +++ b/plugins/Later/plugin.py @@ -207,6 +207,27 @@ class Later(callbacks.Plugin): irc.error(_('There were no notes for %r') % nick) remove = wrap(remove, [('checkCapability', 'admin'), 'something']) + @internationalizeDocstring + def undo(self, irc, msg, args, nick): + """ + + Removes the latest note you sent to . + """ + 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): if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg): return diff --git a/plugins/Later/test.py b/plugins/Later/test.py index 49a5a672e..0481d4dc7 100644 --- a/plugins/Later/test.py +++ b/plugins/Later/test.py @@ -44,6 +44,14 @@ class LaterTestCase(ChannelPluginTestCase): self.assertNotRegexp('later notes', 'bar.*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): origconf = conf.supybot.protocols.irc.strictRfc() conf.supybot.protocols.irc.strictRfc.setValue('True') diff --git a/src/version.py b/src/version.py index b32c63e66..778a19ff3 100644 --- a/src/version.py +++ b/src/version.py @@ -1,3 +1,3 @@ """stick the various versioning attributes in here, so we only have to change 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)'