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"
|
"github.com/bwmarrin/discordgo"
|
||||||
"layeh.com/gumble/gumble"
|
"layeh.com/gumble/gumble"
|
||||||
|
"layeh.com/gumble/gumbleutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BridgeState struct {
|
type BridgeState struct {
|
||||||
@ -44,7 +45,9 @@ func startBridge(discord *discordgo.Session, discordGID string, discordCID strin
|
|||||||
if mumbleInsecure {
|
if mumbleInsecure {
|
||||||
tlsConfig.InsecureSkipVerify = true
|
tlsConfig.InsecureSkipVerify = true
|
||||||
}
|
}
|
||||||
|
config.Attach(gumbleutil.Listener{
|
||||||
|
Connect: mumbleConnect,
|
||||||
|
})
|
||||||
mumble, err := gumble.DialWithDialer(new(net.Dialer), mumbleAddr, config, &tlsConfig)
|
mumble, err := gumble.DialWithDialer(new(net.Dialer), mumbleAddr, config, &tlsConfig)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -53,13 +56,6 @@ func startBridge(discord *discordgo.Session, discordGID string, discordCID strin
|
|||||||
}
|
}
|
||||||
defer mumble.Disconnect()
|
defer mumble.Disconnect()
|
||||||
Bridge.Client = mumble
|
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
|
||||||
// Shared channels pass PCM information in 10ms chunks [480]int16
|
// Shared channels pass PCM information in 10ms chunks [480]int16
|
||||||
var toMumble = mumble.AudioOutgoing()
|
var toMumble = mumble.AudioOutgoing()
|
||||||
@ -71,6 +67,7 @@ func startBridge(discord *discordgo.Session, discordGID string, discordCID strin
|
|||||||
// Mumble
|
// Mumble
|
||||||
go m.fromMumbleMixer(toDiscord, die)
|
go m.fromMumbleMixer(toDiscord, die)
|
||||||
det := config.AudioListeners.Attach(m)
|
det := config.AudioListeners.Attach(m)
|
||||||
|
|
||||||
//Discord
|
//Discord
|
||||||
go discordReceivePCM(dgv, die)
|
go discordReceivePCM(dgv, die)
|
||||||
go fromDiscordMixer(toMumble, die)
|
go fromDiscordMixer(toMumble, die)
|
||||||
|
11
handlers.go
11
handlers.go
@ -7,6 +7,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
|
"layeh.com/gumble/gumble"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ready(s *discordgo.Session, event *discordgo.Ready) {
|
func ready(s *discordgo.Session, event *discordgo.Ready) {
|
||||||
@ -192,3 +193,13 @@ func voiceUpdate(s *discordgo.Session, event *discordgo.VoiceStateUpdate) {
|
|||||||
}
|
}
|
||||||
return
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
1
main.go
1
main.go
@ -91,6 +91,7 @@ func main() {
|
|||||||
config.Password = *mumblePassword
|
config.Password = *mumblePassword
|
||||||
config.AudioInterval = time.Millisecond * 10
|
config.AudioInterval = time.Millisecond * 10
|
||||||
|
|
||||||
|
// Bridge setup
|
||||||
BridgeConf = &BridgeConfig{
|
BridgeConf = &BridgeConfig{
|
||||||
Config: config,
|
Config: config,
|
||||||
MumbleAddr: *mumbleAddr + ":" + strconv.Itoa(*mumblePort),
|
MumbleAddr: *mumbleAddr + ":" + strconv.Itoa(*mumblePort),
|
||||||
|
Loading…
Reference in New Issue
Block a user