5 =head1 NAME $RCSfile: nag.pl,v $
7 Nag: A progressively more agressive reminder program.
15 Andrew DeFaria <Andrew@ClearSCM.com>
23 Tue Jul 27 15:00:11 PDT 2004
27 $Date: 2013/06/13 14:36:03 $
33 Usage: nag.pl [-u|sage] [-ve|rbose] [-d|ebug] [-nos|ign] [-noe|xec]
38 -u|sage: Displays this usage
40 -d|ebug: Output debug messages
42 -noe|xec: No execute mode - just echo out what would have
43 been done (Default: exec)
44 -not|ag: Tag message with a signature detailing how many
45 times we've sent this email and when was the last time we
46 sent it (Default: Don't tag)
47 -nos|ign: Include random signature from ~/.signatures (Default: Don't
49 -f|ile <file> Use <file> as naglist (Default: ~/.nag/list)
53 This script read a file indicating who to remind. The format for this file is:
55 <email>|<subject>|<when>|<msgfile>|<sent>|<date>
57 nag.pl will change a message that was set to send on a particular day of the
58 week to daily after 3 messages were sent. So if you set the message to be send
59 on say Mon it will be sent to 3 weeks and then flip to be sent daily.
61 =head1 The following things should be done to improve this system:
67 Move naglist and message files to a database
71 Change MAPS to recognize when a message is returned from a nag message. Perhaps
72 tag it with X-Nag: <nag id> (will this come back when the user replies?). MAPS
73 would then white list the sender and deliver the email as well as put the nag in
84 use lib "$FindBin::Bin/../lib";
96 my $nagfile = "$ENV{HOME}/.nag/list";
99 my @days = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
101 return $days[(localtime (time)) [6]];
105 my $sigfile = "$ENV{HOME}/.signatures";
107 return unless -r $sigfile;
109 my $signature = "-- <br>";
111 open my $sigs, '<', $sigfile
112 or error "Unable to open signature file $sigfile - $!", 1;
119 $signature .= '<font color="#bbbbbb">';
120 $signature .= splice (@sigs, int (rand (@sigs)), 1);
121 $signature .= '</font>';
127 my ($sent, $date) = @_;
132 my $tagStr = '<hr><p style="text-align: center;">';
133 $tagStr .= "This message has been sent to you $sent time";
138 $tagStr .= " before<br>";
139 $tagStr .= "The last time this message was sent to you was $date<br>";
140 $tagStr .= "$FindBin::Script $VERSION<br></p>";
147 usage => sub { Usage },
148 verbose => sub { set_verbose },
149 debug => sub { set_debug },
153 'file', => \$nagfile,
154 ) or Usage 'Invalid parameter';
156 my $nagfilenew = "$nagfile.$$";
158 open my $nagsIn, '<', $nagfile
159 or error "Unable to open $nagfile for read access - $!", 1;
161 open my $nagsOut, '>', $nagfilenew
162 or error "Unable to open new nagfile $nagfilenew for write access - $!", 1;
172 my ($email, $subject, $when, $msgfile, $sent, $date) = split /\|/;
178 if ($when =~ /$dow/i or $when =~ /daily/i) {
179 verbose "Nagging $email with $msgfile...";
183 $footing = tag $sent, $date
191 my $msgfilename = $msgfile;
192 $msgfilename =~ s/~/$ENV{HOME}/;
194 open $msg, '<', $msgfilename
195 or error "Unable to open message file $msgfile - $!", 1;
206 or error "Unable to close message file $msg - $!", 1;
213 print $nagsOut "$email|$subject|$when|$msgfile|$sent|$date\n";
215 print $nagsOut "$_\n";
220 or error "Unable to close $nagfile - $!", 1;
223 or error "Unable to close $nagfilenew - $!", 1;
225 rename $nagfilenew, $nagfile
226 or error "Unable to rename $nagfilenew to $nagfile", 1;
230 =head1 CONFIGURATION AND ENVIRONMENT
232 DEBUG: If set then $debug is set to this level.
234 VERBOSE: If set then $verbose is set to this level.
236 TRACE: If set then $trace is set to this level.
244 L<Getopt::Long|Getopt::Long>
246 =head2 ClearSCM Perl Modules
260 <a href="http://clearscm.com/php/scm_man.php?file=lib/DateUtils.pm">DateUtils</a><br>
261 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
262 <a href="http://clearscm.com/php/scm_man.php?file=lib/Mail.pm">Mail</a><br>
263 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
268 =head1 BUGS AND LIMITATIONS
270 There are no known bugs in this script
272 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
274 =head1 LICENSE AND COPYRIGHT
276 Copyright (c) 2004, ClearSCM, Inc. All rights reserved.