#!/usr/bin/perl # Editor script to use within mutt to approve / reject Mailman posts # # You must set $password to a valid admin password for Mailman. If you # moderate multiple lists with different passwords, some further # adjustment might be needed # # Example usage (in .muttrc): # macro index M ":set editor=~/bin/mutt_mailman_approve.pl \ # message/rfc822 \ # :set editor=\"vim +'/^$/+2'\"" # (and same for pager) # Then just hit "M" to approve / reject a message use strict; use File::Copy; use File::Temp qw(tempfile); use Term::ReadLine; my $file = $ARGV[0]; my $password = "mypasswd"; open(FILE, $file) or die "Couldn't open file $file\n"; my ($temp_fh,$temp_fn) = tempfile(); my $term = new Term::ReadLine "INPUT"; $term->ornaments('md,me,,'); my $didit; while () { chomp; print $temp_fh "$_\n"; if (/^Subject:/) { unless (/^Subject: Re: confirm/) { warn "Message doesn't appear to be a Mailman confirmation message\n"; last; } } next unless /^Reply-To:/; my $yesno; until ($yesno) { $yesno = $term->readline("Approve message? (y/n) (q to quit): "); lc(chomp($yesno)); if ($yesno =~ /^y/) { print $temp_fh "Approved: $password\n"; $didit = 1; } elsif ($yesno =~ /^n/) { print "Ok - rejecting\n"; $didit = 1; } elsif ($yesno =~ /^q/) { unlink $temp_fn; } else { print STDERR "Wha?\n"; undef($yesno); } } } if ($didit) { move($temp_fn,$file); } unlink $temp_fn;