My vandal-fighting tool

edit

All scripts on this page need perl and Net::IRC.

I use this script for vandal-fighting. Beware that it is difficult to use and only works under Linux. I have only tested it under KDE with the focus protection level (set in the control center) set to "extreme". The script pops up a firefox window every time an anon-IP edits (except for talk pages) or somebody creates a new page.

#!/usr/bin/perl

use Net::IRC;
use strict;

our $irc = new Net::IRC;
our $conn = $irc->newconn(Nick => "Where" . int(rand(999)), Server => "browne.wikimedia.org", Port => 6667, Ircname => "W");

$conn->add_handler("public", \&onPublic);
$conn->add_handler("376", \&onConnect);
$irc->start;
 
sub onConnect {
       our $self = shift;
       $self->join("#en.wikipedia");
}

sub onPublic {
       our $self = shift;
       our $event = shift;
       our ($rawMessage) = $event->args;
       if ($event->nick eq "rc") {
          if (0) {
          if ($rawMessage =~ /Diff:(.*)/) {
             print "Pre: $1\n";
             $1 =~ m#(http://[^\s]+)#;
             print "La: " . $1 . "\n";
             system "firefox '$1' &";
             <STDIN>;
          }}

          $rawMessage =~ m#02(http://en.wikipedia.org[^ ]+)#;
          our $url = $1;
          $rawMessage =~ m#5\*.+03(.*)5\*# or die "blah";
          our $user = $1;
          chop $user;
          chop $user;
          chop $user;
          if ($url =~ /[Tt]alk:/) {return;}
          if ($url =~ /Sandbox/) {return;}
          if ($url =~ /Articles for deletion/) {return;}
          if ($url =~ /Wikipedia:Introduction/) {return;}
          chop $rawMessage;
          if ($user =~ m#^[\d\.]+$#) {
                &act($url);
          }
          if ($rawMessage =~ /N\x{03}10/) {
             print "New\n";
             &act($url);
          }
       }
}

sub act {
   our $ffWindows = `xwininfo -root -children|grep firefox-bin|wc -l`;
   chomp $ffWindows;
   if ($ffWindows < 81) { #the first FF window is 11; each next one adds 7; this means 116 is for 15 windows
      our $diffUrl = shift;
      system "firefox '$diffUrl'&";
   }
      return;
}

AIV notify script

edit

This script pops up a firefox window whenever somebody modifies WP:AIV (unless the edit summary makes it clear that an admin is editing it).

#!/usr/bin/perl

#Filename: aiv.pl
#You need perl and Net::IRC to run this
#People unfortunate enough to be using Windows can use ActivePerl: http://activeperl.com/Products/ActivePerl/ (be sure to then install Net::IRC)
#People fortunate enough to be using Debian or one of its derivatives (ex. Ubuntu/Kubuntu) can just apt-get libnet-irc-perl

#Commands to be typed on the commandline when someone adds to AIV
our $browserCommand = "firefox http://en.wikipedia.org/wiki/WP:AIV&";
our $beepCommand = "xterm -e \"printf '\\a';sleep 1\"";

#---------------------------------------------------------------------------
#If you don't speak perl, you probably don't  want to edit below this point
#---------------------------------------------------------------------------

use Net::IRC;
use strict;

our $irc = new Net::IRC;
our $conn = $irc->newconn(Nick => "Where" . int(rand(999)), Server => "browne.wikimedia.org", Port => 6667, Ircname => "W");

$conn->add_handler("public", \&onPublic);
$conn->add_handler("376", \&onConnect);
$irc->start;

sub onConnect {
       our $self = shift;
       $self->join("#en.wikipedia");
}

sub onPublic {
       our $self = shift;
       our $event = shift;
       our ($rawMessage) = $event->args;
       if ($event->nick eq "rc") {
          if ($rawMessage =~ /Wikipedia:Administrator intervention against vandalism/) {
             if (!($rawMessage =~ /empty/i) && !($rawMessage =~ /clear/i)) { #Don't include admins clearing the list
                system "$beepCommand";
                system "$browserCommand";
             }
          }
       }
}