diff --git a/plugins/Channel/test.py b/plugins/Channel/test.py index 7fd0c0b85..aa11982eb 100644 --- a/plugins/Channel/test.py +++ b/plugins/Channel/test.py @@ -237,7 +237,17 @@ class ChannelTestCase(ChannelPluginTestCase): 'foobar!user@host.domain.tld') join() self.assertKban('kban --account foobar', - 'foobar!user@host.domain.tld') + '*!*@host.domain.tld') + join() + with conf.supybot.protocols.irc.banmask.context(['user', 'host']): + # falls back from --account to config + self.assertKban('kban --account foobar', + '*!user@host.domain.tld') + join() + with conf.supybot.protocols.irc.banmask.context(['account']): + # falls back from --account to config, then to exact hostmask + self.assertKban('kban --account foobar', + 'foobar!user@host.domain.tld') join() self.assertKban('kban --account --host foobar', '*!*@host.domain.tld') @@ -259,7 +269,17 @@ class ChannelTestCase(ChannelPluginTestCase): 'foobar!user@host.domain.tld') join() self.assertKban('kban --account foobar', - 'foobar!user@host.domain.tld') + '*!*@host.domain.tld') + join() + with conf.supybot.protocols.irc.banmask.context(['user', 'host']): + # falls back from --account to config + self.assertKban('kban --account foobar', + '*!user@host.domain.tld') + join() + with conf.supybot.protocols.irc.banmask.context(['account']): + # falls back from --account to config, then to exact hostmask + self.assertKban('kban --account foobar', + 'foobar!user@host.domain.tld') join() self.assertKban('kban --account --host foobar', '*!*@host.domain.tld') diff --git a/src/conf.py b/src/conf.py index 9ba866119..ed5c7d4d8 100644 --- a/src/conf.py +++ b/src/conf.py @@ -1302,6 +1302,17 @@ class Banmask(registry.SpaceSeparatedSetOfStrings): if add_star_mask and (bnick, buser, bhost) != ('*', '*', '*'): masks.append(ircutils.joinHostmask(bnick, buser, bhost)) + if (bnick, buser, bhost) == ('*', '*', '*') and \ + options == ['account'] and \ + not masks: + # found no ban mask to set (because options == ['account'] and user + # is logged out?), try again with the default ban mask + options = supybot.protocols.irc.banmask.getSpecific( + network, channel)() + options = [option for option in options if option != 'account'] + return self.makeExtBanmasks( + hostmask, options=options, channel=channel, network=network) + if (bnick, buser, bhost) == ('*', '*', '*') and \ ircutils.isUserHostmask(hostmask) and \ not masks: