Iwant: Add the @delete command.

master
Valentin Lorentz 2012-08-30 17:41:53 +02:00
parent c9130f2d8f
commit 37144ac176
2 changed files with 18 additions and 0 deletions

View File

@ -115,6 +115,21 @@ class Iwant(callbacks.Plugin):
irc.reply(_('Wish #%i is %s.') % wish)
random = wrap(random, ['channel'])
@internationalizeDocstring
def delete(self, irc, msg, args, channel, id):
"""[<channel>] <id>
Deletes the thing number <id>. <channel> is only needed if you
don't send the message on the channel itself."""
wishlist = unserialize(self.registryValue('wishlist', channel))
if len(wishlist) < id:
irc.error(_('No thing has this id.'))
return
thing = wishlist.pop(id - 1)
self.setRegistryValue('wishlist', serialize(wishlist), channel)
irc.reply(_('Successfully deleted: %s') % thing)
delete = wrap(delete, ['channel', 'id'])
Class = Iwant

View File

@ -45,6 +45,9 @@ class IwantTestCase(ChannelPluginTestCase):
'#3: be cool')
self.assertResponse('iwant get 2', 'Wish #2 is a working plugin.')
self.assertNotError('iwant random')
self.assertResponse('delete 1', 'Successfully deleted: you')
self.assertResponse('iwant list', '#1: a working plugin and '
'#2: be cool')
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: