My disdain for Slack and many other Silicon Valley chat clients is well known, as is my undying love for IRC. With Slack making the news lately after their recent decision to disable the IRC and XMPP gateways in a classic Embrace Extend Extinguish move, theyve been on my mind and I feel like writing about them more. Lets compare writing a bot for Slack with writing an IRC bot.
First of all, lets summarize the process for making a Slack bot. Full details are available in their documentation. The basic steps are:
Alternatively, instead of steps 3 and 4 you can use the Real Time Messaging API, which is a websocket-based protocol that starts with an HTTP request to Slacks authentication endpoint, then a follow-up HTTP request to open the WebSocket connection. Then you set up events in a similar fashion. Refer to the complicated table in the documentation breaking down which events work through which API.
Alright, so thats the Slack way. How does the IRC way compare? IRC is an open
standard, so to learn about it I can just read RFC 1459, which on my system is
conveniently waiting to be read at
means I can just read it locally, offline, in the text editor of my choice,
rather than on some annoying website that calls authentication a triumphant
You dont have to read it right now, though. I can give you a summary here, like
I gave for Slack. Lets start by not writing a bot at all - lets just manually
throw some bits in the general direction of Freenode. Install netcat and run
nc irc.freenode.net 6667, then type this into your terminal:
NICK joebloe USER joebloe 0.0.0.0 joe :Joe Bloe
Hey, presto, youre connected to IRC! Type this in to join a channel:
Then type this to say hello:
PRIVMSG #cmpwn :Hi SirCmpwn, I'm here from your blog!
IRC is one of the simplest protocols out there, and its dead easy to write a bot for it. If your programming language can open a TCP socket (it can), then you can use it to write an IRC bot in 2 minutes, flat. Thats not even to mention that there are IRC client libraries available for every programming language on every platform ever - I even wrote one myself! In fact, that guy is probably the fifth or sixth IRC library Ive written. Theyre so easy to write that Ive lost count.
Slack is a walled garden. Their proprietary API is defined by them and only implemented by them. They can and will shut off parts you depend on (like the IRC+XMPP gateways that were just shut down). IRC is over 20 years old and software written for it then still works now. Its implemented by hundreds of clients, servers, and bots. Your CI supports it and GitHub can send commit notifications to it. Its ubiquitous and free. Use it!