#!/usr/bin/perl # This is intended to accept email from procmail as a filter # and prepare it for inclusion at hiptop nation hiptop.bedope.com # example procmailrc snippet: # :0fhb # |/home/dav/bin/munge_hiptop_nation_post.pl # -------------------------------- # note: Jan 11 17:29 PST # I know I posted it to my blog, but somehow it didn't occur to me # that anyone would notice, so now I'm sorta embarrassed that this # code is actually being looked at. So I just would like to say that # although this does work, it's not really pretty. When I get the chance # I'm going to use some CPAN modules to clean this up so it will work # more smoothly. If you're really interested, check back in a week or so. # -------------------------------- $in_headers = 1; open ( DEBUGOUT, ">/tmp/munge.log" ); print DEBUGOUT "BEGIN\n"; while () { print DEBUGOUT " 1: $_"; if ($_=~/^Subject: (.*)$/i) { # change the subject so it'll post to hiptop nation print "Subject: hn: $1\n"; #} elsif ($_=~/^From: /i) { # print "From: dav_hiptop\@danger-island.com\n"; #} elsif ($_=~/^Reply-To: /i) { # print "From: dav_hiptop@danger-island.com\n"; } elsif ($in_headers==1) { # look for the blank line that marks the end of header section print DEBUGOUT "hdr: $_"; if ($_=~/^$/) { $in_headers = 0; print "Reply-To: dav_hiptop\@danger-island.com\n"; print; # print the blank line # now print anything you want at top of the message body #print "Dav sez
:\n"; } else { print; # print the header line } } else { $line = $_; chop $line; print DEBUGOUT "got: $line\n"; if ($_=~/^$/) { # insert a

tag for blank lines # this is unnecessary, bedope does it $line = "

\n"; } else { # fix URLs # I really need to sit down and think this through sometime, 'cause # it is buggy. # but I don't care much at the moment.... if ($line=~/^http:\/\/AkuAku.org\/$/) { # replace the URL lin in my standard signature with a special one # for hiptop nation posts $line = "
[loc:sf,ca,usa|home|code|cc]"; } else { $line=~s/[^\/>]+(www\.\S+\.\S+)/http:\/\/$1/i; $line=~s/[^"](http:\/\/\S+)/$1<\/a>/i; $line=~s/\b([Mm]ie)\b/$1<\/a>/; $line=~s/Danger Hiptop/Hiptop<\/a>/; } #if ( length($line)<50 ) { # $line = "$line
"; #} } print "$line\n"; print DEBUGOUT "put: $line\n"; } } # now finish up with anything you want at the end #print "
[
*]"; print DEBUGOUT "END\n"; close DEBUGOUT;