mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 14:59:34 +01:00
More bugz0rs fixed.
This commit is contained in:
parent
8aa74dee4b
commit
731c9f0bdb
@ -31,7 +31,9 @@
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
Enforcer: Enforces capabilities on a channel, watching MODEs, KICKs,
|
Enforcer: Enforces capabilities on a channel, watching MODEs, KICKs,
|
||||||
JOINs, etc. to make sure they match the channel's config.
|
JOINs, etc. to make sure they match the channel's config. Also handles
|
||||||
|
auto-opping, auto-halfopping, or auto-voicing, as well as cycling an otherwise
|
||||||
|
empty channel in order to get ops.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
@ -50,12 +52,14 @@ import callbacks
|
|||||||
def configure(advanced):
|
def configure(advanced):
|
||||||
from questions import expect, anything, something, yn
|
from questions import expect, anything, something, yn
|
||||||
conf.registerPlugin('Enforcer', True)
|
conf.registerPlugin('Enforcer', True)
|
||||||
chanserv = something('What\'s the name of ChanServ on your network?')
|
chanserv = anything("""What\'s the name of ChanServ on your network? If
|
||||||
if yn('Do you want the bot to take revenge on rule breakers?') == 'y':
|
there is no ChanServ on your network, just press enter without entering
|
||||||
|
anything.""")
|
||||||
|
if yn('Do you want the bot to take revenge on rule breakers?'):
|
||||||
revenge = True
|
revenge = True
|
||||||
else:
|
else:
|
||||||
revenge = False
|
revenge = False
|
||||||
onStart.append('enforcer start %s' % chanserv)
|
conf.supybot.plugins.Enforcer.ChanServ.set(chanserv)
|
||||||
conf.supybot.plugins.Enforcer.takeRevenge.setValue(revenge)
|
conf.supybot.plugins.Enforcer.takeRevenge.setValue(revenge)
|
||||||
|
|
||||||
class ValidNickOrEmptyString(registry.String):
|
class ValidNickOrEmptyString(registry.String):
|
||||||
@ -93,6 +97,10 @@ conf.registerChannelValue(conf.supybot.plugins.Enforcer, 'ChanServ',
|
|||||||
|
|
||||||
_chanCap = ircdb.makeChannelCapability
|
_chanCap = ircdb.makeChannelCapability
|
||||||
class Enforcer(callbacks.Privmsg):
|
class Enforcer(callbacks.Privmsg):
|
||||||
|
def __init__(self):
|
||||||
|
callbacks.Privmsg.__init__(self)
|
||||||
|
self.topics = ircutils.IrcDict()
|
||||||
|
|
||||||
def doJoin(self, irc, msg):
|
def doJoin(self, irc, msg):
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
c = ircdb.channels.getChannel(channel)
|
c = ircdb.channels.getChannel(channel)
|
||||||
@ -112,7 +120,7 @@ class Enforcer(callbacks.Privmsg):
|
|||||||
def doTopic(self, irc, msg):
|
def doTopic(self, irc, msg):
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
topic = msg.args[1]
|
topic = msg.args[1]
|
||||||
if msg.nick != irc.nick and \
|
if msg.nick != irc.nick and channel in self.topics and \
|
||||||
not ircdb.checkCapabilities(msg.prefix,
|
not ircdb.checkCapabilities(msg.prefix,
|
||||||
(_chanCap(channel, 'op'),
|
(_chanCap(channel, 'op'),
|
||||||
_chanCap(channel, 'topic'))):
|
_chanCap(channel, 'topic'))):
|
||||||
@ -161,7 +169,9 @@ class Enforcer(callbacks.Privmsg):
|
|||||||
|
|
||||||
def doMode(self, irc, msg):
|
def doMode(self, irc, msg):
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
if not ircutils.isChannel(channel) or msg.nick == self.chanserv:
|
chanserv = self.registryValue('ChanServ', channel)
|
||||||
|
if not ircutils.isChannel(channel) or \
|
||||||
|
(chanserv and msg.nick == chanserv):
|
||||||
return
|
return
|
||||||
if msg.nick != irc.nick and \
|
if msg.nick != irc.nick and \
|
||||||
not ircdb.checkCapability(msg.prefix, _chanCap(channel, 'op')):
|
not ircdb.checkCapability(msg.prefix, _chanCap(channel, 'op')):
|
||||||
@ -228,6 +238,7 @@ class Enforcer(callbacks.Privmsg):
|
|||||||
self.log.warning('Not cycling %s: it\'s +i', channel)
|
self.log.warning('Not cycling %s: it\'s +i', channel)
|
||||||
|
|
||||||
def doPart(self, irc, msg):
|
def doPart(self, irc, msg):
|
||||||
|
if msg.prefix != irc.prefix:
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
if len(irc.state.channels[channel].users) == 1:
|
if len(irc.state.channels[channel].users) == 1:
|
||||||
self._cycle(irc, channel)
|
self._cycle(irc, channel)
|
||||||
@ -239,9 +250,12 @@ class Enforcer(callbacks.Privmsg):
|
|||||||
|
|
||||||
def __call__(self, irc, msg):
|
def __call__(self, irc, msg):
|
||||||
chanserv = self.registryValue('ChanServ', irc.network)
|
chanserv = self.registryValue('ChanServ', irc.network)
|
||||||
if chanserv and ircutils.isUserHostmask(msg.prefix):
|
if chanserv:
|
||||||
|
if ircutils.isUserHostmask(msg.prefix):
|
||||||
if msg.nick != chanserv:
|
if msg.nick != chanserv:
|
||||||
callbacks.Privmsg.__call__(self, irc, msg)
|
callbacks.Privmsg.__call__(self, irc, msg)
|
||||||
|
else:
|
||||||
|
callbacks.Privmsg.__call__(self, irc, msg)
|
||||||
|
|
||||||
|
|
||||||
Class = Enforcer
|
Class = Enforcer
|
||||||
|
Loading…
Reference in New Issue
Block a user