#!/usr/bin/perl # vim:ts=4 ## You have to make a .forward file in the root of ## ## your home directory (the directory you end up in ## ## when you do 'cd'). .forward must start with the ## ## path to this script on the form: ## ## "|/home/username/path/mailtools.pl" ## ## Be sure to include the quotation marks! ## # Name of the file to store checked mail in. $mailfile = "/home/nut/botmail"; # Subject of the mails this script is going to check. # IMPORTANT: Make it the same as chk_subj in mailtools1.0.tcl $subject = "REPLAY: .*Upload Notice"; @mail = ; # From the mail being piped to this script # Subject: REPLAY: Score Upload Notice : Midas scored 1410090 on tfrceac foreach $line (@mail) { if($line =~ /Subject: $subject/) { $botmail = 1; # For further processing below @tmp = split(' ', $line); shift(@tmp); # Gets rid of "Subject:" shift(@tmp); # Gets rid of "REPLAY:" # get the shortname to pass to mamename.pl (make it a function) $shortname = $tmp[@tmp-1]; # Gets the last word on the line $marp = "\#marp MARP " . join(' ', @tmp); # Get the long name using the mamename.pl script $longname = `/home/nut/bin/mamename.pl $shortname`; $marp .= " - $longname"; } } if ($botmail == 1) { open(FOUT, ">>$mailfile") or die "Error opening file."; $marpdesc = ""; foreach $line (@mail) { # The new recording is in position x. if ($line =~ "The new recording is in position") { @tmp = split(' ', $line); # Position of recording is the last word, and get rid of the period $marppos = pop(@tmp); $marppos =~ s/\.$//; } if ($line =~ "The description for the recording is:") { $marptemp = $line; $marptemp =~ s/ The description for the recording is: '(.*)'\.//; $marpdesc = $1; } } $marp .= " (Position " . $marppos . ")"; # If there is a description, put a : between it and the rest of the line if ($marpdesc) { $marp .= " : " . $marpdesc; } # $marp example (next two lines) # MARP Score Upload Notice : username scored x on game - Long Game # (Position x) : Some description here print FOUT $marp . "\n"; close FOUT; }