From 44df8240cc38570e33a2b55e063574ea0df5ec36 Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 12 Feb 2019 17:04:55 +0000 Subject: [PATCH] `user` is null when we're sending a message non-echo-mesasge (line_handler.py) --- modules/line_handler.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/line_handler.py b/modules/line_handler.py index 76e9449d..351c786d 100644 --- a/modules/line_handler.py +++ b/modules/line_handler.py @@ -442,7 +442,6 @@ class Module(ModuleManager.BaseModule): from_self = False user = None - user_nickname = None if "prefix" in event: user = event["server"].get_user(event["prefix"].nickname) @@ -484,19 +483,24 @@ class Module(ModuleManager.BaseModule): context = "channel" if channel else "private" hook = self.events.on(direction).on(event_type).on(context) + user_nickname = None + if user: + user_nickname = None if from_self else user.nickname + if channel: hook.call(user=user, channel=channel, statusmsg=statusmsg, **kwargs) - channel.buffer.add_message(user.nickname, message, action, + channel.buffer.add_message(user_nickname, message, action, event["tags"], user==None) elif event["server"].is_own_nickname(target): hook.call(user=user, **kwargs) - user.buffer.add_message(user.nickname, message, action, + user.buffer.add_message(user_nickname, message, action, event["tags"], False) elif not "prefix" in event: # a message we've sent to a user user = event["server"].get_user(target) hook.call(user=user, **kwargs) - user.buffer.add_message(None, message, action, event["tags"], True) + user.buffer.add_message(user_nickname, message, action, + event["tags"], True) # we've received/sent a notice @utils.hook("raw.received.notice")