RelayNext: add ignore feature

This uses Supybot's built in ignore system, but allows configuring
which events to drop from ignored users. It defaults to
['PRIVMSG', 'MODE'].
This commit is contained in:
James Lu 2015-01-18 14:11:00 -05:00
parent 3c5cc19ba7
commit 78a79fdf3d
2 changed files with 10 additions and 1 deletions

View File

@ -81,5 +81,8 @@ _events = ('quit', 'join', 'part', 'nick', 'mode', 'kick')
for ev in _events:
conf.registerChannelValue(RelayNext.events, 'relay%ss' % ev,
registry.Boolean(True, """Determines whether the bot should relay %ss.""" % ev))
conf.registerChannelValue(RelayNext.events, 'userIgnored',
registry.SpaceSeparatedListOfStrings(['PRIVMSG', 'MODE'], ("""Determines what events
the relay should ignore from ignored users. Ignores are added using
Supybot's global ignore system.""")))
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:

View File

@ -36,6 +36,7 @@ import traceback
import supybot.world as world
import supybot.irclib as irclib
import supybot.ircmsgs as ircmsgs
import supybot.ircdb as ircdb
import supybot.conf as conf
import supybot.utils as utils
from supybot.commands import *
@ -216,6 +217,11 @@ class RelayNext(callbacks.Plugin):
def relay(self, irc, msg, channel=None):
channel = channel or msg.args[0]
ignoredevents = map(str.upper, self.registryValue('events.userIgnored'))
if msg.command in ignoredevents and ircdb.checkIgnored(msg.prefix):
self.log.debug("RelayNext (%s): ignoring message from %s",
irc.network, msg.prefix)
return
# Get the source channel
source = "%s@%s" % (channel, irc.network)
source = source.lower()