mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
initial implementation of bouncer functionality
This commit is contained in:
parent
a8f04ecc4d
commit
c2faeed4b5
19 changed files with 733 additions and 441 deletions
|
|
@ -20,6 +20,16 @@ func NewSet(capabs ...Capability) *Set {
|
|||
return &newSet
|
||||
}
|
||||
|
||||
// NewCompleteSet returns a new Set, with all defined capabilities enabled.
|
||||
func NewCompleteSet() *Set {
|
||||
var newSet Set
|
||||
asSlice := newSet[:]
|
||||
for i := 0; i < numCapabs; i += 1 {
|
||||
utils.BitsetSet(asSlice, uint(i), true)
|
||||
}
|
||||
return &newSet
|
||||
}
|
||||
|
||||
// Enable enables the given capabilities.
|
||||
func (s *Set) Enable(capabs ...Capability) {
|
||||
asSlice := s[:]
|
||||
|
|
@ -53,6 +63,16 @@ func (s *Set) Has(capab Capability) bool {
|
|||
return utils.BitsetGet(s[:], uint(capab))
|
||||
}
|
||||
|
||||
// HasAll returns true if the set has all the given capabilities.
|
||||
func (s *Set) HasAll(capabs ...Capability) bool {
|
||||
for _, capab := range capabs {
|
||||
if !s.Has(capab) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Union adds all the capabilities of another set to this set.
|
||||
func (s *Set) Union(other *Set) {
|
||||
utils.BitsetUnion(s[:], other[:])
|
||||
|
|
@ -94,3 +114,9 @@ func (s *Set) String(version Version, values *Values) string {
|
|||
|
||||
return strings.Join(strs, " ")
|
||||
}
|
||||
|
||||
// returns whether we should send `znc.in/self-message`-style echo messages
|
||||
// to sessions other than that which originated the message
|
||||
func (capabs *Set) SelfMessagesEnabled() bool {
|
||||
return capabs.Has(EchoMessage) || capabs.Has(ZNCSelfMessage)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue