From f6a9f0729a979604e1a7d7a99ae9ed30a2f3e37a Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 1 May 2016 14:38:51 -0700 Subject: [PATCH] relay: don't error if the privmsg source on a remote network is missing This can happen when someone speaks while a network is initializing, for example. --- plugins/relay.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/plugins/relay.py b/plugins/relay.py index df4508f..911a37e 100644 --- a/plugins/relay.py +++ b/plugins/relay.py @@ -918,19 +918,20 @@ def handle_messages(irc, numeric, command, args): real_target = getRemoteChan(irc, remoteirc, target) # Don't relay anything back to the source net, or to disconnected networks - # and networks without a relay for this channel + # and networks without a relay for this channel. if irc.name == name or (not remoteirc.connected.is_set()) or (not real_target) \ or (not irc.connected.is_set()): continue user = getRemoteUser(irc, remoteirc, numeric, spawnIfMissing=False) - real_target = prefix + real_target - log.debug('(%s) relay.handle_messages: sending message to %s from %s on behalf of %s', - irc.name, real_target, user, numeric) - if notice: - remoteirc.proto.notice(user, real_target, text) - else: - remoteirc.proto.message(user, real_target, text) + if user: # If the user doesn't exist, drop the message. + real_target = prefix + real_target + log.debug('(%s) relay.handle_messages: sending message to %s from %s on behalf of %s', + irc.name, real_target, user, numeric) + if notice: + remoteirc.proto.notice(user, real_target, text) + else: + remoteirc.proto.message(user, real_target, text) else: # Get the real user that the PM was meant for