feat: add -auto-transmit flag to start transmitting on connect
When -auto-transmit is passed, barnard automatically keys up the microphone as soon as the connection sync completes. Useful for testing, bots, and unattended operation. Usage: barnard -auto-transmit -server=mumble.example.com -username=test_bot
This commit is contained in:
committed by
Brandon McGinty
parent
3ca57a847c
commit
b861193306
@@ -29,6 +29,7 @@ type Barnard struct {
|
||||
|
||||
Stream *gumbleopenal.Stream
|
||||
Tx bool
|
||||
AutoTransmit bool // auto-start transmission on connect
|
||||
Connected bool
|
||||
|
||||
Ui *uiterm.Ui
|
||||
|
||||
@@ -110,6 +110,18 @@ func (b *Barnard) OnConnect(e *gumble.ConnectEvent) {
|
||||
b.AddOutputLine(fmt.Sprintf("Welcome message: %s", wmsg))
|
||||
}
|
||||
b.Ui.Refresh()
|
||||
|
||||
// Auto-start transmission if requested
|
||||
if b.AutoTransmit && b.Stream != nil && !b.Tx {
|
||||
err := b.Stream.StartSource(b.UserConfig.GetInputDevice())
|
||||
if err != nil {
|
||||
b.AddOutputLine(fmt.Sprintf("auto-transmit failed: %s", err.Error()))
|
||||
} else {
|
||||
b.Tx = true
|
||||
b.UpdateGeneralStatus(" AutoTx ", true)
|
||||
b.AddOutputLine("Auto-transmit started")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Barnard) OnDisconnect(e *gumble.DisconnectEvent) {
|
||||
|
||||
@@ -116,6 +116,7 @@ func main() {
|
||||
buffers := flag.Int("buffers", 16, "number of audio buffers to use")
|
||||
profile := flag.Bool("profile", false, "add http server to serve profiles")
|
||||
noiseSuppressionEnabled := flag.Bool("noise-suppression", false, "enable noise suppression for microphone input")
|
||||
autoTransmit := flag.Bool("auto-transmit", false, "start transmitting immediately on connect")
|
||||
logLevel := flag.String("log", "warn", "log level: debug, info, warn, error")
|
||||
logFile := flag.String("logfile", "", "write logs to this file (in addition to stderr)")
|
||||
|
||||
@@ -208,6 +209,7 @@ func main() {
|
||||
Config: gumble.NewConfig(),
|
||||
UserConfig: userConfig,
|
||||
Address: *server,
|
||||
AutoTransmit: *autoTransmit,
|
||||
MutedChannels: make(map[uint32]bool),
|
||||
NoiseSuppressor: noise.NewSuppressor(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user