mumble-discord-bridge/README.md

217 lines
8.5 KiB
Markdown
Raw Normal View History

2020-10-29 02:21:07 -04:00
# Mumble Discord Bridge
Mumble Discord Bridge is an open source Go application to bridge the audio between Mumble and Discord.
It was built with the hope that people can continue to use the voice application of their choice.
## Usage
Several configuration variables must be set for the binary to function correctly.
All variables can be set using flags or in the environment.
The binary will also attempt to load .env file located in the working directory.
```bash
Usage of ./mumble-discord-bridge:
-cpuprofile file
2021-04-19 23:25:45 -04:00
write cpu profile to file
-debug-level int
2021-04-19 23:25:45 -04:00
DEBUG_LEVEL, Discord debug level, optional, (default 1) (default 1)
2020-10-29 02:21:07 -04:00
-discord-cid string
2021-04-19 23:25:45 -04:00
DISCORD_CID, discord cid, required
-discord-command string
2021-04-19 23:25:45 -04:00
DISCORD_COMMAND, Discord command string, env alt DISCORD_COMMAND, optional, (defaults mumble-discord) (default "mumble-discord")
-discord-disable-text
2021-04-19 23:25:45 -04:00
DISCORD_DISABLE_TEXT, disable sending direct messages to discord, (default false)
2020-10-29 02:21:07 -04:00
-discord-gid string
2021-04-19 23:25:45 -04:00
DISCORD_GID, discord gid, required
2020-10-29 02:21:07 -04:00
-discord-token string
2021-04-19 23:25:45 -04:00
DISCORD_TOKEN, discord bot token, required
-mode string
2021-04-19 23:25:45 -04:00
MODE, [constant, manual, auto] determine which mode the bridge starts in, (default constant) (default "constant")
2020-10-29 02:21:07 -04:00
-mumble-address string
2021-04-19 23:25:45 -04:00
MUMBLE_ADDRESS, mumble server address, example example.com, required
-mumble-certificate string
2021-04-19 23:25:45 -04:00
MUMBLE_CERTIFICATE, client certificate to use when connecting to the Mumble server
-mumble-channel string
2021-04-19 23:25:45 -04:00
MUMBLE_CHANNEL, mumble channel to start in, using '/' to separate nested channels, optional
-mumble-disable-text
2021-04-19 23:25:45 -04:00
MUMBLE_DISABLE_TEXT, disable sending text to mumble, (default false)
2021-11-03 13:33:39 -04:00
-mumble-insecure bool ("true" or "false")
MUMBLE_INSECURE, mumble insecure, optional, (default false)
2020-10-29 02:21:07 -04:00
-mumble-password string
2021-04-19 23:25:45 -04:00
MUMBLE_PASSWORD, mumble password, optional
2020-10-29 02:21:07 -04:00
-mumble-port int
2021-04-19 23:25:45 -04:00
MUMBLE_PORT, mumble port, (default 64738) (default 64738)
2020-10-29 02:21:07 -04:00
-mumble-username string
2021-04-19 23:25:45 -04:00
MUMBLE_USERNAME, mumble username, (default: discord) (default "Discord")
-nice
2021-04-19 23:25:45 -04:00
NICE, whether the bridge should automatically try to 'nice' itself, (default false)
-to-discord-buffer int
2021-04-19 23:25:45 -04:00
TO_DISCORD_BUFFER, Jitter buffer from Mumble to Discord to absorb timing issues related to network, OS and hardware quality. (Increments of 10ms) (default 50)
-to-mumble-buffer int
TO_MUMBLE_BUFFER, Jitter buffer from Discord to Mumble to absorb timing issues related to network, OS and hardware quality. (Increments of 10ms) (default 50)
2020-10-29 02:21:07 -04:00
```
2021-01-05 12:16:51 -05:00
The bridge can be run with the follow modes:
2021-01-05 12:16:51 -05:00
```bash
auto
The bridge starts up but does not connect immediately. It can be either manually linked (see below) or will join the voice channels when there's at least one person on each side.
The bridge will leave both voice channels once there is no one on either end
manual
The bridge starts up but does not connect immediately. It will join the voice channels when issued the link command and will leave with the unlink command
constant
The bridge starts up and immediately connects to both Discord and Mumble voice channels. It can not be controlled in this mode and quits when the program is stopped
2021-01-03 21:20:01 -05:00
```
2021-01-05 12:16:51 -05:00
In "auto" or "manual" modes, the bridge can be controlled in Discord with the following commands:
```bash
2021-01-03 21:20:01 -05:00
!DISCORD_COMMAND link
2021-04-19 23:25:45 -04:00
Commands the bridge to join the Discord channel the user is in and the Mumble server
2021-01-03 21:20:01 -05:00
!DISCORD_COMMAND unlink
2021-04-19 23:25:45 -04:00
Commands the bridge to leave the Discord channel the user is in and the Mumble server
2021-01-03 21:20:01 -05:00
!DISCORD_COMMAND refresh
2021-04-19 23:25:45 -04:00
Commands the bridge to unlink, then link again.
2021-01-03 21:20:01 -05:00
!DISCORD_COMMAND auto
2021-04-19 23:25:45 -04:00
Toggle between manual and auto mode
2021-01-03 21:20:01 -05:00
```
2021-04-19 23:25:45 -04:00
2020-10-29 02:21:07 -04:00
## Setup
### Creating a Discord Bot
A Discord bot is required to authenticate this application with Discord.
The guide below provides information on how to setup a Discord bot.
[Create a Discord Bot](https://discordpy.readthedocs.io/en/latest/discord.html)
2021-02-07 12:53:54 -05:00
Individual Discord servers need to invite the bot before it can connect.
The bot requires the following permissions:
2021-04-19 23:25:45 -04:00
2021-02-07 12:53:54 -05:00
* View Channels
* See Messages
* Read Message History
* Voice Channel Connect
* Voice Channel Speak
* Voice Channel Use Voice Activity
### Finding Discord CID and GID
Discord GID is a unique ID linked to one Discord Server, also called Guild. CID is similarly a unique ID for a Discord Channel. To find these you need to set Discord into developer Mode.
[Instructions to enable Discord Developer Mode](https://discordia.me/en/developer-mode)
Then you can get the GID by right-clicking your server and selecting Copy-ID. Similarly the CID can be found right clicking the voice channel and selecting Copy ID.
2020-10-29 02:21:07 -04:00
2021-03-09 00:05:04 -05:00
### Generating Mumble Client (Optional)
Optionally you can specify a client certificate for mumble [Mumble Certificates](https://wiki.mumble.info/wiki/Mumble_Certificates)
If you don't have a client certificate, you can generate one with this command:
``` bash
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout cert.pem -out cert.pem -subj "/CN=mumble-discord-bridge"
```
2020-10-29 02:21:07 -04:00
### Binary
Prebuilt binaries are available.
2021-01-17 22:41:42 -05:00
The binaries require the opus code runtime library to be installed.
```bash
# Ubuntu
sudo apt install libopus0
```
2020-10-29 02:21:07 -04:00
```bash
curl -s https://api.github.com/repos/stieneee/mumble-discord-bridge/releases/latest | grep "mumble-discord-bridge" | grep "browser_download_url" | cut -d '"' -f 4 | wget -qi -
2020-10-29 02:21:07 -04:00
```
### Docker
This project is built and distributed in a docker container.
A sample docker command can be copied from below.
This service command will always attempt to restart the service due to the `--restart=always` flag even when the server is restarted.
For testing purposes it may be best to remove the restart flag.
Replace the environment variables with variable for the desired mumble server, discord bot and discord server/channel.
```bash
# Sample for testing
docker docker run -e MUMBLE_ADDRESS=example.com -e MUMBLE_PASSWORD=optional -e DISCORD_TOKEN=TOKEN -e DISCORD_GID=GID -e DISCORD_CID=CID stieneee/mumble-discord-bridge
# Run as a service
docker docker run -e MUMBLE_ADDRESS=example.com -e MUMBLE_PASSWORD=optional -e DISCORD_TOKEN=TOKEN -e DISCORD_GID=GID -e DISCORD_CID=CID --restart=always --name=mumble-discord-bridge -d stieneee/mumble-discord-bridge
# Stop the service
docker stop mumble-discord-bridge && docker rm mumble-discord-bridge
```
2020-11-08 17:58:08 -05:00
### Mumbler Server Setting
To ensure compatibility please edit your murmur configuration file with the following
```bash
opusthreshold=0
```
This ensures all packets are opus encoded and should not cause any compatibility issues if your users are using up to date clients.
2020-10-29 02:21:07 -04:00
## Building From Source
This project requires Golang to build from source.
A simple go build command is all that is needed.
Ensure the opus library is installed.
```bash
go build -o mumble-discord-bridge *.go
2021-01-17 22:41:42 -05:00
#or
make mumble-discord-bridge
2020-10-29 02:21:07 -04:00
```
2021-04-24 13:22:09 -04:00
### OpenBSD Users
OpenBSD users should consider compiling a custom kernel to use 1000 ticks for the best possible performance.
See [issue 20](https://github.com/Stieneee/mumble-discord-bridge/issues/20) for the latest discussion about this topic.
2021-04-19 23:25:45 -04:00
## Jitter Buffer
The bridge implements simple jitter buffers that attempt to compensate for network, OS and hardware related jitter.
These jitter buffers are configurable in both directions.
A jitter buffer will slightly the delay the transmission of audio in order to have audio packets buffered for the next time step.
The Mumble client itself includes a jitter buffer for similar reasons.
A default jitter of 50ms should be adequate for most scenarios.
A warning will be logged if short burst or audio are seen.
A single warning can be ignored multiple warnings in short time spans would suggest the need for a larger jitter buffer.
2020-10-29 02:21:07 -04:00
## Known Issues
Currently there is an issue opening the discord voice channel.
It is a known issue with a dependency of this project.
Audio leveling from Discord needs to be improved.
2021-01-19 13:51:32 -05:00
Delays in connecting to Mumble (such as from external authentication plugins) may result in extra error messages on initial connection.
There is an issue seen with Mumble-Server (murmur) 1.3.0 in which the bridge will loose the ability to send messages client after prolonged periods of connectivity.
This issue has been appears to be resolved by murmur 1.3.4.
2020-10-29 02:21:07 -04:00
## License
Distributed under the MIT License. See LICENSE for more information.
## Contributing
Issues and PRs are welcome and encouraged.
Please consider opening an issue to discuss features and ideas.
## Acknowledgement
The project would not have been possible without:
2021-04-19 23:25:45 -04:00
* [gumble](https://github.com/layeh/gumble)
* [discordgo](https://github.com/bwmarrin/discordgo)