3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-11 06:29:29 +01:00
RELAYMSG should respect mutes
This commit is contained in:
Shivaram Lingamneni 2021-03-11 01:21:03 -05:00
parent 76b0e44474
commit fe8e6551c3
2 changed files with 10 additions and 0 deletions

View File

@ -1324,6 +1324,12 @@ func (channel *Channel) isMuted(client *Client) bool {
return muteRe.MatchString(nuh) && !channel.lists[modes.ExceptMask].MatchMute(nuh) 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) { func msgCommandToHistType(command string) (history.ItemType, error) {
switch command { switch command {
case "PRIVMSG": case "PRIVMSG":

View File

@ -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)) 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 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{ channel.AddHistoryItem(history.Item{
Type: history.Privmsg, Type: history.Privmsg,