3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-25 21:39:25 +01:00

channel invite mode/list

This commit is contained in:
Jeremy Latt 2014-03-07 17:35:58 -08:00
parent cd2042dfea
commit 04c30c8c9b
2 changed files with 34 additions and 15 deletions

View File

@ -323,29 +323,40 @@ func (channel *Channel) applyModeMember(client *Client, mode ChannelMode,
return false return false
} }
func (channel *Channel) applyModeMask(client *Client, mode ChannelMode, op ModeOp, mask string) bool { func (channel *Channel) ShowMaskList(client *Client, mode ChannelMode) {
if !channel.ClientIsOperator(client) { for lmask := range channel.lists[mode].masks {
client.ErrChanOPrivIsNeeded(channel) client.RplMaskList(mode, channel, lmask)
return false
} }
client.RplEndOfMaskList(mode, channel)
}
func (channel *Channel) applyModeMask(client *Client, mode ChannelMode, op ModeOp,
mask string) bool {
list := channel.lists[mode] list := channel.lists[mode]
if list == nil { if list == nil {
// This should never happen, but better safe than panicky. // This should never happen, but better safe than panicky.
return false return false
} }
if op == Add { if (op == List) || (mask == "") {
list.Add(mask) channel.ShowMaskList(client, mode)
} else if op == Remove { return false
list.Remove(mask)
} }
for lmask := range channel.lists[mode].masks { if !channel.ClientIsOperator(client) {
client.RplMaskList(mode, channel, lmask) client.ErrChanOPrivIsNeeded(channel)
return false
} }
client.RplEndOfMaskList(mode, channel)
return true if op == Add {
return list.Add(mask)
}
if op == Remove {
return list.Remove(mask)
}
return false
} }
func (channel *Channel) applyMode(client *Client, change *ChannelModeChange) bool { func (channel *Channel) applyMode(client *Client, change *ChannelModeChange) bool {
@ -353,7 +364,7 @@ func (channel *Channel) applyMode(client *Client, change *ChannelModeChange) boo
case BanMask, ExceptMask, InviteMask: case BanMask, ExceptMask, InviteMask:
return channel.applyModeMask(client, change.mode, change.op, change.arg) return channel.applyModeMask(client, change.mode, change.op, change.arg)
case Moderated, NoOutside, OpOnlyTopic, Persistent, Private: case InviteOnly, Moderated, NoOutside, OpOnlyTopic, Persistent, Private:
return channel.applyModeFlag(client, change.mode, change.op) return channel.applyModeFlag(client, change.mode, change.op)
case Key: case Key:

View File

@ -194,14 +194,22 @@ func NewUserMaskSet() *UserMaskSet {
} }
} }
func (set *UserMaskSet) Add(mask string) { func (set *UserMaskSet) Add(mask string) bool {
if set.masks[mask] {
return false
}
set.masks[mask] = true set.masks[mask] = true
set.setRegexp() set.setRegexp()
return true
} }
func (set *UserMaskSet) Remove(mask string) { func (set *UserMaskSet) Remove(mask string) bool {
if !set.masks[mask] {
return false
}
delete(set.masks, mask) delete(set.masks, mask)
set.setRegexp() set.setRegexp()
return true
} }
func (set *UserMaskSet) Match(userhost string) bool { func (set *UserMaskSet) Match(userhost string) bool {