More ignorance can never hurt.

Added supybot.plugins.Relay.ignores, a channel configuration variable that allows people to specify hostmasks that are ignored.
This commit is contained in:
Jeremy Fincher 2005-02-09 00:39:11 +00:00
parent 203491e7c3
commit 3a7202bfbe
3 changed files with 22 additions and 2 deletions

View File

@ -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,

View File

@ -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

View File

@ -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."""))