From 5dfb00ff7d8273468b1c70f0a03b90e3bca7daf1 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Wed, 3 Dec 2003 01:28:31 +0000 Subject: [PATCH] Added lobotomies command. --- ChangeLog | 3 +++ src/Channel.py | 15 +++++++++++++++ test/test_Channel.py | 3 +++ 3 files changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6736a6ce8..9f401b22f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ + * Added a Channel.lobotomies command to list the channels in which + the bot is lobotomized. + * Added a swap function to Math.rpn. * Changed the logging infrastructure significantly; each plugin diff --git a/src/Channel.py b/src/Channel.py index 31fff5385..6e251234d 100755 --- a/src/Channel.py +++ b/src/Channel.py @@ -377,6 +377,21 @@ class Channel(callbacks.Privmsg): c = ircdb.channels.getChannel(channel) irc.reply(msg, ', '.join(c.capabilities)) + def lobotomies(self, irc, msg, args): + """takes no arguments + + Returns the channels in which this bot is lobotomized. + """ + L = [] + for (channel, c) in ircdb.channels.iteritems(): + if c.lobotomized: + L.append(channel) + if L: + s = 'I\'m currently lobotomized in %s.' % utils.commaAndify(L) + irc.reply(msg, s) + else: + irc.reply(msg, 'I\'m not currently lobotomized in any channels.') + Class = Channel diff --git a/test/test_Channel.py b/test/test_Channel.py index 295da4565..bbfbcb6cf 100644 --- a/test/test_Channel.py +++ b/test/test_Channel.py @@ -37,6 +37,9 @@ import ircmsgs class ChannelTestCase(ChannelPluginTestCase, PluginDocumentation): plugins = ('Channel',) + def testLobotomies(self): + self.assertRegexp('lobotomies', 'not.*any') + def testUnban(self): self.assertError('unban foo!bar@baz') self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))