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. as he joins.
""" """
import plugins import sets
import conf import conf
import utils import utils
import ircdb import ircdb
import ircmsgs import ircmsgs
import ircutils import ircutils
import plugins
import privmsgs import privmsgs
import callbacks import callbacks
@ -78,34 +79,30 @@ example = utils.wrapLines("""
""") """)
class Parter(callbacks.Privmsg): 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> """<channel>
Makes the bot part <channel> automatically, as soon as he joins it. Makes the bot part <channel> automatically, as soon as he joins it.
""" """
channel = privmsgs.getArgs(args) channel = privmsgs.getArgs(args)
if ircdb.checkCapability(msg.prefix, 'admin'): self.channels.add(channel)
if not hasattr(self, 'channels'):
self.channels = [channel]
else:
self.channels.append(channel)
irc.reply(msg, conf.replySuccess) irc.reply(msg, conf.replySuccess)
else: autopart = privmsgs.checkCapability(autopart, 'admin')
irc.error(msg, conf.replyNoCapability % 'admin')
def removeautopartchannel(self, irc, msg, args): def removeautopart(self, irc, msg, args):
"""<channel> """<channel>
Removes the channel from the auto-part list. Removes the channel from the auto-part list.
""" """
channel = privmsgs.getArgs(args) channel = privmsgs.getArgs(args)
if ircdb.checkCapability(msg.prefix, 'admin'): self.channels.discard(channel)
if hasattr(self, 'channels'):
self.channels = [x for x in self.channels if x != channel]
irc.reply(msg, conf.replySuccess) irc.reply(msg, conf.replySuccess)
else: removeautopart = privmsgs.checkCapability(removeautopart, 'admin')
irc.error(msg, conf.replyNoCapability % 'admin')
def doJoin(self, irc, msg): def doJoin(self, irc, msg):
if irc.nick == msg.nick: if irc.nick == msg.nick:

View File

@ -36,7 +36,7 @@ import ircmsgs
class ParterTestCase(PluginTestCase, PluginDocumentation): class ParterTestCase(PluginTestCase, PluginDocumentation):
plugins = ('Parter',) plugins = ('Parter',)
def test(self): def test(self):
self.assertNotError('autopartchannel #foo') self.assertNotError('autopart #foo')
self.irc.feedMsg(ircmsgs.join('#foo', prefix=self.prefix)) self.irc.feedMsg(ircmsgs.join('#foo', prefix=self.prefix))
m = self.getMsg(' ') m = self.getMsg(' ')
if m.command == 'WHO': if m.command == 'WHO':