Skip to content

Instantly share code, notes, and snippets.

@genewitch
Forked from vivien/irccat
Created June 27, 2017 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save genewitch/510b9d1d2f34ee87c3d3544d6247f3b4 to your computer and use it in GitHub Desktop.
Save genewitch/510b9d1d2f34ee87c3d3544d6247f3b4 to your computer and use it in GitHub Desktop.
irccat - Using netcat with an IRC channel
#!/bin/sh
# Copyright 2014 Vivien Didelot <vivien@didelot.org>
# 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