callbacks, Misc, Relay: Fix when the message prefix is just a nick

<user> and <host> are optional in https://datatracker.ietf.org/doc/html/rfc1459#section-2.3.1

Closes GH-1451.
This commit is contained in:
Valentin Lorentz 2021-05-26 17:50:11 +02:00
parent e59e0f6908
commit c3f39fc93b
3 changed files with 9 additions and 5 deletions

View File

@ -381,7 +381,10 @@ class Misc(callbacks.Plugin):
If <nick> is given, it takes the continuation of the last command from
<nick> 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]

View File

@ -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 = ''

View File

@ -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)