diff --git a/docs/MANUAL.md b/docs/MANUAL.md index 16074c44..a66bd120 100644 --- a/docs/MANUAL.md +++ b/docs/MANUAL.md @@ -608,6 +608,10 @@ This mode is enabled by default, and means that only channel operators can chang If this mode is unset, anyone will be able to change the channel topic. +### +C - No CTCPs + +This mode means that [client-to-client protocol](https://tools.ietf.org/id/draft-oakley-irc-ctcp-01.html) messages other than `ACTION` (`/me`) cannot be sent to the channel. + ## Channel Prefixes diff --git a/irc/channel.go b/irc/channel.go index 1fe6b230..0182e6ab 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -1070,6 +1070,14 @@ func (channel *Channel) SendSplitMessage(command string, minPrefixMode modes.Mod return } + isCTCP := message.IsRestrictedCTCPMessage() + if isCTCP && channel.flags.HasMode(modes.NoCTCP) { + if histType != history.Notice { + rb.Add(nil, client.server.name, ERR_CANNOTSENDTOCHAN, client.Nick(), channel.Name(), fmt.Sprintf(client.t("Cannot send to channel (+%s)"), "C")) + } + return + } + nickmask := client.NickMaskString() account := client.AccountName() chname := channel.Name() @@ -1116,6 +1124,9 @@ func (channel *Channel) SendSplitMessage(command string, minPrefixMode modes.Mod // STATUSMSG continue } + if isCTCP && member.isTor { + continue // #753 + } for _, session := range member.Sessions() { var tagsToUse map[string]string diff --git a/irc/modes.go b/irc/modes.go index f10454b3..d8d1db8e 100644 --- a/irc/modes.go +++ b/irc/modes.go @@ -221,7 +221,7 @@ func (channel *Channel) ApplyChannelModeChanges(client *Client, isSamode bool, c applied = append(applied, change) } - case modes.InviteOnly, modes.Moderated, modes.NoOutside, modes.OpOnlyTopic, modes.RegisteredOnly, modes.Secret, modes.ChanRoleplaying: + case modes.InviteOnly, modes.Moderated, modes.NoOutside, modes.OpOnlyTopic, modes.RegisteredOnly, modes.Secret, modes.ChanRoleplaying, modes.NoCTCP: if change.Op == modes.List { continue } diff --git a/irc/modes/modes.go b/irc/modes/modes.go index aba6b447..64bb56ff 100644 --- a/irc/modes/modes.go +++ b/irc/modes/modes.go @@ -21,6 +21,7 @@ var ( SupportedChannelModes = Modes{ BanMask, ChanRoleplaying, ExceptMask, InviteMask, InviteOnly, Key, Moderated, NoOutside, OpOnlyTopic, RegisteredOnly, Secret, UserLimit, + NoCTCP, } ) @@ -132,6 +133,7 @@ const ( // RegisteredOnly mode is reused here from umode definition Secret Mode = 's' // flag UserLimit Mode = 'l' // flag arg + NoCTCP Mode = 'C' // flag ) var (