From 4e7a00d504c263e6443280f39b8e775978362dd7 Mon Sep 17 00:00:00 2001 From: Ali Afshar Date: Fri, 25 Mar 2005 14:03:44 +0000 Subject: [PATCH] Admin refactored ignore/unignore/ignores to ignore add/remove/list, and changed tests accordingly. --- plugins/Admin/plugin.py | 68 +++++++++++++++++++++-------------------- plugins/Admin/test.py | 22 ++++++------- 2 files changed, 46 insertions(+), 44 deletions(-) diff --git a/plugins/Admin/plugin.py b/plugins/Admin/plugin.py index 9adddceea..9cbb59346 100644 --- a/plugins/Admin/plugin.py +++ b/plugins/Admin/plugin.py @@ -291,44 +291,46 @@ class Admin(callbacks.Plugin): irc.error(s) remove = wrap(remove, ['otherUser','lowered']) - def ignore(self, irc, msg, args, hostmask, expires): - """ [] + class ignore(callbacks.Commands): - Ignores or, if a nick is given, ignores whatever hostmask - that nick is currently using. is a "seconds from now" value - that determines when the ignore will expire; if, for instance, you wish - for the ignore to expire in an hour, you could give an of - 3600. If no is given, the ignore will never automatically - expire. - """ - ircdb.ignores.add(hostmask, expires) - irc.replySuccess() - ignore = wrap(ignore, ['hostmask', additional('expiry', 0)]) + def add(self, irc, msg, args, hostmask, expires): + """ [] - def unignore(self, irc, msg, args, hostmask): - """ - - Ignores or, if a nick is given, ignores whatever hostmask - that nick is currently using. - """ - try: - ircdb.ignores.remove(hostmask) + Ignores or, if a nick is given, ignores whatever hostmask + that nick is currently using. is a "seconds from now" value + that determines when the ignore will expire; if, for instance, you wish + for the ignore to expire in an hour, you could give an of + 3600. If no is given, the ignore will never automatically + expire. + """ + ircdb.ignores.add(hostmask, expires) irc.replySuccess() - except KeyError: - irc.error('%s wasn\'t in the ignores database.' % hostmask) - unignore = wrap(unignore, ['hostmask']) + add = wrap(add, ['hostmask', additional('expiry', 0)]) - def ignores(self, irc, msg, args): - """takes no arguments + def remove(self, irc, msg, args, hostmask): + """ - Returns the hostmasks currently being globally ignored. - """ - # XXX Add the expirations. - if ircdb.ignores.hostmasks: - irc.reply(format('%L', (map(repr,ircdb.ignores.hostmasks)))) - else: - irc.reply('I\'m not currently globally ignoring anyone.') - ignores = wrap(ignores) + Ignores or, if a nick is given, ignores whatever hostmask + that nick is currently using. + """ + try: + ircdb.ignores.remove(hostmask) + irc.replySuccess() + except KeyError: + irc.error('%s wasn\'t in the ignores database.' % hostmask) + remove = wrap(remove, ['hostmask']) + + def list(self, irc, msg, args): + """takes no arguments + + Returns the hostmasks currently being globally ignored. + """ + # XXX Add the expirations. + if ircdb.ignores.hostmasks: + irc.reply(format('%L', (map(repr,ircdb.ignores.hostmasks)))) + else: + irc.reply('I\'m not currently globally ignoring anyone.') + list = wrap(list) Class = Admin diff --git a/plugins/Admin/test.py b/plugins/Admin/test.py index 5b5243902..69e2d3d4f 100644 --- a/plugins/Admin/test.py +++ b/plugins/Admin/test.py @@ -48,18 +48,18 @@ class AdminTestCase(PluginTestCase): getAfterJoinMessages() self.assertRegexp('channels', '#bar, #Baz, and #foo') - def testIgnoreUnignore(self): - self.assertNotError('admin ignore foo!bar@baz') - self.assertError('admin ignore alsdkfjlasd') - self.assertNotError('admin unignore foo!bar@baz') - self.assertError('admin unignore foo!bar@baz') + def testIgnoreAddRemove(self): + self.assertNotError('admin ignore add foo!bar@baz') + self.assertError('admin ignore add alsdkfjlasd') + self.assertNotError('admin ignore remove foo!bar@baz') + self.assertError('admin ignore remove foo!bar@baz') - def testIgnores(self): - self.assertNotError('admin ignores') - self.assertNotError('admin ignore foo!bar@baz') - self.assertNotError('admin ignores') - self.assertNotError('admin ignore foo!bar@baz') - self.assertNotError('admin ignores') + def testIgnoreList(self): + self.assertNotError('admin ignore list') + self.assertNotError('admin ignore add foo!bar@baz') + self.assertNotError('admin ignore list') + self.assertNotError('admin ignore add foo!bar@baz') + self.assertRegexp('admin ignore list', 'foo') def testCapabilityAdd(self): self.assertError('capability add foo bar')