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 If <nick> is given, it takes the continuation of the last command from
<nick> instead of the person sending this message. <nick> instead of the person sending this message.
""" """
if '!' in msg.prefix and '@' in msg.prefix:
userHostmask = msg.prefix.split('!', 1)[1] userHostmask = msg.prefix.split('!', 1)[1]
else:
userHostmask = msg.nick
if nick: if nick:
try: try:
(private, L) = irc._mores[nick] (private, L) = irc._mores[nick]

View File

@ -341,7 +341,7 @@ class Relay(callbacks.Plugin):
if channel not in self.registryValue('channels'): if channel not in self.registryValue('channels'):
return return
network = self._getIrcName(irc) 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]) hostmask = format(' (%s)', msg.prefix.split('!')[1])
else: else:
hostmask = '' hostmask = ''
@ -355,7 +355,7 @@ class Relay(callbacks.Plugin):
if channel not in self.registryValue('channels'): if channel not in self.registryValue('channels'):
return return
network = self._getIrcName(irc) 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]) hostmask = format(' (%s)', msg.prefix.split('!')[1])
else: else:
hostmask = '' hostmask = ''

View File

@ -883,6 +883,7 @@ class ReplyIrcProxy(RichReplyMethods):
prefix = state.nickToHostmask(target) prefix = state.nickToHostmask(target)
except KeyError: except KeyError:
pass # We'll leave it as it is. pass # We'll leave it as it is.
if '!' in prefix and '@' in prefix:
mask = prefix.split('!', 1)[1] mask = prefix.split('!', 1)[1]
self._mores[mask] = msgs self._mores[mask] = msgs
public = bool(self.msg.channel) public = bool(self.msg.channel)