Home

Awesome

go-discord-irc

Go Report Card GoDoc

Preview

Is this being maintained? Yes. But I want to merge all this functionality into the much superior matterbridge by 42wim.

This is IRC to Discord bridge was originally built for @compsoc-edinburgh and ImaginaryNet, but now it looks like more people are using it!

Features

(not a full list)

Gotchas

Things to keep in mind in terms of functionality:

It's built with configuration in mind, but may need a little bit of tweaking for it to work for you:

Configuration

The binary takes three flags:

The config file is a yaml formatted file with the following fields:

namerequires restartdefaultoptionaldescription
avatar_urlNohttps://ui-avatars.com/api/?name=${USERNAME}YesThe URL for the API to use to tell Discord what Avatar to use for a User when the user's avatar cannot be found at Discord already.
discord_tokenYesNoThe bot user token
discord_message_filterNoYesFilters messages from Discord to IRC when they match.
irc_message_filterNoYesFilters messages from IRC to Discord when they match.
irc_serverYesNoIRC server address
irc_server_nameYesNoUsed as a reference when PMing from Discord to IRC. Try to use short, simple one-word names like freenode or swift
channel_mappingsNoNoa dict with irc channel as key (prefixed with #) and Discord channel ID as value
guild_idNoNothe Discord guild (server) id
irc_passYesYespassword for connecting to the IRC server
suffixNo~dYesappended to each Discord user's nickname when they are connected to IRC. If set to _d2, if the name will be bob_d2
separatorNo_Yesused in fallback situations. If set to -, the fallback name will be like bob-7247_d2 (where 7247 is the discord user's discriminator, and _d2 is the suffix)
irc_listener_nameYes~dThe name of the irc listener
ignored_discord_idsSometimesYesA list of Discord IDs to not relay to IRC
allowed_discord_idsSometimesnullYesA list of Discord IDs to relay to IRC. null allows all Discord users to be relayed to IRC. Hot reload: IDs added to the list require a presence change to take effect.
puppet_usernameNousername of discord account being puppetedYesusername to connect to irc with
webirc_passNoYesoptional, but recommended for regular (non-simple) usage. this must be obtained by the IRC sysops
irc_listener_prejoin_commandsYesYeslist of commands for the listener IRC connection to execute (right before joining channels)
irc_puppet_prejoin_commandsYesYeslist of commands for each Puppet IRC connection to execute (right before joining channels)
debugYesfalseYesdebug mode
insecure,YesfalseYesTLS will skip verification (but still uses TLS)
no_tls,YesfalseYesturns off TLS
cooldown_durationNo86400 (24 hours)Yestime in seconds for a discord user to be offline before it's puppet disconnects from irc
show_joinquitNofalseyesdisplays JOIN, PART, QUIT, KICK on discord
max_nick_lengthNo30yesMaximum allowed nick length
ignored_irc_hostmasksNoYesA list of IRC users identified by hostmask to not relay to Discord, uses matching syntax as in glob
connection_limitYes0YesHow many connections to IRC (including our listener) to spawn (limit of 0 or less means unlimited)

The filename.yaml file is continuously read from and many changes will automatically update on the bridge. This means you can add or remove channels without restarting the bot.

An example configuration file can be seen in config.yml. Those marked as requires restart definitely require restart, but others may not currently be configured to automatically update.

This bot needs permissions to manage webhooks as it creates webhooks on the go.

https://discordapp.com/oauth2/authorize?&client_id=<YOUR_CLIENT_ID_HERE>&scope=bot&permissions=0x20000000

NEW IN 2020

Make sure you also give the bot application these intents too:

NEW IN 2022

Make sure you give the message content intent too:

Docker

First edit config.yml file to your needs. Then launch docker build -t go-discord-irc . in the repository root folder. And then docker run -d go-discord-irc to run the bot in background.

Development

A Makefile is provided to make getting started easier.

To build a binary run make build this will produce a binary of go-discord-irc in the root dir.

To build and run the binary run make run, this will use the config.yaml and start in debug.

To Execute tests run make test

Dependencies will be updated and installed with all the above commands or by running make dev