mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-17 23:52:49 +01:00
changehost: simplify _changehost() syntax
This commit is contained in:
parent
8cf1beb183
commit
4095eea3a7
@ -10,7 +10,7 @@ from pylinkirc.log import log
|
|||||||
# Characters allowed in a hostname.
|
# Characters allowed in a hostname.
|
||||||
allowed_chars = string.ascii_letters + '-./:' + string.digits
|
allowed_chars = string.ascii_letters + '-./:' + string.digits
|
||||||
|
|
||||||
def _changehost(irc, target, args):
|
def _changehost(irc, target):
|
||||||
changehost_conf = conf.conf.get("changehost")
|
changehost_conf = conf.conf.get("changehost")
|
||||||
|
|
||||||
if target not in irc.users:
|
if target not in irc.users:
|
||||||
@ -36,7 +36,7 @@ def _changehost(irc, target, args):
|
|||||||
"Changehost will not function correctly!", irc.name)
|
"Changehost will not function correctly!", irc.name)
|
||||||
return
|
return
|
||||||
|
|
||||||
args = args.copy()
|
args = irc.users[target].get_fields()
|
||||||
|
|
||||||
# $host is explicitly forbidden by default because it can cause recursive
|
# $host is explicitly forbidden by default because it can cause recursive
|
||||||
# loops when IP or real host masks are used to match a target. vHost
|
# loops when IP or real host masks are used to match a target. vHost
|
||||||
@ -84,8 +84,7 @@ def handle_uid(irc, sender, command, args):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
target = args['uid']
|
target = args['uid']
|
||||||
_changehost(irc, target, args)
|
_changehost(irc, target)
|
||||||
|
|
||||||
utils.add_hook(handle_uid, 'UID')
|
utils.add_hook(handle_uid, 'UID')
|
||||||
|
|
||||||
def handle_chghost(irc, sender, command, args):
|
def handle_chghost(irc, sender, command, args):
|
||||||
@ -111,8 +110,7 @@ def handle_chghost(irc, sender, command, args):
|
|||||||
|
|
||||||
userobj = irc.users.get(target)
|
userobj = irc.users.get(target)
|
||||||
if userobj:
|
if userobj:
|
||||||
_changehost(irc, target, userobj.get_fields())
|
_changehost(irc, target)
|
||||||
|
|
||||||
utils.add_hook(handle_chghost, 'CHGHOST')
|
utils.add_hook(handle_chghost, 'CHGHOST')
|
||||||
|
|
||||||
@utils.add_cmd
|
@utils.add_cmd
|
||||||
@ -131,7 +129,7 @@ def applyhosts(irc, sender, args):
|
|||||||
irc.error("Unknown network '%s'." % network)
|
irc.error("Unknown network '%s'." % network)
|
||||||
return
|
return
|
||||||
|
|
||||||
for user, userdata in network.users.copy().items():
|
for user in network.users.copy():
|
||||||
_changehost(network, user, userdata.__dict__)
|
_changehost(network, user)
|
||||||
|
|
||||||
irc.reply("Done.")
|
irc.reply("Done.")
|
||||||
|
Loading…
Reference in New Issue
Block a user