Skip to content

Instantly share code, notes, and snippets.

@zotherstupidguy
Forked from vivien/irccat
Last active August 29, 2015 14:21
Show Gist options
  • Save zotherstupidguy/9aee63064dcf6b76c1f3 to your computer and use it in GitHub Desktop.
Save zotherstupidguy/9aee63064dcf6b76c1f3 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Copyright 2014 Vivien Didelot <[email protected]>
# Licensed under the terms of the GNU GPL v3, or any later version.
#Jarkko Oikarinen first introduced IRC to the world in 1988. Five years later, he clearly defined the IRC protocol in RFC 1459, which made the whole protocol much more accessible. Armed with this information, you can get a better understanding of this simple text-based protocol and learn how to connect to IRC servers without using a special client. Once you have mastered this, you should find it a trivial task to write programs that connect to IRC.
#netcat kornbluth.freenode.net 6667
#The USER command is used to set the login, user modes, and real name. If I wanted to have a login of "paul," I would type the following, followed by Enter:
#NICK zotherstupidguy\rUSER foo x x whatever
NICK=irccat42
SERVER=irc.freenode.net
PORT=6667
CHAN="#hackspree"
{
# join channel and say hi
cat << IRC
NICK $NICK
USER irccat 8 x : irccat
JOIN $CHAN
PRIVMSG $CHAN :Greetings!
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 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