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
|
||||
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 {
|
||||
log.Println("no one online, killing bridge")
|
||||
Bridge.ActiveConn <- true
|
||||
MumbleReset()
|
||||
DiscordReset()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,6 @@ func discordSendPCM(v *discordgo.VoiceConnection, pcm <-chan []int16, die chan b
|
||||
}
|
||||
<-ticker.C
|
||||
if len(pcm) > 1 {
|
||||
log.Println("looking for speech")
|
||||
if !streaming {
|
||||
v.Speaking(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")
|
||||
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")
|
||||
autoMode := flag.Bool("auto", lookupEnvOrBool("AUTO_MODE", false), "bridge starts in auto mode")
|
||||
flag.Parse()
|
||||
log.Printf("app.config %v\n", getConfig(flag.CommandLine))
|
||||
|
||||
@ -86,7 +87,7 @@ func main() {
|
||||
Config: config,
|
||||
MumbleAddr: *mumbleAddr + ":" + strconv.Itoa(*mumblePort),
|
||||
MumbleInsecure: *mumbleInsecure,
|
||||
Auto: false,
|
||||
Auto: *autoMode,
|
||||
Command: *discordCommand,
|
||||
GID: *discordGID,
|
||||
CID: *discordCID,
|
||||
@ -100,7 +101,10 @@ func main() {
|
||||
userCount := make(chan int)
|
||||
go pingMumble(*mumbleAddr, strconv.Itoa(*mumblePort), userCount)
|
||||
go discordStatusUpdate(discord, userCount)
|
||||
|
||||
if *autoMode {
|
||||
Bridge.AutoChan = make(chan bool)
|
||||
go AutoBridge(discord)
|
||||
}
|
||||
sc := make(chan os.Signal, 1)
|
||||
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
|
||||
<-sc
|
||||
|
Loading…
Reference in New Issue
Block a user