mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-30 14:49:28 +01:00
clientbot: only send updateClient() hooks if something changes
Closes #323.
This commit is contained in:
parent
9b38ca7d68
commit
cf5898fb45
@ -252,25 +252,28 @@ class ClientbotWrapperProtocol(Protocol):
|
|||||||
|
|
||||||
def updateClient(self, target, field, text):
|
def updateClient(self, target, field, text):
|
||||||
"""Updates the known ident, host, or realname of a client."""
|
"""Updates the known ident, host, or realname of a client."""
|
||||||
if field == 'IDENT':
|
assert target in self.irc.users, "Unknown target %s" % target
|
||||||
self.irc.users[target].ident = text
|
u = self.irc.users[target]
|
||||||
|
|
||||||
|
if field == 'IDENT' and u.ident != text:
|
||||||
|
u.ident = text
|
||||||
if not self.irc.isInternalClient(target):
|
if not self.irc.isInternalClient(target):
|
||||||
# We're updating the host of an external client in our state, so send the appropriate
|
# We're updating the host of an external client in our state, so send the appropriate
|
||||||
# hook payloads.
|
# hook payloads.
|
||||||
self.irc.callHooks([self.irc.sid, 'CHGIDENT',
|
self.irc.callHooks([self.irc.sid, 'CHGIDENT',
|
||||||
{'target': target, 'newident': text}])
|
{'target': target, 'newident': text}])
|
||||||
elif field == 'HOST':
|
elif field == 'HOST' and u.host != text:
|
||||||
self.irc.users[target].host = text
|
u.host = text
|
||||||
if not self.irc.isInternalClient(target):
|
if not self.irc.isInternalClient(target):
|
||||||
self.irc.callHooks([self.irc.sid, 'CHGHOST',
|
self.irc.callHooks([self.irc.sid, 'CHGHOST',
|
||||||
{'target': target, 'newhost': text}])
|
{'target': target, 'newhost': text}])
|
||||||
elif field in ('REALNAME', 'GECOS'):
|
elif field in ('REALNAME', 'GECOS') and u.realname != text:
|
||||||
self.irc.users[target].realname = text
|
u.realname = text
|
||||||
if not self.irc.isInternalClient(target):
|
if not self.irc.isInternalClient(target):
|
||||||
self.irc.callHooks([self.irc.sid, 'CHGNAME',
|
self.irc.callHooks([self.irc.sid, 'CHGNAME',
|
||||||
{'target': target, 'newgecos': text}])
|
{'target': target, 'newgecos': text}])
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
return # Nothing changed
|
||||||
|
|
||||||
def handle_events(self, data):
|
def handle_events(self, data):
|
||||||
"""Event handler for the RFC1459/2812 (clientbot) protocol."""
|
"""Event handler for the RFC1459/2812 (clientbot) protocol."""
|
||||||
|
Loading…
Reference in New Issue
Block a user