Check if a PRIVMSG/NOTICE is send *from* us before we check if it's sent *to* us

- so `user` isn't null when bitbot messages himself.
This commit is contained in:
jesopo 2019-05-22 14:23:38 +01:00
parent e82a05dd37
commit e3d8063373

View file

@ -68,16 +68,16 @@ def privmsg(events, event):
hook.call(user=user, channel=channel, **kwargs) hook.call(user=user, channel=channel, **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):
hook.call(user=user, **kwargs)
user.buffer.add_message(user_nickname, message, action,
event["tags"], False)
elif from_self: elif from_self:
# 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(user_nickname, message, action, user.buffer.add_message(user_nickname, message, action,
event["tags"], True) event["tags"], True)
elif event["server"].is_own_nickname(target):
hook.call(user=user, **kwargs)
user.buffer.add_message(user_nickname, message, action,
event["tags"], False)
def notice(events, event): def notice(events, event):
from_self = _from_self(event["server"], event["direction"], from_self = _from_self(event["server"], event["direction"],
@ -122,16 +122,16 @@ def notice(events, event):
hook.call(user=user, channel=channel, **kwargs) hook.call(user=user, channel=channel, **kwargs)
channel.buffer.add_notice(user_nickname, message, event["tags"], channel.buffer.add_notice(user_nickname, message, event["tags"],
user==None) user==None)
elif event["server"].is_own_nickname(target):
hook.call(user=user, **kwargs)
user.buffer.add_notice(user_nickname, message, event["tags"],
False)
elif from_self: elif from_self:
# a notice we've sent to a user # a notice 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_notice(user_nickname, message, event["tags"], user.buffer.add_notice(user_nickname, message, event["tags"],
True) True)
elif event["server"].is_own_nickname(target):
hook.call(user=user, **kwargs)
user.buffer.add_notice(user_nickname, message, event["tags"],
False)
def tagmsg(events, event): def tagmsg(events, event):
from_self = _from_self(event["server"], event["direction"], from_self = _from_self(event["server"], event["direction"],