mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-11 20:52:42 +01:00
exttargets: add a $network target (#334)
This commit is contained in:
parent
e69e1f5f03
commit
dbeacf9249
@ -144,3 +144,25 @@ def pylinkacc(irc, host, uid):
|
||||
elif len(groups) == 2:
|
||||
# Second scenario. Return True if the user's login matches the one given.
|
||||
return login == groups[1]
|
||||
|
||||
@bind
|
||||
def network(irc, host, uid):
|
||||
"""
|
||||
$network exttarget handler. This exttarget takes one argument: a network name, and returns
|
||||
a match for all users on that network.
|
||||
|
||||
Note: network names are case sensitive.
|
||||
"""
|
||||
try:
|
||||
targetnet = host.split(':')[1]
|
||||
except IndexError: # No network arg given, bail.
|
||||
return False
|
||||
|
||||
userobj = irc.users[uid]
|
||||
if hasattr(userobj, 'remote'):
|
||||
# User is a PyLink Relay client; set the correct network name.
|
||||
homenet = userobj.remote[0]
|
||||
else:
|
||||
homenet = irc.name
|
||||
|
||||
return homenet == targetnet
|
||||
|
@ -42,6 +42,7 @@ Extended targets or exttargets *replace* regular hostmasks with conditional matc
|
||||
- `$channel:#channel:op` -> Returns True if the target is in the given channel, and is opped. Any supported prefix mode (owner, admin, op, halfop, voice) can be used for the last part, but only one at a time.
|
||||
- `$pylinkacc` -> Returns True if the target is logged in to PyLink.
|
||||
- `$pylinkacc:accountname` -> Returns True if the target's PyLink login matches the one given (case insensitive).
|
||||
- `$network:netname` -> Returns True if the target user originates from the given network (this supports and looks up the home network of Relay users).
|
||||
|
||||
## Permissions
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user