1
0
mirror of https://github.com/stryan/mumble-discord-bridge.git synced 2024-10-31 16:55:42 -04:00

on mumble events

This commit is contained in:
Tyler Stiene 2020-11-30 19:23:55 -05:00
parent d75e78d1dd
commit 5f9ad7b7dd
2 changed files with 72 additions and 0 deletions

View File

@ -144,6 +144,7 @@ func main() {
config.AudioInterval = time.Millisecond * 10
m := MumbleDuplex{}
ml := MumbleEventListener{}
var tlsConfig tls.Config
if *mumbleInsecure {
@ -170,6 +171,7 @@ func main() {
// Mumble
go m.fromMumbleMixer(toDiscord)
config.AudioListeners.Attach(m)
config.Listeners.Attach(ml)
//Discord
go discordReceivePCM(dgv, die)
go fromDiscordMixer(toMumble)
@ -196,4 +198,8 @@ func main() {
case <-die:
log.Println("\nGot internal die request. Terminating Mumble-Bridge")
}
time.AfterFunc(5*time.Second, func() {
log.Println("Graceful disconnect timeout, Forcing!")
os.Exit(9)
})
}

66
mumble-event.go Normal file
View File

@ -0,0 +1,66 @@
package main
import (
"fmt"
"layeh.com/gumble/gumble"
_ "layeh.com/gumble/opus"
)
// MumbleEventListener - Bridge Event Handler
type MumbleEventListener struct{}
// OnConnect - event handler
func (ml MumbleEventListener) OnConnect(e *gumble.ConnectEvent) {
fmt.Println("OnConnect", e)
}
// OnDisconnect - event handler
func (ml MumbleEventListener) OnDisconnect(e *gumble.DisconnectEvent) {
fmt.Println("OnDisconnect", e)
}
// OnTextMessage - event handler
func (ml MumbleEventListener) OnTextMessage(e *gumble.TextMessageEvent) {
fmt.Println("OnTextMessage", e)
}
// OnUserChange - event handler
func (ml MumbleEventListener) OnUserChange(e *gumble.UserChangeEvent) {
fmt.Println("OnUserChange", e.User.Name, e)
}
// OnChannelChange - event handler
func (ml MumbleEventListener) OnChannelChange(e *gumble.ChannelChangeEvent) {
fmt.Println("OnChannelChange", e)
}
// OnPermissionDenied - event handler
func (ml MumbleEventListener) OnPermissionDenied(e *gumble.PermissionDeniedEvent) {
fmt.Println("OnPermissionDenied", e)
}
// OnUserList - event handler
func (ml MumbleEventListener) OnUserList(e *gumble.UserListEvent) {
fmt.Println("OnUserList", e)
}
// OnACL - event handler
func (ml MumbleEventListener) OnACL(e *gumble.ACLEvent) {
fmt.Println("OnACL", e)
}
// OnBanList - event handler
func (ml MumbleEventListener) OnBanList(e *gumble.BanListEvent) {
fmt.Println("OnBanList", e)
}
// OnContextActionChange - event handler
func (ml MumbleEventListener) OnContextActionChange(e *gumble.ContextActionChangeEvent) {
fmt.Println("OnContextActionChange", e)
}
// OnServerConfig - event handler
func (ml MumbleEventListener) OnServerConfig(e *gumble.ServerConfigEvent) {
fmt.Println("OnServerConfig", e)
}