user is null when we're sending a message non-echo-mesasge (line_handler.py)

This commit is contained in:
jesopo 2019-02-12 17:04:55 +00:00
parent e573f9de51
commit 44df8240cc

View file

@ -442,7 +442,6 @@ class Module(ModuleManager.BaseModule):
from_self = False from_self = False
user = None user = None
user_nickname = None
if "prefix" in event: if "prefix" in event:
user = event["server"].get_user(event["prefix"].nickname) user = event["server"].get_user(event["prefix"].nickname)
@ -484,19 +483,24 @@ class Module(ModuleManager.BaseModule):
context = "channel" if channel else "private" context = "channel" if channel else "private"
hook = self.events.on(direction).on(event_type).on(context) 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: if channel:
hook.call(user=user, channel=channel, statusmsg=statusmsg, **kwargs) 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) event["tags"], user==None)
elif event["server"].is_own_nickname(target): elif event["server"].is_own_nickname(target):
hook.call(user=user, **kwargs) hook.call(user=user, **kwargs)
user.buffer.add_message(user.nickname, message, action, user.buffer.add_message(user_nickname, message, action,
event["tags"], False) event["tags"], False)
elif not "prefix" in event: elif not "prefix" in event:
# a message we've sent to a user # a message we've sent to a user
user = event["server"].get_user(target) user = event["server"].get_user(target)
hook.call(user=user, **kwargs) 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 # we've received/sent a notice
@utils.hook("raw.received.notice") @utils.hook("raw.received.notice")