5 =head1 NAME $RCSfile: nag.pl,v $
7 Nag: A progressively more aggressive 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 reads 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
86 use lib "$FindBin::Bin/../lib";
98 my $nagfile = "$ENV{HOME}/.nag/list";
101 my @days = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
103 return $days[(localtime (time)) [6]];
107 my $sigfile = "$ENV{HOME}/.signatures";
109 return unless -r $sigfile;
111 my $signature = "-- <br>";
113 open my $sigs, '<', $sigfile
114 or error "Unable to open signature file $sigfile - $!", 1;
121 $signature .= '<font color="#bbbbbb">';
122 $signature .= splice (@sigs, int (rand (@sigs)), 1);
123 $signature .= '</font>';
129 my ($sent, $date) = @_;
134 my $tagStr = '<hr><p style="text-align: center;">';
135 $tagStr .= "This message has been sent to you $sent time";
140 $tagStr .= " before<br>";
141 $tagStr .= "The last time this message was sent to you was $date<br>";
142 $tagStr .= "$FindBin::Script $VERSION<br></p>";
149 usage => sub { Usage },
150 verbose => sub { set_verbose },
151 debug => sub { set_debug },
155 'file', => \$nagfile,
156 ) or Usage 'Invalid parameter';
158 my $nagfilenew = "$nagfile.$$";
160 open my $nagsIn, '<', $nagfile
161 or error "Unable to open $nagfile for read access - $!", 1;
163 open my $nagsOut, '>', $nagfilenew
164 or error "Unable to open new nagfile $nagfilenew for write access - $!", 1;
174 my ($email, $subject, $when, $msgfile, $sent, $date) = split /\|/;
180 if ($when =~ /$dow/i or $when =~ /daily/i) {
181 verbose "Nagging $email with $msgfile...";
185 $footing = tag $sent, $date
193 my $msgfilename = $msgfile;
194 $msgfilename =~ s/~/$ENV{HOME}/;
196 open $msg, '<', $msgfilename
197 or error "Unable to open message file $msgfile - $!", 1;
209 or error "Unable to close message file $msg - $!", 1;
216 print $nagsOut "$email|$subject|$when|$msgfile|$sent|$date\n";
218 print $nagsOut "$_\n";
223 or error "Unable to close $nagfile - $!", 1;
226 or error "Unable to close $nagfilenew - $!", 1;
228 rename $nagfilenew, $nagfile
229 or error "Unable to rename $nagfilenew to $nagfile", 1;
233 =head1 CONFIGURATION AND ENVIRONMENT
235 DEBUG: If set then $debug is set to this level.
237 VERBOSE: If set then $verbose is set to this level.
239 TRACE: If set then $trace is set to this level.
247 L<Getopt::Long|Getopt::Long>
249 =head2 ClearSCM Perl Modules
263 <a href="http://clearscm.com/php/scm_man.php?file=lib/DateUtils.pm">DateUtils</a><br>
264 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
265 <a href="http://clearscm.com/php/scm_man.php?file=lib/Mail.pm">Mail</a><br>
266 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
271 =head1 BUGS AND LIMITATIONS
273 There are no known bugs in this script
275 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
277 =head1 LICENSE AND COPYRIGHT
279 Copyright (c) 2004, ClearSCM, Inc. All rights reserved.