From fe8e6551c38e26e263df5d82a2c2e2927ee8b0b7 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Thu, 11 Mar 2021 01:21:03 -0500 Subject: [PATCH] fix #1502 RELAYMSG should respect mutes --- irc/channel.go | 6 ++++++ irc/handlers.go | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/irc/channel.go b/irc/channel.go index 09a8a956..99dde88e 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -1324,6 +1324,12 @@ func (channel *Channel) isMuted(client *Client) bool { return muteRe.MatchString(nuh) && !channel.lists[modes.ExceptMask].MatchMute(nuh) } +func (channel *Channel) relayNickMuted(relayNick string) bool { + relayNUH := fmt.Sprintf("%s!*@*", relayNick) + return channel.lists[modes.BanMask].MatchMute(relayNUH) && + !channel.lists[modes.ExceptMask].MatchMute(relayNUH) +} + func msgCommandToHistType(command string) (history.ItemType, error) { switch command { case "PRIVMSG": diff --git a/irc/handlers.go b/irc/handlers.go index 5ad2771c..ac417a6d 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -2647,6 +2647,10 @@ func relaymsgHandler(server *Server, client *Client, msg ircmsg.Message, rb *Res rb.Add(nil, server.name, "FAIL", "RELAYMSG", "INVALID_NICK", fmt.Sprintf(client.t("Relayed nicknames MUST contain a relaymsg separator from this set: %s"), config.Server.Relaymsg.Separators)) return false } + if channel.relayNickMuted(nick) { + rb.Add(nil, server.name, "FAIL", "RELAYMSG", "BANNED", fmt.Sprintf(client.t("%s is banned from relaying to the channel"), nick)) + return false + } channel.AddHistoryItem(history.Item{ Type: history.Privmsg,