Daniel Beer Atom | RSS | About

Slirc: IRC interface to Slack

18 Nov 2017

If you need to communicate with other people via Slack, but would prefer to avoid the web interface and Electron application, they offer an IRC gateway. Unfortunately, the gateway has some shortcomings that make it a fairly unsatisfactory solution:

I ended up implementing my own gateway in the form of a locally-running Perl script that communicates with Slack's RTM interface. This has numerous advantages over the official interface:

Installation and setup

Download the script here:

To run it, you will first need to install the prerequisite modules from CPAN. These are:

On most Linux systems, you will be able to install each of these with:

sudo cpan <module-list>

Make sure you have OpenSSL development headers installed before attempting to install the socket module.

You then need to create a configuration file. This should contain the following lines:

slack_token=<API key>
password=<Password for IRC server>
port=<Port for IRC server>

Save your configuration file and run the gateway with:

./slirc-20171127.pl <file.conf>

You should then be able to connect using the IRC client of your choice on the configured port using the password specified in the configuration file. The IRC server does not support TLS, and so doesn't bind to any address other than 127.0.0.1. If you need access to it across the network, you should use a TLS proxy or a TLS-capable IRC bouncer on the same host.

Obtaining an API key

You can obtain a "legacy" API key by requesting it via the web interface from your workspace owner. However, you can also obtain one yourself, since the web interface uses the RTM API.

To do this, log in via the web interface with your web browser's network request tracing enabled and wait. Eventually, the chat interface will be ready, and you should see a series of requests to the API. Pick any of them and look in the POST body for a parameter called token. As long as you don't explicitly log out (clearing cookies is fine), this key will remain usable.

A simple Perl script using LWP::UserAgent automates the process of extracting API keys from non-SSO login credentials:

Using the gateway

Multiple IRC clients can be connected simultaneously. Messages from any client will be sent via the Slack API. Messages and other events received from the Slack API will be broadcast to all connected IRC clients.

If the RTM connection goes down, all IRC clients will be disconnected and will need to reconnect. IRC clients that connect before the RTM connection is available will not be sent welcome messages until the connection is up.

A ChanServ-like user called X is present on the server. It supports the following commands:

/msg X newgroup <name>

Create a new private group. Users can be invited to the group via the usual /INVITE command.

/msg X newchan <name>

Create a new public channel.

/msg X archive <name>

Archive the given group or channel.

/msg X cat <file-id>

Fetch the given file and display it inline in the form of NOTICE messages.

/msg X disconnect

Disconnect and reconnect the RTM client.

Mentions of the form <@nickname> or <#channel> will be translated and appear correctly to clients using the web interface.

Copyright (C) 2017 Daniel Beer <>

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.