From d010ca5c7989a19bb6240bc40b3e77b788e13dca Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 27 Nov 2018 12:14:03 +0000 Subject: [PATCH] Use WHO/WHOX to also keep track of our own username/hostname --- modules/line_handler.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/modules/line_handler.py b/modules/line_handler.py index 00f424f2..58dd53ac 100644 --- a/modules/line_handler.py +++ b/modules/line_handler.py @@ -557,25 +557,35 @@ class Module(ModuleManager.BaseModule): # response to a WHO command for user information @utils.hook("raw.received.352", default_event=True) def handle_352(self, event): - user = event["server"].get_user(event["args"][5]) - user.username = event["args"][2] - user.hostname = event["args"][3] + nickname = event["args"][5] + if not event["server"].is_own_nickname(nickname): + target = event["server"].get_user(nickname) + else: + target = event["server"] + target.username = event["args"][2] + target.hostname = event["args"][3] + # response to a WHOX command for user information, including account name @utils.hook("raw.received.354", default_event=True) def handle_354(self, event): if event["args"][1] == "111": - username = event["args"][2] - hostname = event["args"][3] nickname = event["args"][4] - account = event["args"][5] - realname = event["args"][6] - user = event["server"].get_user(nickname) - user.username = username - user.hostname = hostname - user.realname = realname - if not account == "0": - user.identified_account = account + if not event["server"].is_own_nickname(nickname): + target = event["server"].get_user(nickname) + + account = event["args"][5] + if not account == "0": + target.identified_account = account + else: + target.identified_account = None + else: + target = event["server"] + + target.username = event["args"][2] + target.hostname = event["args"][3] + target.realname = event["args"][6] + # response to an empty mode command @utils.hook("raw.received.324", default_event=True)