state: nick: add Channels/ChannelsStr accessors to get channels a nick is on

This commit is contained in:
StalkR 2013-01-06 20:13:06 +01:00
parent eb92a84e96
commit 2cc4e94acb
1 changed files with 18 additions and 0 deletions

View File

@ -110,6 +110,24 @@ func (nk *Nick) ParseModes(modes string) {
} }
} }
// Channels returns a list of *Channel the nick is on.
func (nk *Nick) Channels() []*Channel {
channels := make([]*Channel, 0, len(nk.lookup))
for _, channel := range nk.lookup {
channels = append(channels, channel)
}
return channels
}
// ChannelsStr returns a list of channel strings the nick is on.
func (nk *Nick) ChannelsStr() []string {
channels := make([]string, 0, len(nk.lookup))
for _, channel := range nk.lookup {
channels = append(channels, channel.Name)
}
return channels
}
// Returns a string representing the nick. Looks like: // Returns a string representing the nick. Looks like:
// Nick: <nick name> e.g. CowMaster // Nick: <nick name> e.g. CowMaster
// Hostmask: <ident@host> e.g. moo@cows.org // Hostmask: <ident@host> e.g. moo@cows.org