diff --git a/plugins/Relay/config.py b/plugins/Relay/config.py index de0f22f70..ad1ea15d2 100644 --- a/plugins/Relay/config.py +++ b/plugins/Relay/config.py @@ -44,6 +44,10 @@ def configure(advanced): use the 'start' command followed by the 'connect' command. Use the 'help' command to see how these two commands should be used.""") +class Ignores(registry.SpaceSeparatedListOf): + List = ircutils.IrcSet + Value = conf.ValidHostmask + class Networks(registry.SpaceSeparatedListOf): List = ircutils.IrcSet Value = registry.String @@ -69,10 +73,13 @@ conf.registerChannelValue(Relay, 'punishOtherRelayBots', conf.registerGlobalValue(Relay, 'channels', conf.SpaceSeparatedSetOfChannels([], """Determines which channels the bot will relay in.""")) -conf.registerChannelValue(Relay.channels, - 'joinOnAllNetworks', registry.Boolean(True, """Determines whether the bot +conf.registerChannelValue(Relay.channels, 'joinOnAllNetworks', + registry.Boolean(True, """Determines whether the bot will always join the channel(s) it relays for on all networks the bot is connected to.""")) +conf.registerChannelValue(Relay, 'ignores', + Ignores([], """Determines what hostmasks will not be relayed on a + channel.""")) conf.registerChannelValue(Relay, 'noticeNonPrivmsgs', registry.Boolean(False, """Determines whether the bot will used NOTICEs rather than PRIVMSGs for non-PRIVMSG relay messages (i.e., joins, parts, diff --git a/plugins/Relay/plugin.py b/plugins/Relay/plugin.py index 3e83c4009..ff296e6ea 100644 --- a/plugins/Relay/plugin.py +++ b/plugins/Relay/plugin.py @@ -344,6 +344,12 @@ class Relay(callbacks.Privmsg): irc = self._getRealIrc(irc) if channel not in self.registryValue('channels'): return + ignores = self.registryValue('ignores', channel) + for ignore in ignores: + if ircutils.hostmaskPatternEqual(ignore, msg.prefix): + self.log.debug('Refusing to relay %s, ignored by %s.', + msg.prefix, ignore) + return if ircmsgs.isCtcp(msg) and \ 'AWAY' not in text and 'ACTION' not in text: return diff --git a/src/conf.py b/src/conf.py index 3d2b2ac9e..d856f14ce 100644 --- a/src/conf.py +++ b/src/conf.py @@ -176,6 +176,13 @@ class ValidChannel(registry.String): else: registry.String.setValue(self, v) +class ValidHostmask(registry.String): + """Value must be a valid user hostmask.""" + def setValue(self, v): + if not ircutils.isUserHostmask(v): + self.error() + super(ValidHostmask, self).setValue(v) + registerGlobalValue(supybot, 'nick', ValidNick('supybot', """Determines the bot's default nick."""))