From c3f39fc93be647140de2f3e28ee1ce2c73114917 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Wed, 26 May 2021 17:50:11 +0200 Subject: [PATCH] callbacks, Misc, Relay: Fix when the message prefix is just a nick and are optional in https://datatracker.ietf.org/doc/html/rfc1459#section-2.3.1 Closes GH-1451. --- plugins/Misc/plugin.py | 5 ++++- plugins/Relay/plugin.py | 4 ++-- src/callbacks.py | 5 +++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/Misc/plugin.py b/plugins/Misc/plugin.py index 7b934396d..e4e9395ae 100644 --- a/plugins/Misc/plugin.py +++ b/plugins/Misc/plugin.py @@ -381,7 +381,10 @@ class Misc(callbacks.Plugin): If is given, it takes the continuation of the last command from instead of the person sending this message. """ - userHostmask = msg.prefix.split('!', 1)[1] + if '!' in msg.prefix and '@' in msg.prefix: + userHostmask = msg.prefix.split('!', 1)[1] + else: + userHostmask = msg.nick if nick: try: (private, L) = irc._mores[nick] diff --git a/plugins/Relay/plugin.py b/plugins/Relay/plugin.py index 1a2b184ba..1b533783d 100644 --- a/plugins/Relay/plugin.py +++ b/plugins/Relay/plugin.py @@ -341,7 +341,7 @@ class Relay(callbacks.Plugin): if channel not in self.registryValue('channels'): return network = self._getIrcName(irc) - if self.registryValue('hostmasks', channel): + if self.registryValue('hostmasks', channel) and '!' in msg.prefix: hostmask = format(' (%s)', msg.prefix.split('!')[1]) else: hostmask = '' @@ -355,7 +355,7 @@ class Relay(callbacks.Plugin): if channel not in self.registryValue('channels'): return network = self._getIrcName(irc) - if self.registryValue('hostmasks', channel): + if self.registryValue('hostmasks', channel) and '!' in msg.prefix: hostmask = format(' (%s)', msg.prefix.split('!')[1]) else: hostmask = '' diff --git a/src/callbacks.py b/src/callbacks.py index 8942b0997..436029a25 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -883,8 +883,9 @@ class ReplyIrcProxy(RichReplyMethods): prefix = state.nickToHostmask(target) except KeyError: pass # We'll leave it as it is. - mask = prefix.split('!', 1)[1] - self._mores[mask] = msgs + if '!' in prefix and '@' in prefix: + mask = prefix.split('!', 1)[1] + self._mores[mask] = msgs public = bool(self.msg.channel) private = kwargs.get('private', False) or not public self._mores[msg.nick] = (private, msgs)