diff --git a/irc/modes.go b/irc/modes.go index 17ad2b6e..b79bb681 100644 --- a/irc/modes.go +++ b/irc/modes.go @@ -33,8 +33,7 @@ func ApplyUserModeChanges(client *Client, changes modes.ModeChanges, force bool, applied := make(modes.ModeChanges, 0) for _, change := range changes { - switch change.Mode { - case modes.Bot, modes.Invisible, modes.WallOps, modes.UserRoleplaying, modes.Operator, modes.LocalOperator, modes.RegisteredOnly, modes.UserNoCTCP: + if change.Mode != modes.ServerNotice { switch change.Op { case modes.Add: if (change.Mode == modes.Operator || change.Mode == modes.LocalOperator) && !(force && oper != nil) { @@ -73,8 +72,8 @@ func ApplyUserModeChanges(client *Client, changes modes.ModeChanges, force bool, } } } - - case modes.ServerNotice: + } else { + // server notices are weird if !client.HasMode(modes.Operator) { continue } @@ -98,8 +97,6 @@ func ApplyUserModeChanges(client *Client, changes modes.ModeChanges, force bool, applied = append(applied, change) } } - - // can't do anything to TLS mode } if len(applied) != 0 { @@ -271,15 +268,6 @@ 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, modes.NoCTCP, modes.RegisteredOnlySpeak: - if change.Op == modes.List { - continue - } - - if channel.flags.SetMode(change.Mode, change.Op == modes.Add) { - applied = append(applied, change) - } - case modes.ChannelFounder, modes.ChannelAdmin, modes.ChannelOperator, modes.Halfop, modes.Voice: if change.Op == modes.List { continue @@ -295,6 +283,16 @@ func (channel *Channel) ApplyChannelModeChanges(client *Client, isSamode bool, c if success { applied = append(applied, change) } + + default: + // all channel modes with no args, e.g., InviteOnly, Secret + if change.Op == modes.List { + continue + } + + if channel.flags.SetMode(change.Mode, change.Op == modes.Add) { + applied = append(applied, change) + } } } diff --git a/irc/modes/modes.go b/irc/modes/modes.go index 8751ca1f..0dfbe5f6 100644 --- a/irc/modes/modes.go +++ b/irc/modes/modes.go @@ -16,6 +16,7 @@ var ( // SupportedUserModes are the user modes that we actually support (modifying). SupportedUserModes = Modes{ Bot, Invisible, Operator, RegisteredOnly, ServerNotice, UserRoleplaying, + UserNoCTCP, } // SupportedChannelModes are the channel modes that we support. @@ -429,8 +430,10 @@ func (a ByCodepoint) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a ByCodepoint) Less(i, j int) bool { return a[i] < a[j] } func RplMyInfo() (param1, param2, param3 string) { - userModes := make(Modes, len(SupportedUserModes)) + userModes := make(Modes, len(SupportedUserModes), len(SupportedUserModes)+1) copy(userModes, SupportedUserModes) + // TLS is not in SupportedUserModes because it can't be modified + userModes = append(userModes, TLS) sort.Sort(ByCodepoint(userModes)) channelModes := make(Modes, len(SupportedChannelModes)+len(ChannelUserModes))