mirror of
https://github.com/fluffle/goirc
synced 2025-09-06 00:43:20 +00:00
Add a method to wipe a state tracker clean.
This commit is contained in:
parent
60cd5b975f
commit
cfffcf2a85
2 changed files with 65 additions and 1 deletions
|
@ -21,6 +21,7 @@ type StateTracker interface {
|
|||
IsOn(channel, nick string) (*ChanPrivs, bool)
|
||||
Associate(channel *Channel, nick *Nick) *ChanPrivs
|
||||
Dissociate(channel *Channel, nick *Nick)
|
||||
Wipe()
|
||||
}
|
||||
|
||||
// ... and a struct to implement it ...
|
||||
|
@ -37,7 +38,7 @@ type stateTracker struct {
|
|||
l logging.Logger
|
||||
}
|
||||
|
||||
// ... and finally a constructor to make it.
|
||||
// ... and a constructor to make it ...
|
||||
func NewTracker(mynick string, l logging.Logger) *stateTracker {
|
||||
st := &stateTracker{
|
||||
chans: make(map[string]*Channel),
|
||||
|
@ -48,6 +49,14 @@ func NewTracker(mynick string, l logging.Logger) *stateTracker {
|
|||
return st
|
||||
}
|
||||
|
||||
// ... and a method to wipe the state clean.
|
||||
func (st *stateTracker) Wipe() {
|
||||
// Deleting all the channels implicitly deletes every nick but me.
|
||||
for _, ch := range st.chans {
|
||||
st.delChannel(ch)
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************\
|
||||
* tracker methods to create/look up nicks/channels
|
||||
\******************************************************************************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue