#irc #reboot #io

app hashpipe

Unix pipes + IRC

3 releases

Uses old Rust 2015

0.1.2 Jul 8, 2017
0.1.1 Jan 2, 2017
0.1.0 Jan 1, 2017

MIT license

259 lines

#|: Pipe data to and from IRC

Hashpipe lets you connect stdin and stdout to IRC with Unix pipes. For example,

sleep 5; echo "done" | hashpipe --server irc.freenode.net

messages the #hashpipe channel on the Freenode network when a long-running command finishes.

By default, stdin is echoed to all channels hashpipe joins, and NOTICEs and PRIVMSGs are printed to stdout. You can even use it as a (poor) IRC client:

$ hashpipe -s irc.freenode.net
lm->#hashpipe: hello there hashpipe
hello to you, lm
lm->hashpipe: I can even /msg you
(I can't msg you back, though)

Hashpipe is also handy for snooping on IRC channels:

if hashpipe --server my.irc.server --channels "#commandcentre" | grep -m 1 "oh geez, it's the law"; then
  shred ~/Documents/secret/**/*

You can even do semi-interactive things with hashpipe:

echo "Say 'stop' in the next 60 seconds to cancel a reboot" | timeout 60 hashpipe -s my.irc.server | grep -m 1 "stop"
if [[ $ret -eq 1 ]]; then

Of course, the best application is sending channel spam^W^Wimportant messages to channels:

$ echo "srs bznz" | figlet -f slant | hashpipe -s irc.for.professionals -c "#important"
<hashpipe>                       __
<hashpipe>    _______________   / /_  ____  ____  ____
<hashpipe>   / ___/ ___/ ___/  / __ \/_  / / __ \/_  /
<hashpipe>  (__  ) /  (__  )  / /_/ / / /_/ / / / / /_
<hashpipe> /____/_/  /____/  /_.___/ /___/_/ /_/ /___/

Raw mode

Hashpipe can also parse stdin as raw IRC commands and/or output everything the server sends. This is primarily useful for sending direct PRIVMSGs or automating various oper tasks.

It understands how to parse the commands listed here. If a command fails to parse, it will warn you, but continue processing stdin.

For instance,

$ hashpipe --server my.irc.server -io
:my.irc.server 1 hashpipe :Welcome to My IRC Server hashpipe!hashpipe@213.456.8.92
:hashpipe!hashpipe@213.456.8.92 MODE hashpipe +x
JOIN #hashpipe
:hashpipe!hashpipe@213.456.8.92 JOIN #hashpipe
:my.irc.server 353 hashpipe @ #hashpipe :hashpipe @`lm` 
:my.irc.server 366 hashpipe #hashpipe :End of /NAMES list.
PRIVMSG #hashpipe :hello
PRIVMSG lm :hi there
NICK bob
:hashpipe!hashpipe@213.456.8.92 NICK :bob


    hashpipe [FLAGS] [OPTIONS] --server <server>

    -h, --help       Prints help information
    -d, --no-ssl     Disable SSL encryption
    -q               Only print errors (overrides -v; overridden by raw output)
    -i, --raw-in     Interpret STDIN as raw IRC commands
    -o, --raw-out    Echo everything from the IRC server directly
    -v               Verbosity (1 for info, 2 for debug)
    -V, --version    Prints version information

    -c, --channels <channels>    Channel(s) to speak in (defalt: #hashpipe, or nothing if using raw input)
    -n, --nick <nick>            Nickname to use (default: hashpipe)
    -p, --port <port>            Port to use (default: 6667, or 6697 with SSL)
    -s, --server <server>        IRC server to connect to


~120K SLoC