Added listeners to mumbledj type
This commit is contained in:
parent
66f21f89ea
commit
1e29473e86
19
main.go
19
main.go
|
@ -21,10 +21,17 @@ type mumbledj struct {
|
||||||
client *gumble.Client
|
client *gumble.Client
|
||||||
keepAlive chan bool
|
keepAlive chan bool
|
||||||
defaultChannel string
|
defaultChannel string
|
||||||
|
conf config
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dj *mumbledj) OnConnect(e *gumble.ConnectEvent) {
|
func (dj *mumbledj) OnConnect(e *gumble.ConnectEvent) {
|
||||||
dj.client.Self().Move(dj.client.Channels().Find(dj.defaultChannel))
|
dj.client.Self().Move(dj.client.Channels().Find(dj.defaultChannel))
|
||||||
|
|
||||||
|
var err error
|
||||||
|
dj.conf, err = loadConfiguration()
|
||||||
|
if err == nil {
|
||||||
|
fmt.Println("Configuration successfully loaded!")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dj *mumbledj) OnDisconnect(e *gumble.DisconnectEvent) {
|
func (dj *mumbledj) OnDisconnect(e *gumble.DisconnectEvent) {
|
||||||
|
@ -32,7 +39,13 @@ func (dj *mumbledj) OnDisconnect(e *gumble.DisconnectEvent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dj *mumbledj) OnTextMessage(e *gumble.TextMessageEvent) {
|
func (dj *mumbledj) OnTextMessage(e *gumble.TextMessageEvent) {
|
||||||
fmt.Println(e.Message)
|
if e.Message[0] == '!' {
|
||||||
|
parseCommand(e.Sender.Name(), e.Message[1:])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var dj = mumbledj {
|
||||||
|
keepAlive: make(chan bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -44,10 +57,6 @@ func main() {
|
||||||
flag.StringVar(&channel, "channel", "", "default channel for MumbleDJ")
|
flag.StringVar(&channel, "channel", "", "default channel for MumbleDJ")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
dj := mumbledj {
|
|
||||||
keepAlive: make(chan bool),
|
|
||||||
}
|
|
||||||
|
|
||||||
dj.client = gumble.NewClient(&dj.config)
|
dj.client = gumble.NewClient(&dj.config)
|
||||||
dj.config = gumble.Config{
|
dj.config = gumble.Config{
|
||||||
Username: username,
|
Username: username,
|
||||||
|
|
Reference in a new issue