3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-23 19:19:31 +01:00

changehost: simplify _changehost() syntax

This commit is contained in:
James Lu 2019-10-09 20:30:38 -07:00
parent 8cf1beb183
commit 4095eea3a7

View File

@ -10,7 +10,7 @@ from pylinkirc.log import log
# Characters allowed in a hostname.
allowed_chars = string.ascii_letters + '-./:' + string.digits
def _changehost(irc, target, args):
def _changehost(irc, target):
changehost_conf = conf.conf.get("changehost")
if target not in irc.users:
@ -36,7 +36,7 @@ def _changehost(irc, target, args):
"Changehost will not function correctly!", irc.name)
return
args = args.copy()
args = irc.users[target].get_fields()
# $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
@ -84,8 +84,7 @@ def handle_uid(irc, sender, command, args):
"""
target = args['uid']
_changehost(irc, target, args)
_changehost(irc, target)
utils.add_hook(handle_uid, 'UID')
def handle_chghost(irc, sender, command, args):
@ -111,8 +110,7 @@ def handle_chghost(irc, sender, command, args):
userobj = irc.users.get(target)
if userobj:
_changehost(irc, target, userobj.get_fields())
_changehost(irc, target)
utils.add_hook(handle_chghost, 'CHGHOST')
@utils.add_cmd
@ -131,7 +129,7 @@ def applyhosts(irc, sender, args):
irc.error("Unknown network '%s'." % network)
return
for user, userdata in network.users.copy().items():
_changehost(network, user, userdata.__dict__)
for user in network.users.copy():
_changehost(network, user)
irc.reply("Done.")