Home | ircpipe

ircpipe - netcat for IRC

A feature often purported by IRC proponents (of which I am one) is that IRC is simple enough that one can connect to it using telnet or netcat. But in practice

PING :e94e45cc

PONG :e94e45cc — this gets annoying fairly quickly. To be precise, it'll get

PING :be59fdbb

PONG :be59fdbb — annoying after exactly four minutes - the second time you're rudely interrupted, and have to frantically respond to

PING :62458450

with PONG :62458450 — or get your connection closed by the IRC server.


This is where ircpipe comes in: a simple utility that understands just enough IRC to handle those PINGs, as well as connection setup, authentication, and even joining an initial list of channels. The idea is to set up a pipe between an IRC network and stdin/stdout, which the user can then read from and write to without having to think about details.

~% ircpipe Usage: ircpipe [-pP] [-sSk] [-n NICK] [-j CHAN] HOST [PORT] ~% ircpipe -n girst_bot -j '#linux,#libera' -s irc.libera.chat

The above example connects securely (TLS) to the Libera.Chat network, as user girst_bot, and joins the #linux and #libera channels. From here on out, we have a very rudimentary IRC client: you'll receive messages sent to the joined channels, can interact with people by typing out the raw IRC commands–without having to look out for PINGS.

But the real reason I developed ircpipe, its the killer feature so to speak, is alerting myself when some rare(ish) event happens: A script is looking at a logfile, and once a matching log line was found, sends me a private message, which makes my smartphone ring.

~% journalctl -fu my-buggy-application.service | awk -F: '/fatal error:/{print "PRIVMSG girst :The thing happened! " $NF}' | ircpipe -n girst_bot -s irc.libera.chat
girst_bot: The thing happened! missing ), unterminated subpattern at position 4711

The whole shebang is implemented in <500 lines of C89, depending only on libc and libtls/libretls. So it'll probably run on any system, as long as it has access to the Internet and a C compiler. It's made available under the GPLv3 at git.gir.st/ircpipe.git. The README includes some more examples, as well as an explanation of the command line parameters.