Merge pull request #67 from mkbwong/master
Fix for issue #34: !move does not work with sub channels
This commit is contained in:
commit
6398ef43c8
|
@ -339,10 +339,10 @@ func move(user *gumble.User, channel string) {
|
||||||
if channel == "" {
|
if channel == "" {
|
||||||
dj.SendPrivateMessage(user, NO_ARGUMENT_MSG)
|
dj.SendPrivateMessage(user, NO_ARGUMENT_MSG)
|
||||||
} else {
|
} else {
|
||||||
if dj.client.Channels.Find(channel) != nil {
|
if channels := strings.Split(channel, "/"); dj.client.Channels.Find(channels...) != nil {
|
||||||
dj.client.Self.Move(dj.client.Channels.Find(channel))
|
dj.client.Self.Move(dj.client.Channels.Find(channels...))
|
||||||
} else {
|
} else {
|
||||||
dj.SendPrivateMessage(user, CHANNEL_DOES_NOT_EXIST_MSG)
|
dj.SendPrivateMessage(user, CHANNEL_DOES_NOT_EXIST_MSG+" "+channel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
main.go
13
main.go
|
@ -13,6 +13,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/layeh/gopus"
|
"github.com/layeh/gopus"
|
||||||
|
@ -27,7 +28,7 @@ type mumbledj struct {
|
||||||
config gumble.Config
|
config gumble.Config
|
||||||
client *gumble.Client
|
client *gumble.Client
|
||||||
keepAlive chan bool
|
keepAlive chan bool
|
||||||
defaultChannel string
|
defaultChannel []string
|
||||||
conf DjConfig
|
conf DjConfig
|
||||||
queue *SongQueue
|
queue *SongQueue
|
||||||
audioStream *gumble_ffmpeg.Stream
|
audioStream *gumble_ffmpeg.Stream
|
||||||
|
@ -40,8 +41,8 @@ type mumbledj struct {
|
||||||
// via commandline args, and moves to root channel if the channel does not exist. The current
|
// via commandline args, and moves to root channel if the channel does not exist. The current
|
||||||
// user's homedir path is stored, configuration is loaded, and the audio stream is set up.
|
// user's homedir path is stored, configuration is loaded, and the audio stream is set up.
|
||||||
func (dj *mumbledj) OnConnect(e *gumble.ConnectEvent) {
|
func (dj *mumbledj) OnConnect(e *gumble.ConnectEvent) {
|
||||||
if dj.client.Channels.Find(dj.defaultChannel) != nil {
|
if dj.client.Channels.Find(dj.defaultChannel...) != nil {
|
||||||
dj.client.Self.Move(dj.client.Channels.Find(dj.defaultChannel))
|
dj.client.Self.Move(dj.client.Channels.Find(dj.defaultChannel...))
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("Channel doesn't exist or one was not provided, staying in root channel...")
|
fmt.Println("Channel doesn't exist or one was not provided, staying in root channel...")
|
||||||
}
|
}
|
||||||
|
@ -162,7 +163,7 @@ func main() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var address, port, username, password, channel, pemCert, pemKey string
|
var address, port, username, password, channel, pemCert, pemKey, accesstokens string
|
||||||
var insecure bool
|
var insecure bool
|
||||||
|
|
||||||
flag.StringVar(&address, "server", "localhost", "address for Mumble server")
|
flag.StringVar(&address, "server", "localhost", "address for Mumble server")
|
||||||
|
@ -172,6 +173,7 @@ func main() {
|
||||||
flag.StringVar(&channel, "channel", "root", "default channel for MumbleDJ")
|
flag.StringVar(&channel, "channel", "root", "default channel for MumbleDJ")
|
||||||
flag.StringVar(&pemCert, "cert", "", "path to user PEM certificate for MumbleDJ")
|
flag.StringVar(&pemCert, "cert", "", "path to user PEM certificate for MumbleDJ")
|
||||||
flag.StringVar(&pemKey, "key", "", "path to user PEM key for MumbleDJ")
|
flag.StringVar(&pemKey, "key", "", "path to user PEM key for MumbleDJ")
|
||||||
|
flag.StringVar(&accesstokens, "accesstokens", "", "list of access tokens for channel auth")
|
||||||
flag.BoolVar(&insecure, "insecure", false, "skip certificate checking")
|
flag.BoolVar(&insecure, "insecure", false, "skip certificate checking")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
@ -179,6 +181,7 @@ func main() {
|
||||||
Username: username,
|
Username: username,
|
||||||
Password: password,
|
Password: password,
|
||||||
Address: address + ":" + port,
|
Address: address + ":" + port,
|
||||||
|
Tokens: strings.Split(accesstokens, " "),
|
||||||
}
|
}
|
||||||
dj.client = gumble.NewClient(&dj.config)
|
dj.client = gumble.NewClient(&dj.config)
|
||||||
|
|
||||||
|
@ -197,7 +200,7 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dj.defaultChannel = channel
|
dj.defaultChannel = strings.Split(channel, "/")
|
||||||
|
|
||||||
dj.client.Attach(gumbleutil.Listener{
|
dj.client.Attach(gumbleutil.Listener{
|
||||||
Connect: dj.OnConnect,
|
Connect: dj.OnConnect,
|
||||||
|
|
Reference in a new issue