3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 11:39:25 +01:00

relay: add hooks for CHGHOST / CHGIDENT / CHGNAME

Closes #49.
This commit is contained in:
James Lu 2015-07-16 11:53:40 -07:00
parent f9d82153bb
commit 35f1c88a4e

View File

@ -321,6 +321,29 @@ def handle_kick(irc, source, command, args):
remotechan, real_target, args['text']) remotechan, real_target, args['text'])
utils.add_hook(handle_kick, 'KICK') utils.add_hook(handle_kick, 'KICK')
def handle_chgclient(irc, source, command, args):
target = args['target']
if args.get('newhost'):
field = 'HOST'
text = args['newhost']
elif args.get('newident'):
field = 'IDENT'
text = args['newident']
elif args.get('newgecos'):
field = 'GECOS'
text = args['newgecos']
if field:
for netname, user in relayusers[(irc.name, target)].items():
remoteirc = utils.networkobjects[netname]
try:
remoteirc.proto.updateClient(remoteirc, user, field, text)
except ValueError: # IRCd doesn't support changing the field we want
logging.debug('(%s) Error raised changing field %r of %s on %s (for %s/%s)', irc.name, field, user, target, remotenet, irc.name)
continue
for c in ('CHGHOST', 'CHGNAME', 'CHGIDENT'):
utils.add_hook(handle_chgclient, c)
def relayModes(irc, remoteirc, sender, channel, modes=None): def relayModes(irc, remoteirc, sender, channel, modes=None):
remotechan = findRemoteChan(irc, remoteirc, channel) remotechan = findRemoteChan(irc, remoteirc, channel)
log.debug('(%s) Relay mode: remotechan for %s on %s is %s', irc.name, channel, irc.name, remotechan) log.debug('(%s) Relay mode: remotechan for %s on %s is %s', irc.name, channel, irc.name, remotechan)