implement Client.Channels(); remove Client.GetChannels()
This commit is contained in:
parent
a693871695
commit
817b616267
21
client.go
21
client.go
@ -419,17 +419,24 @@ func (c *Client) SetNick(name string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetChannels returns the active list of channels that the client
|
// Channels returns the active list of channels that the client is in.
|
||||||
// is in. Returns nil if tracking is disabled.
|
// Returns nil if tracking is disabled.
|
||||||
func (c *Client) GetChannels() map[string]*Channel {
|
func (c *Client) Channels() []string {
|
||||||
if c.Config.DisableTracking {
|
if c.Config.DisableTracking {
|
||||||
panic("GetChannels() used when tracking is disabled")
|
panic("Channels() used when tracking is disabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
c.state.m.RLock()
|
channels := make([]string, len(c.state.channels))
|
||||||
defer c.state.m.RUnlock()
|
|
||||||
|
|
||||||
return c.state.channels
|
c.state.m.RLock()
|
||||||
|
var i int
|
||||||
|
for channel := range c.state.channels {
|
||||||
|
channels[i] = channel
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
c.state.m.RUnlock()
|
||||||
|
|
||||||
|
return channels
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsInChannel returns true if the client is in channel.
|
// IsInChannel returns true if the client is in channel.
|
||||||
|
Loading…
Reference in New Issue
Block a user