This commit is contained in:
Jeremy Fincher 2003-10-23 08:35:26 +00:00
parent 0ff6b8927c
commit 3944b00001
2 changed files with 15 additions and 18 deletions

View File

@ -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):
"""<channel>
Makes the bot part <channel> 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):
"""<channel>
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:

View File

@ -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':