Skip to content

Commit

Permalink
When only --account is provided, fallback to supybot.protocols.irc.ba…
Browse files Browse the repository at this point in the history
…nmask before exact mask
  • Loading branch information
progval committed Jul 19, 2024
1 parent cf63674 commit 54f7b5a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
24 changes: 22 additions & 2 deletions plugins/Channel/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,17 @@ def join():
'[email protected]')
join()
self.assertKban('kban --account foobar',
'[email protected]')
'*!*@host.domain.tld')
join()
with conf.supybot.protocols.irc.banmask.context(['user', 'host']):
# falls back from --account to config
self.assertKban('kban --account foobar',
'*[email protected]')
join()
with conf.supybot.protocols.irc.banmask.context(['account']):
# falls back from --account to config, then to exact hostmask
self.assertKban('kban --account foobar',
'[email protected]')
join()
self.assertKban('kban --account --host foobar',
'*!*@host.domain.tld')
Expand All @@ -259,7 +269,17 @@ def join():
'[email protected]')
join()
self.assertKban('kban --account foobar',
'[email protected]')
'*!*@host.domain.tld')
join()
with conf.supybot.protocols.irc.banmask.context(['user', 'host']):
# falls back from --account to config
self.assertKban('kban --account foobar',
'*[email protected]')
join()
with conf.supybot.protocols.irc.banmask.context(['account']):
# falls back from --account to config, then to exact hostmask
self.assertKban('kban --account foobar',
'[email protected]')
join()
self.assertKban('kban --account --host foobar',
'*!*@host.domain.tld')
Expand Down
11 changes: 11 additions & 0 deletions src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,17 @@ def makeExtBanmasks(self, hostmask, options=None, channel=None, *, network):
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:
Expand Down

0 comments on commit 54f7b5a

Please sign in to comment.