Allow Banmask.makeBanmask to work when dynamic.channel is None.

This gives back the ability to generate a banmask based on the global banmask
settings instead of per-channel settings.

Signed-off-by: James Vega <jamessan@users.sourceforge.net>
This commit is contained in:
James Vega 2009-11-01 10:26:08 -05:00
parent acaa9b1fd6
commit 8a98653d3b
2 changed files with 4 additions and 10 deletions

View File

@ -280,10 +280,7 @@ def getBanmask(irc, msg, args, state):
getChannel(irc, msg, args, state)
channel = state.channel
banmaskstyle = conf.supybot.protocols.irc.banmask
try:
state.args[-1] = banmaskstyle.makeBanmask(state.args[-1])
except AssertionError:
state.errorInvalid('channel', channel)
state.args[-1] = banmaskstyle.makeBanmask(state.args[-1])
def getUser(irc, msg, args, state):
try:

View File

@ -929,20 +929,17 @@ class Banmask(registry.SpaceSeparatedSetOfStrings):
isn't specified via options, the value of
conf.supybot.protocols.irc.banmask is used.
A variable named 'channel' (defining the channel the ban is taking
place in) is expected to be in the environment of the caller of this
function.
options - A list specifying which parts of the hostmask should
explicitly be matched: nick, user, host. If 'exact' is given, then
only the exact hostmask will be used."""
assert ircutils.isChannel(dynamic.channel)
channel = dynamic.channel
assert channel is None or ircutils.isChannel(channel)
(nick, user, host) = ircutils.splitHostmask(hostmask)
bnick = '*'
buser = '*'
bhost = '*'
if not options:
options = get(supybot.protocols.irc.banmask, dynamic.channel)
options = get(supybot.protocols.irc.banmask, channel)
for option in options:
if option == 'nick':
bnick = nick