Created
October 16, 2015 18:34
-
-
Save xorgnak/35b9d0d3836bdbed7a3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
nick="tircsh" | |
channel=testchan | |
server=irc.freenode.net | |
config=/tmp/irclog | |
[ -n "$1" ] && channel=$1 | |
[ -n "$2" ] && server=$2 | |
config="${config}_${channel}" | |
echo "NICK $nick" > $config | |
echo "USER $nick +i * :$0" >> $config | |
echo "JOIN #$channel" >> $config | |
trap "rm -f $config;exit 0" INT TERM EXIT | |
tail -f $config | nc $server 6667 | while read MESSAGE | |
do | |
case "$MESSAGE" in | |
PING*) echo "PONG${MESSAGE#PING}" >> $config;; | |
*QUIT*) ;; | |
*PART*) ;; | |
*JOIN*) ;; | |
*NICK*) ;; | |
*PRIVMSG*) echo "${MESSAGE}" | sed -nr "s/^:([^!]+).*PRIVMSG[^:]+:(.*)/[$(date '+%R')] \1> \2/p";; | |
*) echo "${MESSAGE}";; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment