#!/bin/sh # ttytter -exts=/home/vlb/ttytter/vlbext.pl -runcommand="/r" # # produces something like this: # # lane Not packing a rain coat or umbrella was a dick move on my part DATE=23 Oct # _EOTWEET_ # yarnharlot I think this rain is nature's way of saying "Don't go for a run." DATE=23 Oct # _EOTWEET_ # NOTE: Tweats can contain embedded newlines! # So we use \n_EOTWEET_\n as record separator # See http://www.perlmonks.org/?node_id=510202 dir=$HOME/web/Twitter DATE=`date "+%Y-%b-%d"` TIME=`date "+%H"` twitterlog=TwitterLog${DATE}.txt twtime=$HOME/.twtime cd $dir if [ ! -f $twitterlog ]; then touch $twitterlog chmod g+w $twitterlog fi ttytter -exts=/home/vlb/ttytter/vlbext.pl -runcommand="/r" | perl -e ' use Date::Parse; use Storable; open(TIMEDATA, "'$twtime'"); $lasttime = ; close TIMEDATA; open(TWITTERLOG, ">>'$twitterlog'"); $now = `date "+%H%M"`; my $colorstore = "/home/vlb/.colorstore"; store {}, $colorstore unless -r $colorstore; my %colors = %{ retrieve($colorstore) }; # direct to hash $/ = "\n_EOTWEET_\n"; while ($line = <>) { $star = 0; chomp $line; # Tweets can have embedded newlines # Convert to TWiki-style line breaks instead $line =~ s/\n\n/%BR%/g; $line =~ s/\n/%BR%/g; ($date = $line) =~ s/^.*DATE=(.*)$/\1/; $time = str2time($date); next if ($time <= $lasttime); ($sender = $line) =~ s/^(\w+) .*/\1/; $line =~ s/^(\w+) (.*)/\2/; $sender = lc($sender); # Convert typical UTF-8 "special characters" $line =~ s/\xe2\x80\xa2/*/g; # bullet $line =~ s/\xe2\x80\xa6/.../g; # ellipsis $line =~ s/\xe2\x80\x94/---/g; # em dash $line =~ s/\xe2\x80\x98/\047/g; # smart left single quote $line =~ s/\xe2\x80\x99/\047/g; # smart right single quote $line =~ s/\xe2\x80\x9c/"/g; # smart left double quote $line =~ s/\xe2\x80\x9d/"/g; # smart right double quote $line =~ tr/\000-\177//cd; # kill off remaining 8-bit chars ($tweet = $line) =~ s/^(.*)DATE=.*/\1/; # Filter: I do not want to see these next if ($tweet =~ /We Will Be Happy/i); next if ($tweet =~ /Gaddafi|Libya|Saif/i); next if ($tweet =~ /Egypt|Al Jazeera|Bahrain|Mubarak|Obama/i); next if ($tweet =~ /Japan|nuclear|reactor|tsunami/i); next if ($tweet =~ /One day I want to copy.*word for word/i); next if ($tweet =~ /this SEO expert walks into a bar/i); next if ($tweet =~ /.* http:..bkite\.com/); next if ($tweet =~ /.* http:..blip\.fm/); next if ($tweet =~ /.* http:..gowal\.la/); next if ($tweet =~ / mayor of |4sq\.com| foursquare/i); next if ($tweet =~ /A [0-3]\.[0-9] magnitude/); next if ($tweet =~ /EizabethPW.*RT.*GracePW/i); next if ($tweet =~ /Streaming from my N95/i); next if ($tweet =~ /The .*? Daily is out/); next if ($tweet =~ /More For (Virgo|Libra|Pisces)/i); next if ($tweet =~ /joined a twibe|favorited a lol/i); next if ($tweet =~ /Just added myself|Just listed myself/); next if ($tweet =~ /Just started using.*twply.com/i); next if ($tweet =~ /#magpie|alltop|herebeforeoprah|Twifficiency/i); next if ($tweet =~ / #emmit| #oscars| #greysanatomy|#\w+chat/i); next if ($tweet =~ / #tinystory| #A4T|#ff| #customerlove/i); next if ($tweet =~ / vagina| ovar[yi]| penis| uterus| masturbat/i); next if ($tweet =~ / douch| fart| menstru| tampon| pee | peed /i); next if ($tweet =~ / thr[eo]w up in my | vomit| die in a fire/i); next if ($sender =~ /lilyofoz/); # me if (($tweet =~ /vlb/) && ($sender !~ /vlb/)) { $star = 1; } $sender = "Vicki" if ($sender =~ /vlb/); # gack $tweet =~ s/LIKE A NINJA//; # Twitter links $tweet =~ s/@(\w+)/[[http:\/\/twitter.com\/\1][@\1]]/g; # Escape < $tweet =~ s/$sender:"; #DEBUG print TWITTERLOG "$sender: "; } else { my $color = int(rand(128)); $colors{$sender} = 'p' . $color; print TWITTERLOG "$sender: "; #print TWITTERLOG "$sender: "; } # print $tweet, " _", $date, "_\n"; # DEBUG print TWITTERLOG $tweet, " _", $date, "_"; print TWITTERLOG "\n--------------\n" } if ($now =~ /\d\d[03][0-4]/) { print TWITTERLOG "\n---+++ $now\n"; } close TWITTERLOG; if ($time > $lasttime) { open(TIMEDATA, ">'$twtime'"); print TIMEDATA $time; close TIMEDATA; } store(\%colors, $colorstore); '