Skip to content

Instantly share code, notes, and snippets.

@ishan-marikar
Forked from vivien/irccat
Last active August 29, 2015 14:26
Show Gist options
  • Save ishan-marikar/87965e6cf0a2be60d957 to your computer and use it in GitHub Desktop.
Save ishan-marikar/87965e6cf0a2be60d957 to your computer and use it in GitHub Desktop.
irccat - Using netcat with an IRC channel
#!/bin/sh
# Copyright 2014 Vivien Didelot <[email protected]>
# Licensed under the terms of the GNU GPL v3, or any later version.
NICK=irccat42
SERVER=irc.freenode.net
PORT=6667
CHAN="#irccat"
{
# join channel and say hi
cat << IRC
NICK $NICK
USER irccat 8 x : irccat
JOIN $CHAN
PRIVMSG $CHAN :Greetings!
IRC
# forward messages from STDIN to the chan, indefinitely
while read line ; do
echo "$line" | sed "s/^/PRIVMSG $CHAN :/"
done
# close connection
echo QUIT
} | nc $SERVER $PORT | while read line ; do
case "$line" in
*PRIVMSG\ $CHAN\ :*) echo "$line" | cut -d: -f3- ;;
#*) echo "[IGNORE] $line" >&2 ;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment