mirror of
https://github.com/jlu5/PyLink.git
synced 2025-02-02 15:44:06 +01:00
Irc: implement exttarget inversion (#170)
This commit is contained in:
parent
ae2eefc73e
commit
50d30d4e20
@ -925,9 +925,12 @@ class Irc():
|
||||
|
||||
# Prepare a list of hosts to check against.
|
||||
if target in self.users:
|
||||
if glob.startswith('$'):
|
||||
if glob.startswith(('$', '!$')):
|
||||
# !$exttarget inverts the given match.
|
||||
invert = glob.startswith('!$')
|
||||
|
||||
# Exttargets start with $. Skip regular ban matching and find the matching ban handler.
|
||||
glob = glob.lstrip('$')
|
||||
glob = glob.lstrip('$!')
|
||||
exttargetname = glob.split(':', 1)[0]
|
||||
handler = world.exttarget_handlers.get(exttargetname)
|
||||
|
||||
@ -936,6 +939,8 @@ class Irc():
|
||||
result = handler(self, glob, target)
|
||||
log.debug('(%s) Got %s from exttarget %s in matchHost() glob $%s for target %s',
|
||||
self.name, result, exttargetname, glob, target)
|
||||
if invert: # Anti-exttarget was specified.
|
||||
result = not result
|
||||
return result
|
||||
else:
|
||||
log.debug('(%s) Unknown exttarget %s in matchHost() glob $%s', self.name,
|
||||
|
Loading…
Reference in New Issue
Block a user