From 78a79fdf3d3ae80d3d97397ef70ce9de6e61320f Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 18 Jan 2015 14:11:00 -0500 Subject: [PATCH] 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']. --- RelayNext/config.py | 5 ++++- RelayNext/plugin.py | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/RelayNext/config.py b/RelayNext/config.py index f781ec3..3c1680a 100644 --- a/RelayNext/config.py +++ b/RelayNext/config.py @@ -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: diff --git a/RelayNext/plugin.py b/RelayNext/plugin.py index 03a3036..5e66632 100644 --- a/RelayNext/plugin.py +++ b/RelayNext/plugin.py @@ -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()