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>
(cherry picked from commit 8a98653d3b)
This commit is contained in:
James Vega 2009-11-01 10:26:08 -05:00
parent c53f8cd510
commit 9ddf07ce97
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) getChannel(irc, msg, args, state)
channel = state.channel channel = state.channel
banmaskstyle = conf.supybot.protocols.irc.banmask banmaskstyle = conf.supybot.protocols.irc.banmask
try: state.args[-1] = banmaskstyle.makeBanmask(state.args[-1])
state.args[-1] = banmaskstyle.makeBanmask(state.args[-1])
except AssertionError:
state.errorInvalid('channel', channel)
def getUser(irc, msg, args, state): def getUser(irc, msg, args, state):
try: try:

View File

@ -926,20 +926,17 @@ class Banmask(registry.SpaceSeparatedSetOfStrings):
isn't specified via options, the value of isn't specified via options, the value of
conf.supybot.protocols.irc.banmask is used. 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 options - A list specifying which parts of the hostmask should
explicitly be matched: nick, user, host. If 'exact' is given, then explicitly be matched: nick, user, host. If 'exact' is given, then
only the exact hostmask will be used.""" 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) (nick, user, host) = ircutils.splitHostmask(hostmask)
bnick = '*' bnick = '*'
buser = '*' buser = '*'
bhost = '*' bhost = '*'
if not options: if not options:
options = get(supybot.protocols.irc.banmask, dynamic.channel) options = get(supybot.protocols.irc.banmask, channel)
for option in options: for option in options:
if option == 'nick': if option == 'nick':
bnick = nick bnick = nick