A little refactoring, a few more cases where we should ignore messages.

This commit is contained in:
Jeremy Fincher 2005-02-18 23:00:59 +00:00
parent 6756d4958c
commit 7ff9463f9b

View File

@ -70,17 +70,23 @@ class Protector(callbacks.Plugin):
irc.queueMsg(ircmsgs.deop(channel, nick)) irc.queueMsg(ircmsgs.deop(channel, nick))
def __call__(self, irc, msg): def __call__(self, irc, msg):
def ignore(reason):
self.log.debug('Ignoring %q, %s.', msg, reason)
if not msg.args: if not msg.args:
self.log.debug('Ignoring %q, no msg.args.', msg, irc) ignore('no msg.args')
elif not irc.isChannel(msg.args[0]): elif not irc.isChannel(msg.args[0]):
self.log.debug('Ignoring %q, not on a channel.', msg) ignore('not on a channel')
elif msg.args[0] not in irc.state.channels: elif msg.args[0] not in irc.state.channels:
# One has to wonder how this would happen, but just in case... # One has to wonder how this would happen, but just in case...
self.log.debug('Ignoring %q, bot isn\'t in channel.', msg) ignore('bot isn\'t in channel')
elif irc.nick not in irc.state.channels[msg.args[0]].ops: elif irc.nick not in irc.state.channels[msg.args[0]].ops:
self.log.debug('Ignoring %q, bot is not opped.', msg) ignore('bot is not opped')
elif msg.nick not in irc.state.channels[msg.args[0]].users:
ignore('sender is not in channel (ChanServ, maybe?)')
elif msg.nick not in irc.state.channels[msg.args[0]].ops:
ignore('sender is not an op in channel (IRCOP, maybe?)')
elif self.isImmune(irc, msg): elif self.isImmune(irc, msg):
self.log.debug('Ignoring %q, it is immune.', msg, irc) ignore('sender is immune')
else: else:
super(Protector, self).__call__(irc, msg) super(Protector, self).__call__(irc, msg)