1
0
mirror of https://github.com/stryan/mumble-discord-bridge.git synced 2024-11-23 05:45:41 -05:00

use string slice for mumble channel

This commit is contained in:
stryan 2021-02-08 13:16:09 -05:00
parent 7094f71f43
commit bcf0b30d1e
3 changed files with 9 additions and 9 deletions

View File

@ -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

View File

@ -8,6 +8,7 @@ import (
"os/signal" "os/signal"
"runtime/pprof" "runtime/pprof"
"strconv" "strconv"
"strings"
"syscall" "syscall"
"time" "time"
@ -99,7 +100,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,

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"fmt"
"log" "log"
"strings" "strings"
@ -13,12 +14,10 @@ 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)
}
} }
} }
@ -42,7 +41,7 @@ func (l *MumbleListener) mumbleUserChange(e *gumble.UserChangeEvent) {
log.Println("User connected to mumble " + e.User.Name) log.Println("User connected to mumble " + e.User.Name)
if !l.Bridge.BridgeConfig.MumbleDisableText { if !l.Bridge.BridgeConfig.MumbleDisableText {
e.User.Send("Mumble-Discord-Bridge v" + version) e.User.Send(fmt.Sprintf("Mumble-Discord-Bridge %v", version))
// Tell the user who is connected to discord // Tell the user who is connected to discord
if len(l.Bridge.DiscordUsers) == 0 { if len(l.Bridge.DiscordUsers) == 0 {