Mattermost Recipe: How to connect IRC to Mattermost

Today, we introduce you to a new series of posts we’re doing on the Mattermost blog: Mattermost Recipes.

The goal of these posts is to provide you with solutions to specific problems, as well as a discussion about the details of the solution and some tips about how to customize it to suit your needs perfectly.

If there’s a Recipe you want us to cook up in the future, drop us a line on our forum.

 

Problem:

You have systems that use IRC and want to integrate them with Mattermost.

Solution:

(Note: This was done on Ubuntu 17.10 server. If you want to write one for your favorite distro let us know and we’ll link to it here!)

We will talk about three different ways you can hook IRC up to your Mattermost server:

1. Sameroom

Sameroom is a SaaS product that will connect a lot of different chat programs to a lot of other ones, including IRC and Mattermost. To set it up, you need to register your various accounts and then set up “tubes” between them.

Sameroom

Setting up a tube in Sameroom.

Once you have the tube set up, Sameroom will transmit messages in real time based on your configuration settings.

The Tube configuration page will let you see the status of your tubes.

Mattermost-IRC

A configured tube on Sameroom.

Sameroom gives away a single tube with five messages a day for free; unlimited plans start at $49 per month for five tubes. If you have more than a few IRC channels, it can get pretty expensive.

Advantages

  • Nothing to set up on your end
  • Supports multiple chat apps and protocols

Disadvantages

  • Can be expensive
  • You don’t control the hardware
  • You need to bring your own IRC server

2. Matterbridge

Matterbridge is similar to Sameroom in that it lets you connect many different protocols to each other. Unlike Sameroom, it’s a self-hosted Go application. This means that as long as you can get it running, it’s as cheap as the server it runs on. And, since it’s open source, you can audit the source code and contribute bug fixes.

Since it’s written in Go, you can install it with a few commands:

$ sudo apt update
$ sudo apt install golang
$ cd $GOPATH
$ go get github.com/42wim/matterbridge
$ cd ~/go/bin
$ ls
matterbridge

Once that’s done, use the sample configuration file as a template to set up your bridges. Here’s one that connects the Town Hall on my Mattermost server to the \#mmst-test channel on Freenode:

[irc]
    [irc.freenode]
    Server="irc.freenode.net:6667"
    Nick="matterbot"

[mattermost]
    [mattermost.work]
    Server="localhost"
    Team="Planet Express"
    Login="matterbridge"
    Password="hunter2"
    PrefixMessagesWithNick=true
    RemoteNickFormat="[{PROTOCOL}] <{NICK}> "

[[gateway]]
name=""
enable=true
    [[gateway.inout]]
    account="irc.freenode"
    channel="#mmst-test"

    [[gateway.inout]]
    account="mattermost.work"
    channel="town-hall"

Advantages

  • Open source and self-hosted
  • Connects multiple protocols

Disadvantages

  • You need to have your own IRC server
  • You need to install, configure and manage it

3. MatterIRCD

MatterIRCD is a minimal IRC server that connects directly to Mattermost. This lets you post directly from your IRC client to Mattermost without any intervening software. This approach is great if you already have an IRC server that you’d like to replace with Mattermost.

Installing it is about as easy as installing Matterbridge.

$ sudo apt update
$ sudo apt install golang
$ cd $GOPATH
$ go get github.com/42wim/matterircd
$ cd ~/go/bin
$ ls
matterircd

And, like Matterbridge, it comes with a sample configuration file that describes the various settings. Here’s one that creates an IRC server with a \#town-hall channel that connects to my Mattermost server’s Town Hall.

#interface:port to bind to. (default "127.0.0.1:6667")
Bind = "127.0.0.1:6667"

#specify default mattermost server/instance (default "")
DefaultServer = "chat.movetoiceland.com"

#an array of channels that only will be joined on IRC.
JoinInclude = ["#town-hall"]

Restrict = "chat.mycompany.com"

Advantages

  • Open source and self-hosted
  • Comes with its own IRC server

Disadvantages

  • You need to install, configure and manage it

Discussion

The system you end up using will depend on your goals. If you’re not very technical, your best choice is Sameroom. If you’ve got an existing IRC server you’d like to integrate with Mattermost, then you should go with Matterbridge. And if you have a system that communicates via IRC but you don’t have a server, you should choose MatterIRCD.

Also, these examples don’t cover TLS integration, which is supported by all three systems. If you’re going to be sending data over the Internet, you will want to ensure that your systems are all using encryption when transmitting data.

Sameroom has different security concerns. According to their security page they pass messages in real time and do not store them, and they encrypt the login credentials they store with a unique key that is rotated daily. This is a good level of security, but remember that you are trusting that they’ve implemented these protocols correctly.

Finally, special thanks to Wim for writing and maintaining both MatterIRCD and Matterbridge.

(Editor’s noteThis post was written by Paul Rothrock, Customer Community Manager at Mattermost, Inc. If you have any feedback or questions about Mattermost Recipe: How to connect IRC to Mattermost, please let us know.)

mm

Paul Rothrock is the Customer Community Manager at Mattermost, Inc. Prior to joining Mattermost, he served as a support product manager for Oracle. Paul also worked in tech support and as a publisher advocate for AddThis and has held several other software development roles over the years. Paul holds a bachelor of science degree in information sciences and technology from Penn State University.