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:
parent
09cff18972
commit
81df7b4a5c
@ -203,6 +203,17 @@ func (set *UserMaskSet) Add(mask string) bool {
|
|||||||
return true
|
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 {
|
func (set *UserMaskSet) Remove(mask string) bool {
|
||||||
if !set.masks[mask] {
|
if !set.masks[mask] {
|
||||||
return false
|
return false
|
||||||
@ -229,6 +240,12 @@ func (set *UserMaskSet) String() string {
|
|||||||
return strings.Join(masks, " ")
|
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() {
|
func (set *UserMaskSet) setRegexp() {
|
||||||
if len(set.masks) == 0 {
|
if len(set.masks) == 0 {
|
||||||
set.regexp = nil
|
set.regexp = nil
|
||||||
|
@ -68,9 +68,7 @@ func loadChannelList(channel *Channel, list string, maskMode ChannelMode) {
|
|||||||
if list == "" {
|
if list == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, mask := range strings.Split(list, " ") {
|
channel.lists[maskMode].AddAll(strings.Split(list, " "))
|
||||||
channel.lists[maskMode].Add(mask)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (server *Server) loadChannels() {
|
func (server *Server) loadChannels() {
|
||||||
|
Loading…
Reference in New Issue
Block a user