1
0
Fork 0
forked from External/ergo
Make snomask add/remove behavior match other ircds
This commit is contained in:
Shivaram Lingamneni 2021-02-08 11:43:13 -05:00
parent 42316bc04f
commit 91cfdb963d
8 changed files with 214 additions and 44 deletions

View file

@ -24,11 +24,6 @@ func (m *SnoManager) AddMasks(client *Client, masks ...sno.Mask) {
defer m.sendListMutex.Unlock()
for _, mask := range masks {
// confirm mask is valid
if !sno.ValidMasks[mask] {
continue
}
currentClientList := m.sendLists[mask]
if currentClientList == nil {
@ -101,19 +96,23 @@ func (m *SnoManager) Send(mask sno.Mask, content string) {
}
}
// String returns the snomasks currently enabled.
func (m *SnoManager) String(client *Client) string {
// MasksEnabled returns the snomasks currently enabled.
func (m *SnoManager) MasksEnabled(client *Client) (result sno.Masks) {
m.sendListMutex.RLock()
defer m.sendListMutex.RUnlock()
var masks string
for mask, clients := range m.sendLists {
for c := range clients {
if c == client {
masks += string(mask)
result = append(result, mask)
break
}
}
}
return masks
return
}
func (m *SnoManager) String(client *Client) string {
masks := m.MasksEnabled(client)
return masks.String()
}