announce auto status change, respect what voice channel used for manual link
This commit is contained in:
parent
16a66719e1
commit
8e5bb4b479
12
bridge.go
12
bridge.go
@ -73,7 +73,8 @@ type BridgeState struct {
|
||||
}
|
||||
|
||||
// startBridge established the voice connection
|
||||
func (b *BridgeState) startBridge() {
|
||||
// if channelID is empty, use channelID from config
|
||||
func (b *BridgeState) startBridge(channelID string) {
|
||||
b.lock.Lock()
|
||||
defer b.lock.Unlock()
|
||||
|
||||
@ -90,7 +91,12 @@ func (b *BridgeState) startBridge() {
|
||||
|
||||
// DISCORD Connect Voice
|
||||
log.Println("Attempting to join Discord voice channel")
|
||||
b.DiscordVoice, err = b.DiscordSession.ChannelVoiceJoin(b.BridgeConfig.GID, b.BridgeConfig.CID, false, false)
|
||||
if channelID == "" {
|
||||
b.DiscordVoice, err = b.DiscordSession.ChannelVoiceJoin(b.BridgeConfig.GID, b.BridgeConfig.CID, false, false)
|
||||
} else {
|
||||
b.DiscordVoice, err = b.DiscordSession.ChannelVoiceJoin(b.BridgeConfig.GID, channelID, false, false)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
b.DiscordVoice.Disconnect()
|
||||
@ -241,7 +247,7 @@ func (b *BridgeState) AutoBridge() {
|
||||
|
||||
if !b.Connected && b.MumbleUserCount > 0 && len(b.DiscordUsers) > 0 {
|
||||
log.Println("users detected in mumble and discord, bridging")
|
||||
go b.startBridge()
|
||||
go b.startBridge("")
|
||||
}
|
||||
if b.Connected && b.MumbleUserCount == 0 && len(b.DiscordUsers) <= 1 {
|
||||
log.Println("no one online, killing bridge")
|
||||
|
@ -88,7 +88,7 @@ func (l *DiscordListener) messageCreate(s *discordgo.Session, m *discordgo.Messa
|
||||
for _, vs := range g.VoiceStates {
|
||||
if vs.UserID == m.Author.ID {
|
||||
log.Printf("Trying to join GID %v and VID %v\n", g.ID, vs.ChannelID)
|
||||
go l.Bridge.startBridge()
|
||||
go l.Bridge.startBridge(vs.ChannelID)
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -114,7 +114,7 @@ func (l *DiscordListener) messageCreate(s *discordgo.Session, m *discordgo.Messa
|
||||
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
go l.Bridge.startBridge()
|
||||
go l.Bridge.startBridge(vs.ChannelID)
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -122,10 +122,12 @@ func (l *DiscordListener) messageCreate(s *discordgo.Session, m *discordgo.Messa
|
||||
|
||||
if strings.HasPrefix(m.Content, prefix+" auto") {
|
||||
if l.Bridge.Mode != bridgeModeAuto {
|
||||
l.Bridge.DiscordSession.ChannelMessageSend(m.ChannelID, "Auto mode enabled")
|
||||
l.Bridge.Mode = bridgeModeAuto
|
||||
l.Bridge.AutoChanDie = make(chan bool)
|
||||
go l.Bridge.AutoBridge()
|
||||
} else {
|
||||
l.Bridge.DiscordSession.ChannelMessageSend(m.ChannelID, "Auto mode disabled")
|
||||
l.Bridge.AutoChanDie <- true
|
||||
l.Bridge.Mode = bridgeModeManual
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user