mirror of
https://github.com/stryan/mumble-discord-bridge.git
synced 2024-11-14 11:45:40 -05:00
begin switching to mumble event listeners
This commit is contained in:
parent
bf166f7a9c
commit
c469a65ed6
13
bridge.go
13
bridge.go
@ -12,6 +12,7 @@ import (
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"layeh.com/gumble/gumble"
|
||||
"layeh.com/gumble/gumbleutil"
|
||||
)
|
||||
|
||||
type BridgeState struct {
|
||||
@ -44,7 +45,9 @@ func startBridge(discord *discordgo.Session, discordGID string, discordCID strin
|
||||
if mumbleInsecure {
|
||||
tlsConfig.InsecureSkipVerify = true
|
||||
}
|
||||
|
||||
config.Attach(gumbleutil.Listener{
|
||||
Connect: mumbleConnect,
|
||||
})
|
||||
mumble, err := gumble.DialWithDialer(new(net.Dialer), mumbleAddr, config, &tlsConfig)
|
||||
|
||||
if err != nil {
|
||||
@ -53,13 +56,6 @@ func startBridge(discord *discordgo.Session, discordGID string, discordCID strin
|
||||
}
|
||||
defer mumble.Disconnect()
|
||||
Bridge.Client = mumble
|
||||
if BridgeConf.MumbleChannel != "" {
|
||||
//join specified channel
|
||||
startingChannel := mumble.Channels.Find(BridgeConf.MumbleChannel)
|
||||
if startingChannel != nil {
|
||||
mumble.Self.Move(startingChannel)
|
||||
}
|
||||
}
|
||||
// Shared Channels
|
||||
// Shared channels pass PCM information in 10ms chunks [480]int16
|
||||
var toMumble = mumble.AudioOutgoing()
|
||||
@ -71,6 +67,7 @@ func startBridge(discord *discordgo.Session, discordGID string, discordCID strin
|
||||
// Mumble
|
||||
go m.fromMumbleMixer(toDiscord, die)
|
||||
det := config.AudioListeners.Attach(m)
|
||||
|
||||
//Discord
|
||||
go discordReceivePCM(dgv, die)
|
||||
go fromDiscordMixer(toMumble, die)
|
||||
|
11
handlers.go
11
handlers.go
@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"layeh.com/gumble/gumble"
|
||||
)
|
||||
|
||||
func ready(s *discordgo.Session, event *discordgo.Ready) {
|
||||
@ -192,3 +193,13 @@ func voiceUpdate(s *discordgo.Session, event *discordgo.VoiceStateUpdate) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func mumbleConnect(e *gumble.ConnectEvent) {
|
||||
if BridgeConf.MumbleChannel != "" {
|
||||
//join specified channel
|
||||
startingChannel := e.Client.Channels.Find(BridgeConf.MumbleChannel)
|
||||
if startingChannel != nil {
|
||||
e.Client.Self.Move(startingChannel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user