Everything2
Near Matches
Ignore Exact
Full Text
Everything2

Chatterbox Logger

created by chkno

(thing) by chkno (1.1 mon) (print)   ?   (I like it!) Sat Jan 06 2001 at 4:07:23

(Updated Wed Nov 21 12:50:42 PST 2001)

There used to be an awful mess of bad shell code, crontabs to drive it, bad locks that didn't work, etc. The below is a bit better.

To my horror, Wonko stumbled across this ugly beast (after he had wnitten his own), & linked it from E2 Chatterbox Archive.

Anyway, in hopes that no one ever actually read the old one, here is something slightly less embarrasing.


This is pretty self contained. It checks for new messages every $INTERVAL seconds, logs to $LOGFILE, & kicks out plantext readable output on stdout.

(Note: "fetch" is used to grab chatter. If your unix doesn't have a fetch, alter $GET appropiately.)

#!/bin/sh

URL="http://www.everything2.com/index.pl?node=chatterbox%20XML%20ticker"
GET="fetch -o - -q"
LOGFILE="$HOME/chatterbox.log.html"
TMPFILE="/var/tmp/`basename $0`a.$$"
TMPFILE2="/var/tmp/`basename $0`b.$$"
INTERVAL="60"

# Note:  This isn't an XML parser.  It's a big ugly hack.

trap cleanup 1 2 3 15

cleanup () {
 rm -f $TMPFILE $TMPFILE2 
 exit 
}

parsemsg () {
 while read line;do
  nick=`echo "$line"|cut -d\" -f2`
  nick=`echo "<a href=\"http://www.everything2.com/?node=$nick\">$nick</a>"`
  date=`echo "$line"|cut -d\" -f4|sed "s/..$/.&/"`
  date=`date -j $date +%T`
  line=`echo "$line"|sed "s/^[^>]*>//"|sed "s%</message>.*%%"`
  if echo "$line"|grep "^/me" >/dev/null;then
   line=`echo "$line"|sed "s%/me %%"`
   echo "<p><b><font size=-3>$date</font> * $nick $line</b>"
  else
   echo "<p><font size=-3><b>$date</b></font> &lt;$nick&gt; $line"
  fi
 done | sed "s%href=\"/%href=\"http://www.everything2.com/%g"
}


while true;do 


 $GET "$URL" > $TMPFILE
 #check for Word Galaxy
 if grep "<h3>Nate's Word Galaxy Generator</h3>" $TMPFILE >/dev/null;then
  # Every night, the Everything database is archived and ...
  sleep `expr $INTERVAL \* 4`
  continue
 fi

 # clean headerish stuff, compact to one msg per line, & feed into parsemsg()
 cat $TMPFILE          |
  sed "/CHATTER/d"     |
  sed "/^$/d"          |
  lam - -              |
  parsemsg > $TMPFILE2

 tail -100 $LOGFILE    |
  diff - $TMPFILE2     |
  grep "^> "           |
  cut -c3-             |
  tee -a $LOGFILE      |
  sed "{
s%<a [^>]*>%_%g
s%</a>%_%g
s%<[^>]*>%%g
s%&lt;%<%
s%&gt;%>%
s%&amp;%\&%
}"

 sleep $INTERVAL

done

printable version
chaos

E2 Chatterbox Archive E2 Explorer E2 Link and Logger Client E2 Java Chatterbox Client
autogenics Chatterbox Pinchemadre TMTOWTDI
exercise for the reader socket shell script ksh
awk Words carved into the walls Fetch in vitro
lam Piebald trap cheating
Selective Service bash Unix SED
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Just another sprinkling of indeterminacy
How your brain works
hiragana
The gods
Mauritius
Being for the Benefit of Mr. Kite
Cut The (idea) Technique up
The Ramones
Living it up in the Lowlands - an international Dutch nodermeet
Sequoia National Park
flint knapping
Salvation for modern Dads
Even things as amazing as stars burn out
Inferno - Contents
New Writeups
sitaraika
Colours(idea)
etouffee
Wild tides guard her secrets(poetry)
Lord Brawl
Dr. Horrible's Sing-Along Blog(review)
a8ksh4
regret(idea)
Heisenberg
Editor Log: July 2008(log)
sam512
halfway homes, catacombs, twilight zones(fiction)
Timeshredder
The Texas UFO Crash of 1897(event)
Heitah
The Dark Knight(review)
ignis_glaciesque
Uppsala(place)
ignis_glaciesque
diffusion of responsibility(idea)
TheOrientalAfrican
The Soft Meadow of my Childhood(event)
BookReader
The Dragon Slayers(fiction)
kohlcass
religiously fashionable(review)
Pavlovna
waulking song(thing)
tentative
Stick Man(poetry)
Everything 2 is brought to you by the letter C and The Everything Development Company