It turns out you don't even need vim for this part. Alvaro
pointed out that mutt's native capability, along with Perl, can make moderation a one-keystroke operation. I've updated the script for strict-cleanliness and Perl 5.10 grammar.
First, the script:
#!/usr/bin/env perl
use strict;
use warnings;
use feature qw(:5.10);
use Net::SMTP;
my ($action, $full_action, $token) = (undef, undef, undef);
given($0) {
when (/accept/) {
($action, $full_action) = qw(accept-quiet Accepting);
}
when (/reject/) {
($action, $full_action) = qw(reject-quiet Rejecting);
}
default {
die 'No mode defined.';
}
}
while(<>) {
next unless /^Subject: ([0-9A-Z-]{14}) : (CONSULT|REMINDER)/;
$token = $1;
last;
}
die 'No token defined.' unless defined $token;
my $smtp = Net::SMTP->new('localhost') or die "new: $!";
$smtp->mail('david@fetter.org');
$smtp->to('majordomo@postgresql.org');
$smtp->data;
$smtp->datasend(<
From: Moderation Bot
To: postgresql.org's Majordomo
Subject: $full_action token $token
$action $token
EOM
$smtp->dataend();
$smtp->quit;
Next, symlink it to majordomo-accept and majordomo-reject., then add the following to your .muttrc file:
macro pager R "|~/bin/majordomo-reject\nd" "Majordomo reject"
macro pager A "|~/bin/majordomo-accept\nd" "Majordomo accept"
You're now set up. To moderate, just read the message, and when you've read enough, hit R to reject, A to accept.
Thanks for the saved keystrokes, Alvaro!