From 3944b00001ab318e3d87b7b99f4d7a28570cc649 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 23 Oct 2003 08:35:26 +0000 Subject: [PATCH] Updated. --- plugins/Parter.py | 31 ++++++++++++++----------------- test/test_Parter.py | 2 +- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/plugins/Parter.py b/plugins/Parter.py index 130366954..2064af773 100644 --- a/plugins/Parter.py +++ b/plugins/Parter.py @@ -36,13 +36,14 @@ bots. This module makes supybot automatically part certain channels as soon as he joins. """ -import plugins +import sets import conf import utils import ircdb import ircmsgs import ircutils +import plugins import privmsgs import callbacks @@ -78,34 +79,30 @@ example = utils.wrapLines(""" """) class Parter(callbacks.Privmsg): - def autopartchannel(self, irc, msg, args): + def __init__(self): + super(self.__class__, self).__init__() + self.channels = sets.Set([]) + + def autopart(self, irc, msg, args): """ Makes the bot part automatically, as soon as he joins it. """ channel = privmsgs.getArgs(args) - if ircdb.checkCapability(msg.prefix, 'admin'): - if not hasattr(self, 'channels'): - self.channels = [channel] - else: - self.channels.append(channel) - irc.reply(msg, conf.replySuccess) - else: - irc.error(msg, conf.replyNoCapability % 'admin') + self.channels.add(channel) + irc.reply(msg, conf.replySuccess) + autopart = privmsgs.checkCapability(autopart, 'admin') - def removeautopartchannel(self, irc, msg, args): + def removeautopart(self, irc, msg, args): """ Removes the channel from the auto-part list. """ channel = privmsgs.getArgs(args) - if ircdb.checkCapability(msg.prefix, 'admin'): - if hasattr(self, 'channels'): - self.channels = [x for x in self.channels if x != channel] - irc.reply(msg, conf.replySuccess) - else: - irc.error(msg, conf.replyNoCapability % 'admin') + self.channels.discard(channel) + irc.reply(msg, conf.replySuccess) + removeautopart = privmsgs.checkCapability(removeautopart, 'admin') def doJoin(self, irc, msg): if irc.nick == msg.nick: diff --git a/test/test_Parter.py b/test/test_Parter.py index 1500b523b..7e16d6251 100644 --- a/test/test_Parter.py +++ b/test/test_Parter.py @@ -36,7 +36,7 @@ import ircmsgs class ParterTestCase(PluginTestCase, PluginDocumentation): plugins = ('Parter',) def test(self): - self.assertNotError('autopartchannel #foo') + self.assertNotError('autopart #foo') self.irc.feedMsg(ircmsgs.join('#foo', prefix=self.prefix)) m = self.getMsg(' ') if m.command == 'WHO':