mirror of
https://github.com/stryan/mumble-discord-bridge.git
synced 2024-11-14 19:45:41 -05:00
Merge pull request #15 from stryan/new-config
support nested mumble channel, add debug toggle
This commit is contained in:
commit
16a66719e1
@ -27,7 +27,7 @@ Usage of ./mumble-discord-bridge:
|
|||||||
-mumble-address string
|
-mumble-address string
|
||||||
MUMBLE_ADDRESS, mumble server address, example example.com, required
|
MUMBLE_ADDRESS, mumble server address, example example.com, required
|
||||||
-mumble-channel string
|
-mumble-channel string
|
||||||
MUMBLE_CHANNEL, mumble channel to start in, optional
|
MUMBLE_CHANNEL, mumble channel to start in, using '/' to seperate nested channels, optional
|
||||||
-mumble-disable-text
|
-mumble-disable-text
|
||||||
MUMBLE_DISABLE_TEXT, disable sending text to mumble, (default false)
|
MUMBLE_DISABLE_TEXT, disable sending text to mumble, (default false)
|
||||||
-mumble-insecure
|
-mumble-insecure
|
||||||
@ -40,6 +40,8 @@ Usage of ./mumble-discord-bridge:
|
|||||||
MUMBLE_USERNAME, mumble username, (default: discord) (default "Discord")
|
MUMBLE_USERNAME, mumble username, (default: discord) (default "Discord")
|
||||||
-nice
|
-nice
|
||||||
NICE, whether the bridge should automatically try to 'nice' itself, (default false)
|
NICE, whether the bridge should automatically try to 'nice' itself, (default false)
|
||||||
|
-debug
|
||||||
|
DEBUG_LEVEL, DISCORD debug level, optional (default: 1)
|
||||||
```
|
```
|
||||||
|
|
||||||
The bridge can be run with the follow modes:
|
The bridge can be run with the follow modes:
|
||||||
|
@ -24,7 +24,7 @@ type BridgeConfig struct {
|
|||||||
MumbleConfig *gumble.Config
|
MumbleConfig *gumble.Config
|
||||||
MumbleAddr string
|
MumbleAddr string
|
||||||
MumbleInsecure bool
|
MumbleInsecure bool
|
||||||
MumbleChannel string
|
MumbleChannel []string
|
||||||
MumbleDisableText bool
|
MumbleDisableText bool
|
||||||
Command string
|
Command string
|
||||||
GID string
|
GID string
|
||||||
|
8
main.go
8
main.go
@ -8,6 +8,7 @@ import (
|
|||||||
"os/signal"
|
"os/signal"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ func main() {
|
|||||||
mumbleUsername := flag.String("mumble-username", lookupEnvOrString("MUMBLE_USERNAME", "Discord"), "MUMBLE_USERNAME, mumble username, (default: discord)")
|
mumbleUsername := flag.String("mumble-username", lookupEnvOrString("MUMBLE_USERNAME", "Discord"), "MUMBLE_USERNAME, mumble username, (default: discord)")
|
||||||
mumblePassword := flag.String("mumble-password", lookupEnvOrString("MUMBLE_PASSWORD", ""), "MUMBLE_PASSWORD, mumble password, optional")
|
mumblePassword := flag.String("mumble-password", lookupEnvOrString("MUMBLE_PASSWORD", ""), "MUMBLE_PASSWORD, mumble password, optional")
|
||||||
mumbleInsecure := flag.Bool("mumble-insecure", lookupEnvOrBool("MUMBLE_INSECURE", false), " MUMBLE_INSECURE, mumble insecure, optional")
|
mumbleInsecure := flag.Bool("mumble-insecure", lookupEnvOrBool("MUMBLE_INSECURE", false), " MUMBLE_INSECURE, mumble insecure, optional")
|
||||||
mumbleChannel := flag.String("mumble-channel", lookupEnvOrString("MUMBLE_CHANNEL", ""), "MUMBLE_CHANNEL, mumble channel to start in, optional")
|
mumbleChannel := flag.String("mumble-channel", lookupEnvOrString("MUMBLE_CHANNEL", ""), "MUMBLE_CHANNEL, mumble channel to start in, using '/' to seperate nested channels, optional")
|
||||||
mumbleDisableText := flag.Bool("mumble-disable-text", lookupEnvOrBool("MUMBLE_DISABLE_TEXT", false), "MUMBLE_DISABLE_TEXT, disable sending text to mumble, (default false)")
|
mumbleDisableText := flag.Bool("mumble-disable-text", lookupEnvOrBool("MUMBLE_DISABLE_TEXT", false), "MUMBLE_DISABLE_TEXT, disable sending text to mumble, (default false)")
|
||||||
discordToken := flag.String("discord-token", lookupEnvOrString("DISCORD_TOKEN", ""), "DISCORD_TOKEN, discord bot token, required")
|
discordToken := flag.String("discord-token", lookupEnvOrString("DISCORD_TOKEN", ""), "DISCORD_TOKEN, discord bot token, required")
|
||||||
discordGID := flag.String("discord-gid", lookupEnvOrString("DISCORD_GID", ""), "DISCORD_GID, discord gid, required")
|
discordGID := flag.String("discord-gid", lookupEnvOrString("DISCORD_GID", ""), "DISCORD_GID, discord gid, required")
|
||||||
@ -47,6 +48,7 @@ func main() {
|
|||||||
discordDisableText := flag.Bool("discord-disable-text", lookupEnvOrBool("DISCORD_DISABLE_TEXT", false), "DISCORD_DISABLE_TEXT, disable sending direct messages to discord, (default false)")
|
discordDisableText := flag.Bool("discord-disable-text", lookupEnvOrBool("DISCORD_DISABLE_TEXT", false), "DISCORD_DISABLE_TEXT, disable sending direct messages to discord, (default false)")
|
||||||
mode := flag.String("mode", lookupEnvOrString("MODE", "constant"), "MODE, [constant, manual, auto] determine which mode the bridge starts in, (default constant)")
|
mode := flag.String("mode", lookupEnvOrString("MODE", "constant"), "MODE, [constant, manual, auto] determine which mode the bridge starts in, (default constant)")
|
||||||
nice := flag.Bool("nice", lookupEnvOrBool("NICE", false), "NICE, whether the bridge should automatically try to 'nice' itself, (default false)")
|
nice := flag.Bool("nice", lookupEnvOrBool("NICE", false), "NICE, whether the bridge should automatically try to 'nice' itself, (default false)")
|
||||||
|
debug := flag.Int("debug-level", lookupEnvOrInt("DEBUG", 1), "DEBUG_LEVEL, Discord debug level, optional, (default 1)")
|
||||||
|
|
||||||
cpuprofile := flag.String("cpuprofile", "", "write cpu profile to `file`")
|
cpuprofile := flag.String("cpuprofile", "", "write cpu profile to `file`")
|
||||||
|
|
||||||
@ -99,7 +101,7 @@ func main() {
|
|||||||
// MumbleConfig: config,
|
// MumbleConfig: config,
|
||||||
MumbleAddr: *mumbleAddr + ":" + strconv.Itoa(*mumblePort),
|
MumbleAddr: *mumbleAddr + ":" + strconv.Itoa(*mumblePort),
|
||||||
MumbleInsecure: *mumbleInsecure,
|
MumbleInsecure: *mumbleInsecure,
|
||||||
MumbleChannel: *mumbleChannel,
|
MumbleChannel: strings.Split(*mumbleChannel, "/"),
|
||||||
MumbleDisableText: *mumbleDisableText,
|
MumbleDisableText: *mumbleDisableText,
|
||||||
Command: *discordCommand,
|
Command: *discordCommand,
|
||||||
GID: *discordGID,
|
GID: *discordGID,
|
||||||
@ -135,7 +137,7 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Bridge.DiscordSession.LogLevel = 1
|
Bridge.DiscordSession.LogLevel = *debug
|
||||||
Bridge.DiscordSession.StateEnabled = true
|
Bridge.DiscordSession.StateEnabled = true
|
||||||
Bridge.DiscordSession.Identify.Intents = discordgo.MakeIntent(discordgo.IntentsAllWithoutPrivileged)
|
Bridge.DiscordSession.Identify.Intents = discordgo.MakeIntent(discordgo.IntentsAllWithoutPrivileged)
|
||||||
Bridge.DiscordSession.ShouldReconnectOnError = true
|
Bridge.DiscordSession.ShouldReconnectOnError = true
|
||||||
|
@ -13,14 +13,12 @@ type MumbleListener struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *MumbleListener) mumbleConnect(e *gumble.ConnectEvent) {
|
func (l *MumbleListener) mumbleConnect(e *gumble.ConnectEvent) {
|
||||||
if l.Bridge.BridgeConfig.MumbleChannel != "" {
|
|
||||||
//join specified channel
|
//join specified channel
|
||||||
startingChannel := e.Client.Channels.Find(l.Bridge.BridgeConfig.MumbleChannel)
|
startingChannel := e.Client.Channels.Find(l.Bridge.BridgeConfig.MumbleChannel...)
|
||||||
if startingChannel != nil {
|
if startingChannel != nil {
|
||||||
e.Client.Self.Move(startingChannel)
|
e.Client.Self.Move(startingChannel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func (l *MumbleListener) mumbleUserChange(e *gumble.UserChangeEvent) {
|
func (l *MumbleListener) mumbleUserChange(e *gumble.UserChangeEvent) {
|
||||||
l.Bridge.MumbleUsersMutex.Lock()
|
l.Bridge.MumbleUsersMutex.Lock()
|
||||||
|
Loading…
Reference in New Issue
Block a user