## Slack bots suck

If you have ever been on IRC for long enough, chances are some channel you were on had a bot on it. Some bots are silly, they respond to phrases, often stuffed with inside jokes. Other bots are useful, they will tell you when things like code is pushed. Some run RPGs. A bot isn't really anything special, its just a user who's client happens to be a program. Often simple scripts written in python or shell or Perl (i would argue this is the only legitimate use of perl). They don't have fancy installation processes, you just edit the file for credentials if needed and set some varibles. You don't need API keys to use them. You certaintly don't need to pay to have lots of them. So when someone, who, may I add, never used IRC, decides that Slack is the best thing since sliced bread because bots, I felt the need to rant a little.

Slack bots are called "integrations". They are a joke. If you haven't written an IRC bot, you might not see why at first. Let us look into the average Slack bot, then an IRC bot.

First, you need to ask Slack nicely if you can have a bot. If you have more than 10, the mommy slack tells you that you've been a bad little boy and that you can't have that many without giving your brother some candy. After you've filled in the green form 51-a, you can proceed to deposit a self-attested affidavit to your local government agency. At some point of time, you receive some "keys".

Now you start a websocket (a socket but with more stuff to worry about), then do some authentication things. Then you get some json encoded stuff that you process with javascript or python (who am I kidding, you're going to be doing this in javascript obviously). Then you try to respond to that with some more json-y things and hope everything works ok.

IRC is an old protocol. It is well defined, client-independent, and works pretty much anywhere (you can see what I mean by this below). It is also a simple protocol.

No really, IRC is riddiculously simple. It is practical (but tedious) to use IRC purely from netcat or telnet. You can learn the entire functional part of the protocol over 2 readings of a tcpdump of the conversation (or search for documentation).

Use telnet or nc, and open a session with your IRC server. In this case its irc.freenode.net port 6667. You can also use openssl s_connect to connect to an SSL enabled port like 6697, and do things securely. When its done doing its thing, usually some initial messages, try this (the second command is needed on freenode but I am not sure it's needed on all servers):

NICK somenick
USER someuser 0.0.0.0 some FullName


Join a channel? JOIN #botwars. Want to send messages? Little weird, but you PRIVMSG #channel :Some Message after the colon. This is a nice guide I found.

Messages are nice and line-terminated. The protocol is trivial to parse for any competent programmer, and the best part is that you can have as many of these things as you want.

Oh and you can program them in whatever language you want because everything, EVERYTHING supports the ability to open a socket to a tcp server. Python does, ruby does it, whatever weird transcompiled javascript-sugar you use does it, freaking pascal does it. The esp8266 can do it. You have no excuse. Do not lecture me about how it is sooo much easier to do with slack because they encode shit in a format that your language parses for you.

If you are too tired to parse stuff yourself, I can guarentee you there is an IRC client library for it. There, now your itch about reinventing 3 lines of parsing code is cured. Did you notice this thing was free? And that you can host an IRC server youself? You probably realized you can have an IRC bot built into anything. Your monitoring scripts can have an IRC bot built into them. Your CI system can have an IRC hook. You can write a nice inside joke parser. You can write an electronic stoner.

Slack bots are a mere shadow of what you can do with IRC. They aren't new, and they certainly aren't improved.

Side note: IRC servers might send you pings occationally, just pong back. Hey, I never said that netcat was for day-to-day use, I was trying to prove a point.

I read Drew DeVault's article a long time ago but out of sheer coincidence, I decided to write this article shortly after he published this, which reflects most of what I said here, in a less rant-y fashion. I realized this and didn't want to publish but I showed him my draft and he told me to publish it anyway. Recommend reading both of those, and probably his entire blog too.