#!/usr/bin/perl -w # # TreoVisorCentral_notification # # AUTHOR: # Dan Harkless http://harkless.org/dan/software/ # # COPYRIGHT: # This file is Copyright (C) 2003 by Dan Harkless, and is released under the # GNU General Public License . # # USAGE: # % TreoVisorCentral_notification [-mobilize] [-treoize] [-truncsubj []] # # DESCRIPTION: # Takes a TreoCentral.com or VisorCentral.com "Reply to post" or "New Private # Message" email on stdin and filters it to contain just the URL, so that when # an SMS notification of the email is sent to you by my sms_biff script (or # equivalent), you'll be able to browse to the thread / private message # directly from the SMS popup on your Treo. See the commandline options below # for the details. # # For an example of how to call this from your .procmailrc (in conjunction # with sms_biff), see the TreoVisorCentral_notification entry on my Software # page (URL above). # # COMMANDLINE OPTIONS: # -mobilize # "discussion" in the URL will be replaced with "mobilediscussion", so that # you can read the new post(s) on your Treo using the more lightweight # mobile interface. Note that as of this writing, the "newpost" # functionality for the mobilediscussion board isn't as advanced as that for # the normal board -- it'll just always go to the (top of) the last page of # the thread, not to the exact first post you haven't yet read. # # -treoize # "visorcentral" in the URL will be changed to "treocentral", and "vcforum" # will be changed to "tcforum" to work around the long-standing # TreoCentral.com bug that causes notifications to randomly appear to be # from VisorCentral.com. # # -truncsubj [] # On "Reply to post" subjects, removes that text. In other words, the # subject becomes just the subject of the discussion board thread. # # Also, the Subject contents is truncated to characters. If no limit # is specified, this defaults to 32. This is appropriate if you're using my # sms_biff with its sms_biff_BODY_SUBJECT_CONSTRUCT set to "continuation", # to prevent long subjects from intruding into the body and crowding out the # URL. # # DATE MODIFICATION # ========== ================================================================== # 2003-03-01 Original. ## Modules used ################################################################ use English; # allow long English names like $PROGRAM_NAME instead of $0 use Getopt::Long; # for GetOptions() use File::Basename; # for basename() ## Main ######################################################################## $progname = basename($PROGRAM_NAME); use vars qw($opt_mobilize $opt_treoize $opt_truncsubj); # eliminate warnings if (!GetOptions("mobilize", "treoize", "truncsubj:i")) { print STDERR "Usage: $progname [-mobilize] [-treoize] [-truncsubj []]\n"; exit 1; } if (defined($opt_truncsubj) and $opt_truncsubj == 0) { $opt_truncsubj = 32; } $in_header = 1; while () { if ($in_header) { if ($opt_truncsubj and /^Subject: *(.*)$/) { $subject = $1; $subject =~ s/Reply to post '(.*)'/$1/; print "Subject: ", substr($subject, 0, $opt_truncsubj), "\n"; } else { print; if (/^$/) { $in_header = 0; } } } elsif (/(http:.*(newpost|private\.php))/) { $URL = $1; if ($opt_mobilize) { $URL =~ s/discussion/mobilediscussion/; } if ($opt_treoize) { $URL =~ s/visorcentral/treocentral/; $URL =~ s/vcforum/tcforum/; } print $URL; } }