mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
47 lines
785 B
Go
47 lines
785 B
Go
package irc
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
// Stats contains the numbers of total, invisible and operators on the server
|
|
type Stats struct {
|
|
sync.RWMutex
|
|
|
|
Total int
|
|
Invisible int
|
|
Operators int
|
|
}
|
|
|
|
// ChangeTotal increments the total user count on server
|
|
func (s *Stats) ChangeTotal(i int) {
|
|
s.Lock()
|
|
defer s.Unlock()
|
|
|
|
s.Total += i
|
|
}
|
|
|
|
// ChangeInvisible increments the invisible count
|
|
func (s *Stats) ChangeInvisible(i int) {
|
|
s.Lock()
|
|
defer s.Unlock()
|
|
|
|
s.Invisible += i
|
|
}
|
|
|
|
// ChangeOperators increases the operator count
|
|
func (s *Stats) ChangeOperators(i int) {
|
|
s.Lock()
|
|
defer s.Unlock()
|
|
|
|
s.Operators += i
|
|
}
|
|
|
|
// GetStats retrives total, invisible and oper count
|
|
func (s *Stats) GetStats() (int, int, int) {
|
|
s.Lock()
|
|
defer s.Unlock()
|
|
|
|
return s.Total, s.Invisible, s.Operators
|
|
}
|