mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
fix ban regexp not being recompiled on removal
This commit is contained in:
parent
b1e12ca1eb
commit
b83d454554
@ -240,7 +240,7 @@ func NewUserMaskSet() *UserMaskSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add adds the given mask to this set.
|
// Add adds the given mask to this set.
|
||||||
func (set *UserMaskSet) Add(mask string) bool {
|
func (set *UserMaskSet) Add(mask string) (added bool) {
|
||||||
casefoldedMask, err := Casefold(mask)
|
casefoldedMask, err := Casefold(mask)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(fmt.Sprintf("ERROR: Could not add mask to usermaskset: [%s]", mask))
|
log.Println(fmt.Sprintf("ERROR: Could not add mask to usermaskset: [%s]", mask))
|
||||||
@ -248,16 +248,16 @@ func (set *UserMaskSet) Add(mask string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set.Lock()
|
set.Lock()
|
||||||
already := set.masks[casefoldedMask]
|
added = !set.masks[casefoldedMask]
|
||||||
|
if added {
|
||||||
set.masks[casefoldedMask] = true
|
set.masks[casefoldedMask] = true
|
||||||
|
}
|
||||||
set.Unlock()
|
set.Unlock()
|
||||||
|
|
||||||
if already {
|
if added {
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
set.setRegexp()
|
set.setRegexp()
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddAll adds the given masks to this set.
|
// AddAll adds the given masks to this set.
|
||||||
@ -271,23 +271,25 @@ func (set *UserMaskSet) AddAll(masks []string) (added bool) {
|
|||||||
}
|
}
|
||||||
set.masks[mask] = true
|
set.masks[mask] = true
|
||||||
}
|
}
|
||||||
|
if added {
|
||||||
set.setRegexp()
|
set.setRegexp()
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove removes the given mask from this set.
|
// Remove removes the given mask from this set.
|
||||||
func (set *UserMaskSet) Remove(mask string) bool {
|
func (set *UserMaskSet) Remove(mask string) (removed bool) {
|
||||||
set.Lock()
|
set.Lock()
|
||||||
already := !set.masks[mask]
|
removed = set.masks[mask]
|
||||||
|
if removed {
|
||||||
delete(set.masks, mask)
|
delete(set.masks, mask)
|
||||||
|
}
|
||||||
set.Unlock()
|
set.Unlock()
|
||||||
|
|
||||||
if !already {
|
if removed {
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
set.setRegexp()
|
set.setRegexp()
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Match matches the given n!u@h.
|
// Match matches the given n!u@h.
|
||||||
|
Loading…
Reference in New Issue
Block a user