Skip to content

Instantly share code, notes, and snippets.

@zotherstupidguy
Last active May 10, 2017 16:41
Show Gist options
  • Save zotherstupidguy/766e4a2c0103a05af6c3 to your computer and use it in GitHub Desktop.
Save zotherstupidguy/766e4a2c0103a05af6c3 to your computer and use it in GitHub Desktop.
IRC Channel IPs
#!/bin/sh
NICK=itouchthings
SERVER=irc.freenode.net
PORT=6667
CHAN="#ruby"
#PRIVMSG $CHAN :Greetings!
{
# join channel and say hi
#JOIN $CHAN
cat << IRC
NICK $NICK
USER itouchthings 8 x : itouchthings
WHO $CHAN %ni
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 -r _ code _ ip _ ; do
case $code in
354)
printf '%s\n' "$ip"
;;
*)
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment