
How to write an IRC bot - janvdberg
http://sircmpwn.github.io/2018/03/10/How-to-write-an-IRC-bot.html
======
crispyporkbites
In summary to write an IRC bot, open a TCP socket to an IRC server in whatever
language you want and start doing stuff. To write a slack bot, go jump through
their hoops and proprietary tech, and maybe they'll let you do stuff.

Thank goodness the web and email are open protocols, let's hope in 10 years
time we have added a standard chat protocol to that list, and no one is
wasting time on proprietary chat platforms.

~~~
yosamino
> let's hope in 10 years time we have added a standard chat protocol to that
> list

Well we do have one now: XMPP. I was pleasantly surprised at the current state
of it, when I revisited it last year.

That being said, it's still not in a "just-works" state, and while I might
enjoy fidgeting around with it to get things like push messaging to work, I
can see why many people don't want to do that.

~~~
jimktrains2
> That being said, it's still not in a "just-works" state, and while I might
> enjoy fidgeting around with it to get things like push messaging to work, I
> can see why many people don't want to do that.

At least you're fidgeting around with an open protocol and not something
that's proprietary and won't work in a few months.

------
Posibyte
Sircmpwn is a user on this site. There are so many times I've opened a link to
a piece of software, an article, or a tutorial and thought "Wow, this is cool"
or "Hey, this is fun to read." And Sircmpwn has repeatedly been an author I've
seen that sort of content from and felt like I got something nice out of it
every time.

Sircompwn, if you're reading this, thanks for the neat content. I don't mind
stumbling upon them during my lunch breaks :)

~~~
iforgotpassword
Yeah, a bit like ludde in the old days. I've used or enjoyed scumm VM, openttd
and utorrent a lot.

I also remembered truecraft right now when I saw this post and went to check
on it. The git repo is now archived and read only, but didn't find a mention
anywhere if/why development was given up.

~~~
Sir_Cmpwn
TrueCraft needs a lot of work that I don't have time for right now, it gets in
the way of my other FOSS work. I'll work on it more if I make enough recurring
donation revenue to work on FOSS full time.

Progress: [https://drewdevault.com/donate](https://drewdevault.com/donate)

~~~
iforgotpassword
That makes sense, thanks for the clarification. That archived message on
github just felt like it's a permanent decision. And since I started using
sway recently I'm pretty OK with your priorities. ;)

------
jachee
Alternately:
[http://zork.net/~nick/shazbot/README.html](http://zork.net/~nick/shazbot/README.html)

~~~
pavel_lishin
I'm always very impressed by people who can write awesome things in bash.

------
grokkingStuff
As much as I like IRC, I don't get why the author hates slack so much. I
dislike slack (probably because of the culture in Slack groups) but I do think
that having a mobile app & ease of use is why Slack is okay. Not having to
deal with different servers & terminology that look scary also helps (a lot)
for most people using Slack.

Most people who use Slack haven't ever used IRC professionally (or at all) -
I've shown IRC to people who love Slack and I usually get "Ugh, it looks so
old fashioned and difficult to use" as a reaction. Looks matters a lot if you
want people to use it - most IRC clients are old or have designs based on old
clients.

Plenty of Slack clones out there that look decent that have similar business
models. What would be awesome if there's an IRC server that looked and acted
like Slack; nice features like:

\- a website to log into like Slack (with benefits like modern web design and
Github, Twitter, Facebook login). \- an irc client that looks decent on
website, desktop and phone clients (and doesn't run on electron). \- having
multiple channels for one company like Slack channels in a group. IRC
currently requires you to register several channels (which is annoying).

\------------

As for the difficulty in writing bots for Slack vs IRC, sure it's easier to
write stuff for Slack because:

\- most Slack bots/services are written by companies who want their third
party services to be easily integrated into whatever team communication their
client use.

\- most custom bots are variation of some bots that someone else has written
(anecdotal evidence but pretty sure it's true). I'm pretty sure it's not that
different for irc.

\- most people don't bother writing bots unless they're willing to play around
with bots; difficulty isn't an issue when it comes to writing one and I
haven't seen bot development treated as an actual task (it's more of a hack
that works and isn't really touched again.)

\------------

Honestly, this seems to be a case where the author neglects how real-life
people work in favor of code "niceness" (for lack of a better term). There's a
reason why most people use Microsoft products (and it isn't because they make
great software.)

~~~
SlowBro
What’s the nicest looking IRC client these days?

I lately only ever use any chat client sporadically so I’m out of touch, but
may be needing a platform soon.

Interesting note: I worked at AOL when AIM was introduced and was one of the
first users :-P When I moved to tech support of a local cable internet company
that was our official work chat :-)

~~~
croon
As someone who's been on irc since the mid 90s and have had and still do have
a couple of Irssis running in screens for 10+ years, I have to say that
irccloud is pretty great for ease of use. There was an open source clone
called ircanywhere, but it seems abandoned.

I have no idea what the future holds, and I always welcome new tools and
disruptions, and I'm using slack, discord, messenger etc for various
communities. What keeps me from leaving irc is:

* friction in moving all users that have been using an IRC channel for 20 years

* stupid stuff in slack and messenger like lock in and slow search. I really like grep:ing logs for links and discussions and then reading the context up and down, which I have found difficult in web services.

~~~
xPaw
If you're looking for an open source alternative to IRCCloud, then The
Lounge[1] pretty much fills that niche.

[1]
[https://github.com/thelounge/thelounge](https://github.com/thelounge/thelounge)

~~~
LinuxBender
Disclaimer: I personally do not need emoji's.

Does TheLounge let users upload custom emoji? I ask, because my coworkers say,
"You can take Slack from my cold dead hands". There was even a great emoji
war.

I would like to stand up a web interface to IRC and let folks play around on
it. I tried Convos, but it didn't seem to fit that piece of the puzzle.

For the backend, I have always used UnrealIRCD + Anope services. It has always
been rock solid and scales beyond any need I could imagine. It would be great
if there were a modern web interface I could put in front of it that people
would want to use.

~~~
MaxLeiter
No, it does not support that. Just uses unicode emojis and lets the OS/browser
handle the rendering

~~~
LinuxBender
Thanks. I totally understand and agree. The problem I am faced with is that
Slack (a former gaming company) has gotten people hooked / trained /
conditioned on the custom emoji.

------
pimeys
When I learn a new language, the first things I do is I write an IRC bot. Such
a fun task.

Right now my plan is to convert my good old (but still in heavy use, with
MegaHAL!) bot [0] to Haskell, while reading the book and learning the
language. The current bot was my last ever Ruby project and while I take using
a new language as a challenge, the Cinch [1] framework is definitely worth a
try if you want to create a bot quickly.

[0]
[https://github.com/pimeys/diskotappi](https://github.com/pimeys/diskotappi)
[1] [https://github.com/cinchrb/cinch](https://github.com/cinchrb/cinch)

------
8_hours_ago
For those wondering, RFC's can be installed to /usr/share/doc/rfc/txt/ with
the rfc package[0] on Arch Linux. Ubuntu has the doc-rfc package[1] with
installs to /usr/share/doc/RFC.

[0]:
[https://www.archlinux.org/packages/community/any/rfc/](https://www.archlinux.org/packages/community/any/rfc/)

[1]: [https://packages.ubuntu.com/xenial/doc-
rfc](https://packages.ubuntu.com/xenial/doc-rfc)

------
Panino
I tried the commands given (plus a few more I just guessed) and they all
worked. What an enlightening demonstration of IRC's simplicity! This comes at
a good time because I've been having issues with eggdrop, maybe now I'll just
write something tiny to replace the bits of functionality I want.

~~~
hex1848
TIL that eggdrop is still being developed / maintained.. I had a few bots
running around EFNet and Undernet in ~96. Hadn't heard this reference in
years.

[http://www.eggheads.org/](http://www.eggheads.org/)

~~~
efdee
Op me cause I'm lame.

------
janvdberg
FWIW, you can still use your favorite IRC client (e.g. WeeChat + Glowing Bear)
with Slack by using wee-slack ([https://github.com/wee-slack/wee-
slack](https://github.com/wee-slack/wee-slack))

~~~
apetresc
I've been using wee-slack for months, but I always assumed it was using the
IRC bridge under the hood - judging by the fact that it's still working right
now, I guess that's not the case :)

~~~
u801e
I think they'll shut down all remaining IRC and XMPP gateways by May 15. So we
still have a little over 2 months from now.

------
sudshekhar
Are there any good books/comprehensive resources for a beginner wanting to
experiment with the irc protocol? I tried setting up my own irc server on an
aws instance once. Opening the firewalls, connecting it to other clouds and to
the clients was hard [for me]. Would love a step by step guide, that gives
quick win and further confidence to get started.

This was my original inspiration: [https://aaronparecki.com/2015/08/29/8/why-
i-live-in-irc](https://aaronparecki.com/2015/08/29/8/why-i-live-in-irc)

------
chukye
so cool read IRC Bot in HN front page. I remember when I started to program,
hacking irc scripts for fun, thanks for the post, remembers me good times.
(RIP t7ds)

~~~
caioariede
mIRC scripts is what you meant, right? That's basically how I started in
programming.

One of the things that certainly contributed for keeping my interest in
programming was the quick feedback. No need for confusing setups, just open
the editor and start doing something. I know a lot of people that started this
way and are good programmers nowadays.

~~~
avemg
Can't speak for OP, but my progression went like this starting in 1995:

\- Start wasting lots of time in MSN chatrooms

\- Parents cancel MSN and switch to local ISP. Mourn loss of chatrooms.

\- Discover IRC using the mIRC client

\- Start playing around with mIRC scripting

\- Get into Linux because that's what the crowd I hung out with on IRC was
using

\- Switch to epic and BitchX and start scripting on this clients

\- Get into eggdrops and start scripting those and then start looking through
the actual source code and making changes

\- Start writing my own bots

Amazing how much my current career as a software dev is owed to things I
learned because I liked "wasting" time chatting online.

~~~
runeb
Nostalgic read! Same here, '96\. Then getting into irc wars, net splits and
nickname collisions, taking over channels. Finding bugs in eggdrop 1.1.5 to
gain op on channels. Never did work with TCL again though.

------
Lord_Zero
Shameless plug for our NodeJS IRC Bot Framework Tennu:
[https://github.com/Tennu/tennu](https://github.com/Tennu/tennu)

Connect in one line of code:

`require('tennu').Client('../config/myNetwork.json').connect();`

------
larrik
> IRC is over 20 years old

IRC is turning 30 this year, actually.

Yeah

------
earenndil
Not directly related, but I found an irc bot this guy wrote. IN BRAINFUCK.

[https://github.com/SirCmpwn/bf-irc-bot](https://github.com/SirCmpwn/bf-irc-
bot)

------
askz
RIP Eggdrops

------
purplezooey
Nuts. We were writing IRC bots in the 1990s when eggdrop bot was around.

~~~
vldr
anyone remember VladBot?

------
aluhut
I wish someone would pick up megahal and bring it up to date.

------
dmitriid
\- 80% of the article: complaining about Slack

\- 20% of the article: pretending to write a bot (and never actually writing a
bot) that does about 1% of what a bot on Slack can do

Article title: "How to write an IRC bot"

I've personally written a (admittedly crappy) four-way integration between
Slack, IRC, XMPP, and Telegram [1]. IRC and XMPP are consistently the worst
protocols to write for if you want anything but plain text. And believe you
me, people do want something besides plain text.

And don't get me started on clients for those :)

Funnily enough, irccloud is basically trying to do what Slack is doing, only
with IRC: a web-based interface, with private channels, embedded media, etc.
The only way to ,enjoy all that is to use the web-based clients, etc.

[1] [https://github.com/dmitriid/tetrad](https://github.com/dmitriid/tetrad)

~~~
nopacience
Seriously?

What did you expect? The secret sauce is on the client.

For example, user pastes in plain text, a youtube url:

userXXX: [http://youtube.com/cool-video](http://youtube.com/cool-video)

Then lets say user2 client reads that message, then it will parse it and check
if youtube.com has a plugin enabled. If it does, it will get the thumnail and
title and display it in a nicer way than just the URL. But it was initially
just a url.

I think you want a HTML chat with javascript. Try making that... and discover
that it is not secure to accept and run javascript from unkown users.

So plain text means securer! -- without code that might be evalled.

~~~
dmitriid
I see you've never used Slack before.

Slack doesn't run a "youtube plugin javascript". It does link unfurling [1].
Precisely for this reason: "it is not secure to accept and run javascript from
unkown users.". And, of course, it supports unfurling for a lot of things out
of the box: links, images, youtube and vimeo videos, spotify playlists etc.

That is there in the protocol/API. Your client may then chose to display those
unfurled links however it wants. Slack's client presents them more or less
exactly the way users may want, consistently across multiple platforms.

Neither IRC no XMPP have that. That's why you mistakenly think that the only
recourse is to "accept and run javascript from unkown users on the client".

And yes. Most users _do_ want a chat with formatting, unfurled links, inline
messages, inline video, emoji reactions, multifunctional bots etc. That's why
they flock to Slack, not to IRC/XMPP.

\---

[1] [https://api.slack.com/docs/message-link-
unfurling#slack_app_...](https://api.slack.com/docs/message-link-
unfurling#slack_app_unfurling)

