mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-30 14:14:37 +01:00
Later: add @undo command. Closes GH-76.
This commit is contained in:
parent
4e6d08c7ce
commit
24aa0b6754
@ -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):
|
||||
"""<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):
|
||||
if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg):
|
||||
return
|
||||
|
@ -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')
|
||||
|
@ -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)'
|
||||
|
Loading…
Reference in New Issue
Block a user