3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00

avoid duplicate mode changes

This commit is contained in:
Jeremy Latt 2014-02-25 22:16:23 -08:00
parent 0d277025c1
commit 66f9b42125
3 changed files with 26 additions and 2 deletions

View File

@ -248,10 +248,16 @@ func (channel *Channel) applyModeFlag(client *Client, mode ChannelMode,
switch op {
case Add:
if channel.flags[mode] {
return false
}
channel.flags[mode] = true
return true
case Remove:
if !channel.flags[mode] {
return false
}
delete(channel.flags, mode)
return true
}
@ -283,10 +289,16 @@ func (channel *Channel) applyModeMember(client *Client, mode ChannelMode,
switch op {
case Add:
if channel.members[target][mode] {
return false
}
channel.members[target][mode] = true
return true
case Remove:
if !channel.members[target][mode] {
return false
}
channel.members[target][mode] = false
return true
}
@ -318,6 +330,9 @@ func (channel *Channel) applyMode(client *Client, change *ChannelModeChange) boo
client.ErrNeedMoreParams("MODE")
return false
}
if change.arg == channel.key {
return false
}
channel.key = change.arg
return true
@ -333,7 +348,7 @@ func (channel *Channel) applyMode(client *Client, change *ChannelModeChange) boo
client.ErrNeedMoreParams("MODE")
return false
}
if limit == 0 {
if (limit == 0) || (limit == channel.userLimit) {
return false
}

View File

@ -23,7 +23,7 @@ var (
)
const (
SEM_VER = "ergonomadic-1.2.2"
SEM_VER = "ergonomadic-1.2.3"
CRLF = "\r\n"
MAX_REPLY_LEN = 512 - len(CRLF)

View File

@ -525,16 +525,25 @@ func (m *ModeCommand) HandleServer(s *Server) {
case Invisible, ServerNotice, WallOps:
switch change.op {
case Add:
if target.flags[change.mode] {
continue
}
target.flags[change.mode] = true
changes = append(changes, change)
case Remove:
if !target.flags[change.mode] {
continue
}
delete(target.flags, change.mode)
changes = append(changes, change)
}
case Operator, LocalOperator:
if change.op == Remove {
if !target.flags[change.mode] {
continue
}
delete(target.flags, change.mode)
changes = append(changes, change)
}