mirror of
https://github.com/stryan/mumble-discord-bridge.git
synced 2024-11-23 05:45:41 -05:00
add auto_mode flag
This commit is contained in:
parent
4b8e6eea55
commit
77cf328955
@ -135,10 +135,11 @@ func AutoBridge(s *discordgo.Session) {
|
|||||||
Bridge.ActiveConn = die
|
Bridge.ActiveConn = die
|
||||||
go startBridge(s, BridgeConf.GID, BridgeConf.CID, BridgeConf.Config, BridgeConf.MumbleAddr, BridgeConf.MumbleInsecure, die)
|
go startBridge(s, BridgeConf.GID, BridgeConf.CID, BridgeConf.Config, BridgeConf.MumbleAddr, BridgeConf.MumbleInsecure, die)
|
||||||
}
|
}
|
||||||
log.Printf("DU: %v MU %v\n", Bridge.DiscordUserCount, Bridge.MumbleUserCount)
|
|
||||||
if Bridge.Connected && Bridge.MumbleUserCount == 0 && Bridge.DiscordUserCount <= 1 {
|
if Bridge.Connected && Bridge.MumbleUserCount == 0 && Bridge.DiscordUserCount <= 1 {
|
||||||
log.Println("no one online, killing bridge")
|
log.Println("no one online, killing bridge")
|
||||||
Bridge.ActiveConn <- true
|
Bridge.ActiveConn <- true
|
||||||
|
MumbleReset()
|
||||||
|
DiscordReset()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,6 @@ func discordSendPCM(v *discordgo.VoiceConnection, pcm <-chan []int16, die chan b
|
|||||||
}
|
}
|
||||||
<-ticker.C
|
<-ticker.C
|
||||||
if len(pcm) > 1 {
|
if len(pcm) > 1 {
|
||||||
log.Println("looking for speech")
|
|
||||||
if !streaming {
|
if !streaming {
|
||||||
v.Speaking(true)
|
v.Speaking(true)
|
||||||
streaming = true
|
streaming = true
|
||||||
|
8
main.go
8
main.go
@ -31,6 +31,7 @@ func main() {
|
|||||||
discordGID := flag.String("discord-gid", lookupEnvOrString("DISCORD_GID", ""), "DISCORD_GID, discord gid")
|
discordGID := flag.String("discord-gid", lookupEnvOrString("DISCORD_GID", ""), "DISCORD_GID, discord gid")
|
||||||
discordCID := flag.String("discord-cid", lookupEnvOrString("DISCORD_CID", ""), "DISCORD_CID, discord cid")
|
discordCID := flag.String("discord-cid", lookupEnvOrString("DISCORD_CID", ""), "DISCORD_CID, discord cid")
|
||||||
discordCommand := flag.String("discord-command", lookupEnvOrString("DISCORD_COMMAND", "mumble-discord"), "Discord command string, env alt DISCORD_COMMAND, optional, defaults to mumble-discord")
|
discordCommand := flag.String("discord-command", lookupEnvOrString("DISCORD_COMMAND", "mumble-discord"), "Discord command string, env alt DISCORD_COMMAND, optional, defaults to mumble-discord")
|
||||||
|
autoMode := flag.Bool("auto", lookupEnvOrBool("AUTO_MODE", false), "bridge starts in auto mode")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
log.Printf("app.config %v\n", getConfig(flag.CommandLine))
|
log.Printf("app.config %v\n", getConfig(flag.CommandLine))
|
||||||
|
|
||||||
@ -86,7 +87,7 @@ func main() {
|
|||||||
Config: config,
|
Config: config,
|
||||||
MumbleAddr: *mumbleAddr + ":" + strconv.Itoa(*mumblePort),
|
MumbleAddr: *mumbleAddr + ":" + strconv.Itoa(*mumblePort),
|
||||||
MumbleInsecure: *mumbleInsecure,
|
MumbleInsecure: *mumbleInsecure,
|
||||||
Auto: false,
|
Auto: *autoMode,
|
||||||
Command: *discordCommand,
|
Command: *discordCommand,
|
||||||
GID: *discordGID,
|
GID: *discordGID,
|
||||||
CID: *discordCID,
|
CID: *discordCID,
|
||||||
@ -100,7 +101,10 @@ func main() {
|
|||||||
userCount := make(chan int)
|
userCount := make(chan int)
|
||||||
go pingMumble(*mumbleAddr, strconv.Itoa(*mumblePort), userCount)
|
go pingMumble(*mumbleAddr, strconv.Itoa(*mumblePort), userCount)
|
||||||
go discordStatusUpdate(discord, userCount)
|
go discordStatusUpdate(discord, userCount)
|
||||||
|
if *autoMode {
|
||||||
|
Bridge.AutoChan = make(chan bool)
|
||||||
|
go AutoBridge(discord)
|
||||||
|
}
|
||||||
sc := make(chan os.Signal, 1)
|
sc := make(chan os.Signal, 1)
|
||||||
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
|
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
|
||||||
<-sc
|
<-sc
|
||||||
|
@ -105,6 +105,9 @@ func (m MumbleDuplex) fromMumbleMixer(toDiscord chan []int16, die chan bool) {
|
|||||||
if sendAudio {
|
if sendAudio {
|
||||||
select {
|
select {
|
||||||
case toDiscord <- outBuf:
|
case toDiscord <- outBuf:
|
||||||
|
case <-die:
|
||||||
|
log.Println("Killing fromMumbleMixer")
|
||||||
|
return
|
||||||
default:
|
default:
|
||||||
log.Println("toDiscord buffer full. Dropping packet")
|
log.Println("toDiscord buffer full. Dropping packet")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user