3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 18:52:41 +01:00

comments and improvements for client set

This commit is contained in:
Jeremy Latt 2014-03-08 19:22:04 -08:00
parent 09cff18972
commit 81df7b4a5c
2 changed files with 18 additions and 3 deletions

View File

@ -203,6 +203,17 @@ func (set *UserMaskSet) Add(mask string) bool {
return true
}
func (set *UserMaskSet) AddAll(masks []string) (added bool) {
for _, mask := range masks {
if !added && !set.masks[mask] {
added = true
}
set.masks[mask] = true
}
set.setRegexp()
return
}
func (set *UserMaskSet) Remove(mask string) bool {
if !set.masks[mask] {
return false
@ -229,6 +240,12 @@ func (set *UserMaskSet) String() string {
return strings.Join(masks, " ")
}
// Generate a regular expression from the set of user mask
// strings. Masks are split at the two types of wildcards, `*` and
// `?`. All the pieces are meta-escaped. `*` is replaced with `.*`,
// the regexp equivalent. Likewise, `?` is replaced with `.`. The
// parts are re-joined and finally all masks are joined into a big
// or-expression.
func (set *UserMaskSet) setRegexp() {
if len(set.masks) == 0 {
set.regexp = nil

View File

@ -68,9 +68,7 @@ func loadChannelList(channel *Channel, list string, maskMode ChannelMode) {
if list == "" {
return
}
for _, mask := range strings.Split(list, " ") {
channel.lists[maskMode].Add(mask)
}
channel.lists[maskMode].AddAll(strings.Split(list, " "))
}
func (server *Server) loadChannels() {