mirror of
https://github.com/42wim/matterbridge.git
synced 2024-12-18 06:52:01 -08:00
19 lines
467 B
Go
19 lines
467 B
Go
|
package gumbleutil
|
||
|
|
||
|
import (
|
||
|
"layeh.com/gumble/gumble"
|
||
|
)
|
||
|
|
||
|
// ChannelPath returns a slice of channel names, starting from the root channel
|
||
|
// to the given channel.
|
||
|
func ChannelPath(channel *gumble.Channel) []string {
|
||
|
var pieces []string
|
||
|
for ; channel != nil; channel = channel.Parent {
|
||
|
pieces = append(pieces, channel.Name)
|
||
|
}
|
||
|
for i := 0; i < (len(pieces) / 2); i++ {
|
||
|
pieces[len(pieces)-1-i], pieces[i] = pieces[i], pieces[len(pieces)-1-i]
|
||
|
}
|
||
|
return pieces
|
||
|
}
|